Skip to content

Support stretchy delays in box #13899

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

Merged
merged 1 commit into from
Jun 5, 2025
Merged

Conversation

jakelishman
Copy link
Member

@jakelishman jakelishman commented Feb 20, 2025

Summary

Mostly this just needed to re-use the existing handling from within Delay, and to teach the control-flow builders to look in another special place (BoxOp.duration) for potential Expr instances to close over.

Old PR message This is currently built on top of a roll-up merge of Kevin's `stretchy-delay` branch, and just unifies the handling between `Delay` and `Box` so that they both support the `Expr` stuff. There's no need for Rust-space handling for `box`, because the entirety of the control-flow system isn't handled in Python-space yet.

This might need further modification based on Kevin's work on transpiler support.

This commit will be rebased and amended along with the rest of the stretch patch series.

Details and comments

Built on top of both #13869 and #13853.

@jakelishman jakelishman added Changelog: New Feature Include in the "Added" section of the changelog mod: transpiler Issues and PRs related to Transpiler mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Feb 20, 2025
@jakelishman jakelishman added this to the 2.0.0 milestone Feb 20, 2025
@jakelishman jakelishman added the on hold Can not fix yet label Feb 20, 2025
@coveralls
Copy link

coveralls commented Feb 20, 2025

Pull Request Test Coverage Report for Build 15470983441

Details

  • 12 of 12 (100.0%) changed or added relevant lines in 3 files are covered.
  • 24 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.009%) to 87.972%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/circuit/src/symbol_expr.rs 2 73.85%
crates/qasm2/src/lex.rs 3 92.48%
crates/qasm2/src/parse.rs 18 96.68%
Totals Coverage Status
Change from base Build 15470434666: -0.009%
Covered Lines: 83015
Relevant Lines: 94365

💛 - Coveralls

@1ucian0
Copy link
Member

1ucian0 commented Feb 24, 2025

on hold until #13869 and #13853.

@jakelishman jakelishman modified the milestones: 2.0.0, 2.1.0 Mar 1, 2025
@kevinhartman
Copy link
Contributor

I'm sure you're probably quite busy at the moment, but depending on when 2.0 is going out, I can review this tomorrow if you want to rebase it.

@eliarbel eliarbel removed the on hold Can not fix yet label May 29, 2025
@eliarbel eliarbel modified the milestones: 2.1.0, 2.2.0 Jun 5, 2025
Mostly this just needed to re-use the existing handling from within
`Delay`, and to teach the control-flow builders to look in another
special place (`BoxOp.duration`) for potential `Expr` instances to close
over.
@jakelishman jakelishman marked this pull request as ready for review June 5, 2025 15:24
@jakelishman jakelishman requested a review from a team as a code owner June 5, 2025 15:24
@qiskit-bot
Copy link
Collaborator

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

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

@jakelishman jakelishman modified the milestones: 2.2.0, 2.1.0 Jun 5, 2025
Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

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

Simple enough—looks great. Thanks for enabling this!

Feel free to merge.

@@ -2724,6 +2724,8 @@ def append(
if copy and is_parameter:
Copy link
Contributor

Choose a reason for hiding this comment

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

Above this line (beyond the scope of your changes), I see that we assign to param. My eyes might be playing tricks on me, but is there a point to that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know why we bother with the assignment in the lines above - the commit that introduced the assignment (#10977) doesn't say why - before, we didn't have the assignment -, and we drop the variable immediately after. I suspect _validate_expr returns the input just for chaining convenience - there's at least one place that does node = _validate_expr(expr.lift(node)), so that's probably the base.

Either that, or some earlier version of the code (as in, during local development) had more of a call for it.

@jakelishman jakelishman enabled auto-merge June 5, 2025 15:45
@jakelishman jakelishman added this pull request to the merge queue Jun 5, 2025
Merged via the queue into Qiskit:main with commit 3a0b759 Jun 5, 2025
26 checks passed
@jakelishman jakelishman deleted the box/stretch branch June 5, 2025 16:18
rahaman-quantum pushed a commit to rahaman-quantum/qiskit that referenced this pull request Jun 20, 2025
Mostly this just needed to re-use the existing handling from within
`Delay`, and to teach the control-flow builders to look in another
special place (`BoxOp.duration`) for potential `Expr` instances to close
over.
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 mod: transpiler Issues and PRs related to Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants