Open barakatzir opened 1 day ago
This is unfortunately a bit of a problem in the Qiskit data model around parametric gates - we can't, generally, tell from a given QuantumCircuit
how to get its definition in terms of arbitrary parameters if we only see it called with a fixed parameter, and we can't in general be certain that any given parametric gate
statement defines a gate that's properly consistent with a Qiskit standard-library gate. rzz
isn't in stdgates.inc
, so we have to define the gate in the file, but on reload, we can't tell that it's a standard-library gate (as opposed to some other gate that the user just called rzz
), which means we don't risk doing the wrong thing by silently switching to our version of RZZGate
.
The underlying issue is the same data-model thing alluded to in #9428. We have some plans to improve the situation for Qiskit built-in gates that aren't in the OpenQASM standard libraries in #10737, but we've not had chance to implement that yet. The OpenQASM 3 importer also hasn't been prioritised for a long time, so it sadly doesn't have much of the work-around functionality that the OpenQASM 2 importer has for dealing with these situations better - we also want to improve that, it'll just take time.
Fwiw, OpenQASM 3 is always going to be a lossy serialisation format for QuantumCircuit
- we try what we can to represent a circuit in valid OpenQASM 3, and to map valid OpenQASM 3 back to Qiskit concepts, but the mappings are very much not 1:1, so things always get changed between the export and the import.
Environment
What is happening?
Dumping loading and dumping again yields a different QASM3, with the wrong rzz custom gate definition (with fixed angle). While the circuit is technically correct this makes reasoning about the result of dumping and loading qasm3 files harder.
How can we reproduce the issue?
output
note that the custom rzz gate has a fixed angle
What should happen?
The gate in QASM3 should be defined as
Any suggestions?
No response