-
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
Fix classical-bit handling in control-flow StochasticSwap #8906
Conversation
Previously we were expanding control-flow blocks to be full-width over _all_ wires, and only contracting the qubits back again, without changing the clbits given as node arguments. This modifies the The changes in most of the tests are necessary because the tests were testing behaviour that should be considered incorrect. The principal new test of all this behaviour is the additional assertions added in `_visit_block` in the random tests; these uniformly fail without this patch, and succeed with it.
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:
|
Pull Request Test Coverage Report for Build 3282607050
💛 - 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.
The code change looks good to me, but the one thing I think would be good is a dedicated test for this, or specifically with the follow-on effects to ensure we can serialize with qpy and qasm3 transpiled control flow circuits. Just to verify we don't regress this in the future, especially once we get sabre control flow aware.
This idea of writing post-transpile integration tests turned out to be an excellent idea - in trying to write them, I've already turned up more bugs in unrelated code than I was expected, such as #8923. |
These are general integration tests for QPY and OpenQASM 3 dumping, with a particular emphasis on making sure control-flow constructs don't invalidate these two operations.
Added more tests in fb30ff8. They need all of:
to merge first before they'll pass, because of other bugs I found while writing the integration tests. |
This PR should be ready to review and merge, now that its dependents are in. |
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.
LGTM, thanks for adding the extensive testing and fixing the long tail of issues it uncovered.
* Fix classical-bit handling in control-flow StochasticSwap Previously we were expanding control-flow blocks to be full-width over _all_ wires, and only contracting the qubits back again, without changing the clbits given as node arguments. This modifies the The changes in most of the tests are necessary because the tests were testing behaviour that should be considered incorrect. The principal new test of all this behaviour is the additional assertions added in `_visit_block` in the random tests; these uniformly fail without this patch, and succeed with it. * Add integration tests of some post-transpile work These are general integration tests for QPY and OpenQASM 3 dumping, with a particular emphasis on making sure control-flow constructs don't invalidate these two operations. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 514e383)
) * Fix classical-bit handling in control-flow StochasticSwap Previously we were expanding control-flow blocks to be full-width over _all_ wires, and only contracting the qubits back again, without changing the clbits given as node arguments. This modifies the The changes in most of the tests are necessary because the tests were testing behaviour that should be considered incorrect. The principal new test of all this behaviour is the additional assertions added in `_visit_block` in the random tests; these uniformly fail without this patch, and succeed with it. * Add integration tests of some post-transpile work These are general integration tests for QPY and OpenQASM 3 dumping, with a particular emphasis on making sure control-flow constructs don't invalidate these two operations. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 514e383) Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Previously we were expanding control-flow blocks to be full-width over all wires, and only contracting the qubits back again, without changing the clbits given as node arguments. This modifies the
The changes in most of the tests are necessary because the tests were testing behaviour that should be considered incorrect. The principal new test of all this behaviour is the additional assertions added in
_visit_block
in the random tests; these uniformly fail without this patch, and succeed with it.Details and comments
Fix #8903.