-
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.
Fix performance regression in looped `QuantumCircuit.assign_parameter…
…s` (#13337) * Fix performance regression in looped `QuantumCircuit.assign_parameters` When calling `assign_parameters` on a heavily parametric circuit with the unusual access pattern of binding off a single parameter at a time, Qiskit 1.2 had a severe performance regression compared to Qiskit 1.1 stemming from gh-12794. The calls to `unsorted_parameters` on each iteration were creating a new `set`, which could be huge if the number of parameters in the circuit was large. In Qiskit 1.1 and before, that object was a direct view onto the underlying `ParameterTable` (assuming the input circuit did not have a parametric global phase), so was free to construct. * Improve documentation
- Loading branch information
1 parent
667ee8e
commit 5b1a358
Showing
3 changed files
with
56 additions
and
47 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
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
9 changes: 9 additions & 0 deletions
9
releasenotes/notes/assign-parameters-perf-regression-fc8c9db134b1763d.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,9 @@ | ||
--- | ||
fixes: | ||
- | | ||
Fixed a performance regression in :meth:`.QuantumCircuit.assign_parameters` introduced in Qiskit | ||
1.2.0 when calling the method in a tight loop, binding only a small number of parameters out of | ||
a heavily parametric circuit on each iteration. If possible, it is still more performant to | ||
call :meth:`~.QuantumCircuit.assign_parameters` only once, with all assignments at the same | ||
time, as this reduces the proportion of time spent on input normalization and error-checking | ||
overhead. |