-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid private methods when adding unused
Parameter
s (#34)
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.
- Loading branch information
1 parent
6e5b88a
commit 8aafe7c
Showing
4 changed files
with
73 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
fixes: | ||
- | | ||
The internal-only method of handling circuits that define a parameter that they do not use | ||
(such as a program that defines ``input float a;`` but doesn't use ``a``) has changed to | ||
avoid using private Qiskit methods. This makes it more resilient to changing versions | ||
of Qiskit. | ||
upgrade: | ||
- | | ||
OpenQASM 3 inputs that include ``input float`` parameters that are not used by the program | ||
will now parse to circuits that have a global phase that appears parametrised in terms of | ||
the otherwise-unused parameter. The numerical value of the global phase will not be affected, | ||
and the global phase will be independent of the parameters. You can discard the parameter | ||
by using ``QuantumCircuit.assign_parameters`` to assign any numeric value to the parameter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters