`let` aliases: no `++` concatenation, no classical aliases, no alias-of-alias
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
Start in _visit_alias_statement in src/pyqasm/visitor.py, where the errors at about lines 2806 and 2811 are raised, then read how existing qubit aliases are stored as name-to-qubit-list mappings. Add handling for Concatenation values and alias-of-alias lookup, and extend the register lookup to classical bits. Tests belong in tests/qasm3/test_alias.py; done when the spec example runs end to end, but it also depends on the separate negative-indexing issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Limitation
Aliasing and
Register concatenation and slicing
define let over qubit and classical registers, allow the ++ concatenation operator in the
aliased expression, and allow an alias to be built from another alias.
pyqasm supports only the simple and sliced qubit-register cases. The spec's own worked
example fails on its second line.
Example QASM failure
The spec's example, verbatim:
OPENQASM 3.0;
qubit[2] one;
qubit[10] two;
let concatenated = one ++ two; // <-- fails here
let first = concatenated[0];
let last = concatenated[-1];
let qubit_selection = two[{0, 3, 5}];
let sliced = concatenated[0:6];
let every_second = concatenated[0:2:12];
let last_three = two[-4:-1];
let both = sliced ++ last_three;
ValidationError: Unsupported aliasing AliasStatement(... value=Concatenation(...))
Alias of an alias:
OPENQASM 3.0;
qubit[4] q;
let a = q;
let b = a[0];
// ValidationError: Qubit register a not found for aliasing
Classical register alias — the spec permits let over classical bits, and
For loops explicitly names "the target of a let
statement that creates an alias to classical bits" as an iterable:
OPENQASM 3.0;
bit[4] b;
let c = b;
// ValidationError: Qubit register b not found for aliasing
OPENQASM 3.0;
bit[2] a;
bit[2] b;
let c = a ++ b;
// ValidationError: Unsupported aliasing ...
Simple and sliced qubit aliases work today, including gates and delays applied to them, so the
alias machinery exists — it is the expression forms and the classical case that are missing.
Change Requested
- Handle
openqasm3.ast.Concatenationas an alias value, for both qubit and bit registers,
producing an alias whose length is the sum of its parts. - Resolve an alias target that is itself an alias, by looking through to the underlying
register. Nesting must work to arbitrary depth (sliced ++ last_threein the spec example
concatenates two aliases). - Support
letover classicalbit[n]registers, not only qubit registers, and correct the
error message, which currently says "Qubit register ... not found" even when the name refers
to a declared classical register. - Support the discrete-set alias form
two[{0, 3, 5}].
Negative indices inside alias expressions (concatenated[-1], two[-4:-1]) are covered by the
separate negative-indexing issue; the two should land together for the spec example to pass in
full.
Implementation Details
- Alias handling is
Qasm3Visitor._visit_alias_statementinsrc/pyqasm/visitor.py; the two
errors above are raised atvisitor.py:2806("Unsupported aliasing") and
visitor.py:2811("Qubit register ... not found for aliasing"). - The lookup at 2811 consults only the qubit register table. It needs to consult the classical
scope as well, and the resulting alias must record which kind it is so downstream index
resolution picks the right table. - Aliases are currently stored as a name → concrete-qubit-list mapping. Concatenation fits that
model directly: resolve each operand to its list and join them. Alias-of-alias then works
for free, provided the lookup checks the alias table before the register table. Concatenationnodes may nest (a ++ b ++ c), so resolution should recurse rather than
assume two operands.- A classical alias must be usable everywhere a
bit[n]is: as aforiterable, indexed,
sliced, and assigned to. Coordinate with thebit[n]representation issue. - Tests:
tests/qasm3/test_alias.py— the spec example above as a single end-to-end case,
plus qubit++, bit++, alias-of-alias, discrete-set alias, a gate applied through a
concatenated alias, and a length-mismatch error case.
- Lingua principale
- Python
- Stelle
- 29
- Fork
- 33
- Merge medio
- 1g 20h
- PR unite (30g)
- 8
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di qBraid/pyqasm
-
dumps() prints the original program when unroll() leaves at most one statementForse già presa @ShiveshDragon l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
qBraid/pyqasm#493 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement error-handling program-validation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 43/100
I maintainer di solito rispondono entro 1 giorno
-
dependencies enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di qBraid/pyqasm
Issue simili
-
docs(contributing): the two things that silently block a PRForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaavailable documentation good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 95/100
Nixitov/Riptide-Native#944 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
JTHCode/secretguard#24 ·
I maintainer di solito rispondono entro 1 giorno
-
area: middleware documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
omarelshamy25x/shamy-hijri#63 ·
I maintainer di solito rispondono entro 1 giorno