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 Expr support to ControlFlowOp representation #10358

Merged

Conversation

jakelishman
Copy link
Member

Summary

This commit allows IfElseOp and WhileLoopOp to have a condition that is an Expr typed Bool(), and SwitchCaseOp to have a target that is an Expr. It does not fully add support to resolving these new allowed values into the control-flow builder interface (that will come later).

Details and comments

Close #10224.

Depends on #10332. Same consideration about release note.

Originally I was doing the control-flow builder interface as part of this commit as well since there's very little additional work needed to make that work. In practice, though, being able to test the builder interface requires a bunch of the DAGCircuit-related bits to be working as well, so I've split it off.

@jakelishman jakelishman added the Changelog: New Feature Include in the "Added" section of the changelog label Jun 29, 2023
@jakelishman jakelishman added this to the 0.25.0 milestone Jun 29, 2023
@jakelishman jakelishman requested a review from a team as a code owner June 29, 2023 17:25
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

@coveralls
Copy link

coveralls commented Jun 29, 2023

Pull Request Test Coverage Report for Build 5552067812

  • 118 of 121 (97.52%) changed or added relevant lines in 13 files are covered.
  • 18 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.001%) to 86.046%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/controlflow/switch_case.py 8 9 88.89%
qiskit/dagcircuit/dagcircuit.py 9 11 81.82%
Files with Coverage Reduction New Missed Lines %
qiskit/circuit/controlflow/switch_case.py 1 94.08%
qiskit/extensions/quantum_initializer/squ.py 2 80.0%
crates/qasm2/src/lex.rs 3 89.87%
crates/qasm2/src/parse.rs 12 97.11%
Totals Coverage Status
Change from base Build 5549582782: 0.001%
Covered Lines: 72260
Relevant Lines: 83978

💛 - Coveralls

kevinhartman
kevinhartman previously approved these changes Jul 13, 2023
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.

Very straightforward. These changes include #10332, so once that merges, this one is good to go too (after a rebase/merge).

I like how you were able to reuse a lot of the existing testing, and the integration points to enable expressions in the conditions and switch target are a lot more minimal than I was expecting!

This commit allows `IfElseOp` and `WhileLoopOp` to have a `condition`
that is an `Expr` typed `Bool()`, and `SwitchCaseOp` to have a `target`
that is an `Expr`.  It does not fully add support to resolving these new
allowed values into the control-flow builder interface (that will come
later).
@jakelishman
Copy link
Member Author

Now rebased on top of main.

@kevinhartman kevinhartman added this pull request to the merge queue Jul 14, 2023
Merged via the queue into Qiskit:main with commit 6749018 Jul 14, 2023
13 checks passed
@jakelishman jakelishman deleted the expr/condition-target-typecheck branch July 19, 2023 21:23
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for classical expressions to SwitchCaseOp, WhileLoopOp and IfElseOp
4 participants