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 representation of box #13869

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jakelishman
Copy link
Member

@jakelishman jakelishman commented Feb 18, 2025

This adds in the base box control-flow construction, with support for containing instructions and having a literal delay, like the Delay instruction.

This supports basic output to OpenQASM 3, QPY and some rudimentary support in the text and mpl drawers. The transpiler largely handles things already, since control flow is handled generically in most places.

Known issues:

  • QPY fails to round-trip the unit field from an instruction's duration.
  • We expect this to be able to accept stretches in its duration, just as Delay can, which will need a follow-up.
  • We expect Box to support "annotations" in a future release of Qiskit.
  • There is currently no way in OpenQASM 3 to represent a qubit that is idle during a box without inserting a magic instruction on it.
  • There's no support for import from OpenQASM 3 for box yet - that happens in different package (qiskit-qasm3-import) right now.
  • IBM backends don't claim support for box yet, so transpile against a backend will fail, though you can modify the Target to add the instruction manually.

Summary

Details and comments

No tests yet, but I tested various things casually - this is just the WIP to show what's going on.

Close #13772.

@jakelishman jakelishman added Changelog: New Feature Include in the "Added" section of the changelog mod: transpiler Issues and PRs related to Transpiler labels Feb 18, 2025
@jakelishman jakelishman added this to the 2.0.0 milestone Feb 18, 2025
@jakelishman jakelishman requested review from nonhermitian and a team as code owners February 18, 2025 15:28
@qiskit-bot
Copy link
Collaborator

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

  • @enavarro51
  • @Qiskit/terra-core
  • @mtreinish
  • @nkanazawa1989

@jakelishman jakelishman self-assigned this Feb 18, 2025
@coveralls
Copy link

coveralls commented Feb 18, 2025

Pull Request Test Coverage Report for Build 13442098597

Details

  • 68 of 139 (48.92%) changed or added relevant lines in 11 files are covered.
  • 30 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.1%) to 88.023%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/dagcircuit/dagnode.py 1 2 50.0%
qiskit/visualization/circuit/text.py 4 5 80.0%
qiskit/qasm3/ast.py 4 6 66.67%
qiskit/qpy/binary_io/circuits.py 3 6 50.0%
crates/circuit/src/dag_circuit.rs 1 5 20.0%
qiskit/circuit/quantumcircuit.py 17 23 73.91%
qiskit/visualization/circuit/matplotlib.py 0 6 0.0%
qiskit/qasm3/exporter.py 8 16 50.0%
qiskit/qasm3/printer.py 1 10 10.0%
qiskit/circuit/controlflow/box.py 27 58 46.55%
Files with Coverage Reduction New Missed Lines %
qiskit/circuit/quantumcircuit.py 1 93.39%
crates/qasm2/src/lex.rs 5 91.98%
crates/qasm2/src/parse.rs 24 96.22%
Totals Coverage Status
Change from base Build 13441968406: -0.1%
Covered Lines: 78366
Relevant Lines: 89029

💛 - Coveralls

This adds in the base `box` control-flow construction, with support for
containing instructions and having a literal delay, like the `Delay`
instruction.

This supports basic output to OpenQASM 3, QPY and some rudimentary
support in the text and mpl drawers.  The transpiler largely handles
things already, since control flow is handled generically in most
places.

Known issues:

- QPY fails to round-trip the `unit` field from an instruction's
  duration.
- We expect this to be able to accept stretches in its duration, just as
  `Delay` can, which will need a follow-up.
- We expect `Box` to support "annotations" in a future release of
  Qiskit.
- There is currently no way in OpenQASM 3 to represent a qubit that is
  idle during a `box` without inserting a magic instruction on it.
- There's no support for import from OpenQASM 3 for `box` yet - that
  happens in different package (`qiskit-qasm3-import`) right now.
- IBM backends don't claim support for `box` yet, so `transpile` against
  a backend will fail, though you can modify the `Target` to add the
  instruction manually.
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: transpiler Issues and PRs related to Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add box scope
4 participants