You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a ClassicalRegister is given a name containing curly braces, QASM 3 exporter produces invalid QASM, leading to job failures in the runtime. Note that this behavior is not observed when a QuantumRegister is given a name containing curly braces.
The motivation for using the curly braces in name was to subscript the register name when calling QuantumCircuit.draw(output="mpl"), which does not work ClassicalRegister and does work for QuantumRegister, but only after transpiling (a separate but related issue, I think).
Now I think about it, I know how this came about: originally, there was no need to test the register names for special symbols because they were constrained to only be valid OQ2 identifiers (i.e. [a-z][a-zA-Z0-9_]*) during the construction of the object, which is a strict subset of valid OQ3 identifiers once extra keywords are removed too. When that restriction was relaxed in #9100 it became possible in the OQ3 exporter to have an invalid register name.
I'm vaguely surprised that it doesn't cause similar problems for quantum registers, but no big deal.
Environment
What is happening?
When a
ClassicalRegister
is given aname
containing curly braces, QASM 3 exporter produces invalid QASM, leading to job failures in the runtime. Note that this behavior is not observed when aQuantumRegister
is given aname
containing curly braces.The motivation for using the curly braces in
name
was to subscript the register name when callingQuantumCircuit.draw(output="mpl")
, which does not workClassicalRegister
and does work forQuantumRegister
, but only after transpiling (a separate but related issue, I think).How can we reproduce the issue?
Actual output
QASM output
qreg
andc_{reg}
q_{reg}
andcreg
q_{reg}
andc_{reg}
qreg
andcreg
What should happen?
results
should contain expectedResult
for the given circuit.Any suggestions?
@jakelishman mentioned, "[it] sounds like there’s some place where the exporter fails to normalise an identifier into something exportable."
The text was updated successfully, but these errors were encountered: