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

Improve deprecation of unit and duration #13247

Merged
merged 6 commits into from
Oct 7, 2024

Conversation

mtreinish
Copy link
Member

Summary

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.

Details and comments

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.
@mtreinish mtreinish added Changelog: Deprecation Include in "Deprecated" section of changelog Rust This PR or issue is related to Rust code in the repository mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Sep 30, 2024
@mtreinish mtreinish added this to the 1.3.0 milestone Sep 30, 2024
@mtreinish mtreinish requested review from nonhermitian and a team as code owners September 30, 2024 16:33
@mtreinish mtreinish added the Changelog: New Feature Include in the "Added" section of the changelog label Sep 30, 2024
@coveralls
Copy link

coveralls commented Sep 30, 2024

Pull Request Test Coverage Report for Build 11218352731

Details

  • 73 of 92 (79.35%) changed or added relevant lines in 9 files are covered.
  • 21 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.03%) to 88.871%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/delay.py 10 11 90.91%
qiskit/circuit/instruction.py 6 8 75.0%
qiskit/visualization/timeline/interface.py 2 4 50.0%
crates/circuit/src/operations.rs 14 19 73.68%
qiskit/visualization/timeline/core.py 4 13 30.77%
Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 2 88.26%
crates/qasm2/src/lex.rs 2 92.98%
qiskit/synthesis/two_qubit/xx_decompose/decomposer.py 6 90.91%
crates/circuit/src/circuit_instruction.rs 11 75.94%
Totals Coverage Status
Change from base Build 11217298881: -0.03%
Covered Lines: 74522
Relevant Lines: 83854

💛 - 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.

I see that the deprecation was trickier than expected. I left a few comments that are hopefully useful.

mtreinish and others added 2 commits October 1, 2024 10:56
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
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.

Mostly LGTM, just missing running black to fix CI. One comment is that it might be nicer to point to alternatives in the deprecation messages that say that unit/duration are deprecated. Something like "If this information is required for transpilation, it will be extracted from the target directly".

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!!

@mtreinish mtreinish added this pull request to the merge queue Oct 7, 2024
Merged via the queue into Qiskit:main with commit ec3f801 Oct 7, 2024
15 checks passed
@mtreinish mtreinish deleted the schedule-follow-ip branch February 21, 2025 11:33
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 Changelog: New Feature Include in the "Added" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants