-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 conversion transpiler pass from c_if
to IfElseOp
#8764
Conversation
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:
|
This is intended to be used to ease the transition from the old-style conditions to the new-style form. Backends may use it in their custom pipelines, so they can guarantee they only need to deal with one form. A further classical optimisation may be to group `IfElseOp` blocks that share the same condition into a single operation, but this would likely be a separate pass, if added, or potentially be the domain of a separate part of the circuit-description/compilation/running pipeline.
a5dd085
to
59b4b78
Compare
Pull Request Test Coverage Report for Build 3147692364
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the code LGTM, this is a pretty straightforward replacement and you're more thorough than I would have been as I never would have thought about a user using c_if
inside a control flow block (but that could be because I'm not really used to dealing with recursive pass calling yet to work with control flow).
The only thing that I think would be good before we merge is some negative (as in not conditional instructions) test coverage. I think just a couple test to test a dag with no conditional operations to validate that it is unchanged on the output and also a test checking a control flow block with no conditional operations inside it (which was my one inline comment). They're not super important but just asserting this as part of the api will hopefully prevent bugs in the future just in case.
Summary
This is intended to be used to ease the transition from the old-style conditions to the new-style form. Backends may use it in their custom pipelines, so they can guarantee they only need to deal with one form.
A further classical optimisation may be to group
IfElseOp
blocks that share the same condition into a single operation, but this would likely be a separate pass, if added, or potentially be the domain of a separate part of the circuit-description/compilation/running pipeline.Details
Fixes #8601.
Will need rebasing over #8627 and #8615 once they merge, as this depends on them, and currently includes their commits. I just can't look at my screen any more tonight to wait til it merges.
edit: This is now rebased.
cc: @taalexander (this is the pass I wrote for you)