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 tuple-like access to CircuitInstruction #12640

Merged

Conversation

jakelishman
Copy link
Member

Summary

This has been the legacy path since CircuitInstruction was added in gh-8093. It's more performant to use the attribute-access patterns, and with more of the internals moving to Rust and potentially needing more use of additional class methods and attributes, we need to start shifting people away from the old form.

Details and comments

Fix #12631.

The sister PR to Aer that fixes its remaining uses of this is Qiskit/qiskit-aer#2179.

@jakelishman jakelishman added Changelog: Deprecation Include in "Deprecated" section of changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Jun 21, 2024
@jakelishman jakelishman added this to the 1.2.0 milestone Jun 21, 2024
@jakelishman jakelishman requested a review from a team as a code owner June 21, 2024 16:48
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @kevinhartman
  • @mtreinish

This has been the legacy path since `CircuitInstruction` was added in
Qiskitgh-8093.  It's more performant to use the attribute-access patterns, and
with more of the internals moving to Rust and potentially needing more
use of additional class methods and attributes, we need to start
shifting people away from the old form.
@jakelishman jakelishman force-pushed the deprecate-legacy-instruction-iterable branch from 29980c1 to 9a08838 Compare June 21, 2024 17:04
@coveralls
Copy link

coveralls commented Jun 21, 2024

Pull Request Test Coverage Report for Build 9617201737

Details

  • 23 of 24 (95.83%) changed or added relevant lines in 1 file are covered.
  • 18 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.01%) to 89.764%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/circuit/src/circuit_instruction.rs 23 24 95.83%
Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 2 88.2%
crates/qasm2/src/lex.rs 4 91.6%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 9616513556: -0.01%
Covered Lines: 63667
Relevant Lines: 70927

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

LGTM, this is straightforward enough and it's good to have a deprecation warning pattern for Python from rust now.

Comment on lines +967 to +969
// Stack level. Compared to Python-space calls to `warn`, this is unusually low
// beacuse all our internal call structure is now Rust-space and invisible to Python.
1,
Copy link
Member

Choose a reason for hiding this comment

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

This isn't great, but yeah there isn't really an alternative because the call stack isn't really accessible here.

Copy link
Member Author

Choose a reason for hiding this comment

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

tbh, I think it might actually work out better from Rust space than it otherwise would, because this is only called by magic methods, which have weird callstacks already, since some of the "logical" parts of it are CPython internals already.

Setting stacklevel=1 here causes everything I could think of to get blamed on the actual triggering line in Python space.

@mtreinish mtreinish added this pull request to the merge queue Jun 24, 2024
Merged via the queue into Qiskit:main with commit 8b1f75f Jun 24, 2024
15 checks passed
@jakelishman jakelishman deleted the deprecate-legacy-instruction-iterable branch June 24, 2024 19:21
@1ucian0
Copy link
Member

1ucian0 commented Jun 26, 2024

I think, randomized tests is still using this deprecated behavior https://github.com/Qiskit/qiskit/actions/runs/9656096284/job/26633022278

1ucian0 added a commit to 1ucian0/qiskit-terra that referenced this pull request Jun 26, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jun 26, 2024
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
This has been the legacy path since `CircuitInstruction` was added in
Qiskitgh-8093.  It's more performant to use the attribute-access patterns, and
with more of the internals moving to Rust and potentially needing more
use of additional class methods and attributes, we need to start
shifting people away from the old form.
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate legacy iterable access to CircuitInstruction
5 participants