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

Add QuantumCircuit.noop for instructionless qubit use #13774

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

jakelishman
Copy link
Member

Summary

This closes a usability gap between the low-level construction of control-flow ops and the builder interface. In the builder interface, there was previously no way to consider a qubit to be "used" by the scope without adding some corresponding instruction on it. It was possible to express this already by manually constructing the blocks.

In general, this is not so useful for the control-flow operations that we already have present because the additional dependency is spurious and simply stymies some ability to perform optimisations. It is also a fair optimisation to remove the spurious data dependency in the transpiler. It becomes more useful with the upcoming box, however; this has additional semantics around its incident data dependencies.

Details and comments

Close #13767.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This closes a usability gap between the low-level construction of
control-flow ops and the builder interface.  In the builder interface,
there was previously no way to consider a qubit to be "used" by the
scope without adding some corresponding instruction on it.  It was
possible to express this already by manually constructing the blocks.

In general, this is not so useful for the control-flow operations that
we already have present because the additional dependency is spurious
and simply stymies some ability to perform optimisations.  It is also a
fair optimisation to remove the spurious data dependency in the
transpiler.  It becomes more useful with the upcoming `box`, however;
this has additional semantics around its incident data dependencies.
@jakelishman jakelishman added 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 labels Jan 31, 2025
@jakelishman jakelishman added this to the 2.0.0 milestone Jan 31, 2025
@jakelishman jakelishman requested a review from a team as a code owner January 31, 2025 13:50
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@jakelishman
Copy link
Member Author

Medium priority because it's part of the high-priority box epic, but technically not an absolutely hard requirement for fulfilment of the minimal viable implementation.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 13074080595

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 2 files are covered.
  • 19 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 88.811%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/two_qubit_decompose.rs 1 92.08%
crates/accelerate/src/unitary_synthesis.rs 1 92.97%
crates/qasm2/src/lex.rs 5 91.73%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 13072040346: -0.02%
Covered Lines: 79767
Relevant Lines: 89817

💛 - Coveralls

Copy link
Contributor

@alexanderivrii alexanderivrii left a comment

Choose a reason for hiding this comment

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

This PR is well-motivated and well-executed. My only (minor) question is whether we should use "future" examples in the documentation. @jakelishman. are you planning to add the QuantumCircuit.box method for 2.0.0?

Comment on lines +6197 to +6199
with qc.box():
# This control-flow block will only use qubits 0 and 1.
qc.cx(0, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

To make sure, we don't have the functionality qc.box() is Qiskit yet, correct? So this code example would not be runnable, would this be a problem?

Copy link
Member Author

@jakelishman jakelishman Feb 4, 2025

Choose a reason for hiding this comment

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

Oh yeah sorry, I wrote the example speculatively, but it's written against the spec of Qiskit/RFCs#76. I can change it to if_test for now if you like, but box is the bigger motivation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, since box will make it into 2.0 release, I am completely happy to keep this example as is.

@jakelishman
Copy link
Member Author

Yeah, box is a high-priority item for the 2.0 release - I'll be posting a PR for it in relatively short order.

@alexanderivrii alexanderivrii added this pull request to the merge queue Feb 4, 2025
Merged via the queue into Qiskit:main with commit 104aaca Feb 4, 2025
17 of 18 checks passed
@jakelishman jakelishman deleted the control-flow/noop branch February 4, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add convenience method to include an idle bit in control-flow builders
4 participants