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 control-flow support to GatesInBasis #8823

Merged
merged 2 commits into from
Oct 1, 2022

Conversation

jakelishman
Copy link
Member

Summary

It's not yet entirely clear how control-flow will be supported through the Target and basis_gates, but for the time being, we just test them as if they will be added like any other instruction. This is unlikely to entirely remain the case as more classical handling is added.

Details and comments

It's not yet entirely clear how control-flow will be supported through
the `Target` and `basis_gates`, but for the time being, we just test
them as if they will be added like any other instruction.  This is
unlikely to entirely remain the case as more classical handling is
added.
@jakelishman jakelishman added priority: high Changelog: New Feature Include in the "Added" section of the changelog labels Sep 30, 2022
@jakelishman jakelishman added this to the 0.22 milestone Sep 30, 2022
@jakelishman jakelishman requested a review from a team as a code owner September 30, 2022 21:25
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

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.

Thanks for doing this it LGTM, it seems simple and straightforward enough.

@mtreinish
Copy link
Member

My thinking on the support was that a Target would need to contain the control flow ops the backend supported. We already require that measurement, reset, delay, and other non gate operations need to be in the target for it to be usable on the backend so I wasn't really treating control flow any differently. TBH, I was less interested in the BackendV1 basis gates approach and haven't thought about it much, although I guess the analogous thing would be to include the suported control flow instructions in the basis gates list.

@coveralls
Copy link

coveralls commented Sep 30, 2022

Pull Request Test Coverage Report for Build 3163192353

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.0009%) to 84.669%

Files with Coverage Reduction New Missed Lines %
qiskit/extensions/quantum_initializer/squ.py 2 79.78%
Totals Coverage Status
Change from base Build 3163192223: -0.0009%
Covered Lines: 61630
Relevant Lines: 72789

💛 - Coveralls

@jakelishman
Copy link
Member Author

At the moment there's an issue that control-flow operations are naturally variadic in qubit count, but even Target.add_instruction(ForLoopOp(...), {None: None}) still imposes a constraint on Target.instruction_supported that the number of qubits match. Since you can only hold one ForLoopOp instruction for the for_loop name, you can't really represent that variadicity.

@jakelishman
Copy link
Member Author

For V1, just throwing it in the basis gates will work for now. I suspect we'll probably need to look towards a V2.5 / backwards-compatible V3 as more classical control is added, but it does depend strongly on how much classical processing information we want to pass from backends to Terra.

@mtreinish
Copy link
Member

Well we can evolve the target interface independently of backend too. That's part of why I made them separate objects (although far from the primary reason). But that's something we'll have to look at for 0.23.0 I guess because it's a general issue for any variable width operation (thinking a global MS gate on ions would have the same problem). I'll open an issue to track this for 0.23.0.

@jakelishman
Copy link
Member Author

Oh, good forward thinking with the backend/target split, then - I hadn't fully considered that at all. Yeah, that does give us rather more freedom.

@mergify mergify bot merged commit 890f450 into Qiskit:main Oct 1, 2022
@jakelishman jakelishman deleted the control-flow-gates-in-basis branch October 5, 2022 11:04
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 priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants