-
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.
Deprecate the unit and duration attributes (#13224)
* Deprecate the unit and duration attributes This commit deprecates the unit and duration attributes for QuantumCircuit and Instruction. These attributes will be removed in Qiskit 2.0 as they're not needed anymore and are adding a lot of complexity to the circuit data model as they're mutable state and extra memory slots that we need to keep around. The better model for tracking instruction duration is in the Target as it's inherently a property of the backend running the instructions. For the unittests this commit globally ignores the deprecation warning raised by this commit because internally we access the now deprecated access quite frequently as we need to check it when adding instructions to circuits to populate the rust data model. * Apply suggestions from code review Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --------- Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
73 additions
and
6 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
25 changes: 25 additions & 0 deletions
25
releasenotes/notes/deprecate-unit-duration-48b76c957bac5691.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,25 @@ | ||
--- | ||
deprecations_circuits: | ||
- | | ||
The :attr:`.QuantumCircuit.unit` and :attr:`.QuantumCircuit.duration` | ||
attributes have been deprecated and will be removed in Qiskit 2.0.0. These | ||
attributes were used to track the estimated duration and unit of that | ||
duration to execute on the circuit. However, the values of these attributes | ||
were always limited, as they would only be properly populated if the | ||
transpiler were run with the correct settings. The duration was also only a | ||
guess based on the longest path on the sum of the duration of | ||
:class:`.DAGCircuit` and wouldn't ever correctly account for control flow | ||
or conditionals in the circuit. | ||
- | | ||
The :attr:`.Instruction.duration` and :attr:`.Instruction.unit` attributes | ||
have been deprecated and will be removed in Qiskit 2.0.0. These attributes | ||
were used to attach a custom execution duration and unit for that duration | ||
to an individual instruction. However, the source of truth of the duration | ||
of a gate is the :class:`.BackendV2` :class:`.Target` which contains | ||
the duration for each instruction supported on the backend. The duration of | ||
an instruction is not something that's typically user adjustable and is | ||
an immutable property of the backend. If you were previously using this | ||
capability to experiment with different durations for gates you can | ||
mutate the :attr:`.InstructionProperties.duration` field in a given | ||
:class:`.Target` to set a custom duration for an instruction on a backend | ||
(the unit is always in seconds in the :class:`.Target`). |
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