`let` aliases: no `++` concatenation, no classical aliases, no alias-of-alias
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 29
- Forks
- 33
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 8
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de qBraid/pyqasm
-
dumps() prints the original program when unroll() leaves at most one statementPosiblemente ocupada @ShiveshDragon la tomó hace 9 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
qBraid/pyqasm#493 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
enhancement error-handling program-validation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 43/100
Los mantenedores suelen responder en 1 día
-
dependencies enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de qBraid/pyqasm
Issues similares
-
docs(contributing): the two things that silently block a PRPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoavailable documentation good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 95/100
Nixitov/Riptide-Native#944 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
JTHCode/secretguard#24 ·
Los mantenedores suelen responder en 1 día
-
area: middleware documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
omarelshamy25x/shamy-hijri#63 ·
Los mantenedores suelen responder en 1 día