Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the unit and duration attributes #13224

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

mtreinish
Copy link
Member

Summary

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.

Details and comments

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.
@mtreinish mtreinish added Changelog: Deprecation Include in "Deprecated" section of changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Sep 25, 2024
@mtreinish mtreinish added this to the 1.3.0 milestone Sep 25, 2024
@mtreinish mtreinish requested a review from a team as a code owner September 25, 2024 23:30
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Sep 25, 2024

Pull Request Test Coverage Report for Build 11050184582

Details

  • 18 of 18 (100.0%) changed or added relevant lines in 2 files are covered.
  • 11 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 88.745%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 5 92.23%
crates/qasm2/src/parse.rs 6 97.61%
Totals Coverage Status
Change from base Build 11042619863: 0.02%
Covered Lines: 73823
Relevant Lines: 83186

💛 - Coveralls

Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I just added a few wording suggestions on the reno.

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
@ElePT ElePT added this pull request to the merge queue Sep 26, 2024
Merged via the queue into Qiskit:main with commit e3f5c25 Sep 26, 2024
15 checks passed
cameron-d28 pushed a commit to cameron-d28/qiskit that referenced this pull request Sep 26, 2024
* 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>
@mtreinish mtreinish deleted the deprecate-unit-duration branch September 30, 2024 16:23
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Sep 30, 2024
The unit and duration attributes of QuantumCircuit and Instruction were
introduced in Qiskit#13224 however the way the PR went about this was a bit to
abbreviated and it had several downsides. The most noticable was that it
introduced a significant runtime regression as the rust internals were
accessing the deprecated getter. This is fixed so that the rust code
doesn't try to access any deprecated attributes. However, more
importantly there were several edge cases not accoutned for in the PR.
Mainly, DAGCircuit's matching attribute were not deprecated, but then
also specific use cases of the attributes were not addressed. The
primary driver of the per instruction duration and unit were the
timeline visualization which didn't have a method to function without
these data attributes. This commit addresses this by adding a new
target argument that is used to provide a backend's target which is
the source of truth for durations in a post unit/duration `Instruction`.
The other notable edge case is the `Delay` instruction which will need
to retain the duration and unit attributes as the fields are integral
for that instruction. The `Delay` is updated to handle them explicitly
outside of the `Instrution` data model to avoid complications around the
deprecation.
github-merge-queue bot pushed a commit that referenced this pull request Oct 7, 2024
* Improve deprecation of unit and duration

The unit and duration attributes of QuantumCircuit and Instruction were
introduced in #13224 however the way the PR went about this was a bit to
abbreviated and it had several downsides. The most noticable was that it
introduced a significant runtime regression as the rust internals were
accessing the deprecated getter. This is fixed so that the rust code
doesn't try to access any deprecated attributes. However, more
importantly there were several edge cases not accoutned for in the PR.
Mainly, DAGCircuit's matching attribute were not deprecated, but then
also specific use cases of the attributes were not addressed. The
primary driver of the per instruction duration and unit were the
timeline visualization which didn't have a method to function without
these data attributes. This commit addresses this by adding a new
target argument that is used to provide a backend's target which is
the source of truth for durations in a post unit/duration `Instruction`.
The other notable edge case is the `Delay` instruction which will need
to retain the duration and unit attributes as the fields are integral
for that instruction. The `Delay` is updated to handle them explicitly
outside of the `Instrution` data model to avoid complications around the
deprecation.

* Apply suggestions from code review

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>

* Fix lint

* Mention the target in constructor deprecation message

---------

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
ElePT added a commit to ElePT/qiskit that referenced this pull request Oct 9, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants