Qiskit / qiskit-qasm3-import

Importer from OpenQASM 3 to Qiskit's QuantumCircuit
https://qiskit.github.io/qiskit-qasm3-import
Apache License 2.0
15 stars 7 forks source link

Avoid private methods when adding unused `Parameter`s #34

Closed jakelishman closed 3 months ago

jakelishman commented 3 months ago

Using private methods of QuantumCircuit to force tracking of unused Parameter instances resulting in the cleanest circuit output, but was fragile against Qiskit changing the private data structure internals. This has been a real problem as Qiskit moves more of the internal data tracking down to Rust space.

This changes the hacked-in tracking to use only public methods to insert a dummy reference, at the cost that a true reference is added in to the global phase. For most real-world uses of unused parameters (i.e. those in gate bodies), this will immediately be assigned out and so be invisible to users. The only place where this should appear to users is if there is an input float that is unused. In these cases, a dummy reference will be inserted into the global phase that has no effect.

Fix #33.