-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assign values directly to fully bound parameters in quantum circuits (#…
…10183) (#10192) * Assign circuit parameters as int/float to instructions * Do not test that fully bound parameters are still ParameterExpressions * Change int to float in qasm output pi_check casts integers to floats but not integers inside ParameterExpressions. * Workaround symengine ComplexDouble not supporting float * black * Update releasenotes/notes/circuit-assign-parameter-to-concrete-value-7cad75c97183257f.yaml Co-authored-by: Jake Lishman <[email protected]> * Update releasenotes/notes/circuit-assign-parameter-to-concrete-value-7cad75c97183257f.yaml Co-authored-by: Jake Lishman <[email protected]> * Restore assigned parameter value type check to tests * Add test to check type and value of simple circuit parameter assignment * Add consistency check between assigned instruction data and calibrations dict keys * Add regression test * Add upgrade note * Remove support for complex instruction parameter assignment * Restore complex assignment Complex assignment maybe not be supported but allowing it in the parameter assignment step lets validate_parameters get the value and raise an appropriate exception. * black * More specific assertion methods * Use exact floating-point check --------- Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: John Lapeyre <[email protected]> Co-authored-by: Jake Lishman <[email protected]> (cherry picked from commit 332bd9f) Co-authored-by: Will Shanks <[email protected]>
- Loading branch information
1 parent
4e71247
commit 615e42b
Showing
5 changed files
with
123 additions
and
16 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
29 changes: 29 additions & 0 deletions
29
releasenotes/notes/circuit-assign-parameter-to-concrete-value-7cad75c97183257f.yaml
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,29 @@ | ||
--- | ||
fixes: | ||
- | | ||
Changed the binding of numeric values with | ||
:meth:`.QuantumCircuit.assign_parameters` to avoid a mismatch between the | ||
values of circuit instruction parameters and corresponding parameter keys | ||
in the circuit's calibration dictionary. Fixed `#9764 | ||
<https://github.com/Qiskit/qiskit-terra/issues/9764>`_ and `#10166 | ||
<https://github.com/Qiskit/qiskit-terra/issues/10166>`_. See also the | ||
related upgrade note regarding :meth:`.QuantumCircuit.assign_parameters`. | ||
upgrade: | ||
- | | ||
Changed :meth:`.QuantumCircuit.assign_parameters` to bind | ||
assigned integer and float values directly into the parameters of | ||
:class:`~qiskit.circuit.Instruction` instances in the circuit rather than | ||
binding the values wrapped within a | ||
:class:`~qiskit.circuit.ParameterExpression`. This change should have | ||
little user impact as ``float(QuantumCircuit.data[i].operation.params[j])`` | ||
still produces a ``float`` (and is the only way to access the value of a | ||
:class:`~qiskit.circuit.ParameterExpression`). Also, | ||
:meth:`~qiskit.circuit.Instruction` parameters could already be ``float`` | ||
as well as a :class:`~qiskit.circuit.ParameterExpression`, so code dealing | ||
with instruction parameters should already handle both cases. The most | ||
likely chance for user impact is in code that uses ``isinstance`` to check | ||
for :class:`~qiskit.circuit.ParameterExpression` and behaves differently | ||
depending on the result. Additionally, qpy serializes the numeric value in | ||
a bound :class:`~qiskit.circuit.ParameterExpression` at a different | ||
precision than a ``float`` (see also the related bug fix note about | ||
:meth:`.QuantumCircuit.assign_parameters`). |
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