-
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
Make SabreSwap account for clbits in predecessors #7952
Conversation
Previously, SabreSwap only checked that it was valid to add a gate back to the DAG by ensuring that all its qubit predecessors had already been added to the DAG. It did not check for clbit successors. This meant that measurements and (potentially, unverified) classically conditioned gates could be re-ordered out from the correct topological ordering. The most notable effect of this was that measurements writing to the same bit could be re-ordered, changing the output of the circuit. See Qiskitgh-7950 for more detail.
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 2191575209
💛 - Coveralls |
I approve of this bugfix, though I was sitting next to Jake while he crafted it 😁 (and the same bug actually exists in TOQM too!). |
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.
This LGTM it makes sense to me that we should be respecting all edges in the dag when looking for successors because there is a ordering dependency there and only looking at the quantum successors is giving us an incomplete picture. Just one inline comment on one small improvement
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
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.
looks good. I wonder if this fixes #7707
I ran the reproduce script in the issue with this applied locally and it returned and didn't get stuck in an infinite loop. |
The issue with commit b5b79d2 was that The PR now uses |
* Make SabreSwap account for clbits in predecessors Previously, SabreSwap only checked that it was valid to add a gate back to the DAG by ensuring that all its qubit predecessors had already been added to the DAG. It did not check for clbit successors. This meant that measurements and (potentially, unverified) classically conditioned gates could be re-ordered out from the correct topological ordering. The most notable effect of this was that measurements writing to the same bit could be re-ordered, changing the output of the circuit. See gh-7950 for more detail. * Add reno * Fix lint * Trim fat in SabreSwap._successors Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Fix _successors method Co-authored-by: Matthew Treinish <mtreinish@kortar.org> (cherry picked from commit 38f3705)
* Make SabreSwap account for clbits in predecessors Previously, SabreSwap only checked that it was valid to add a gate back to the DAG by ensuring that all its qubit predecessors had already been added to the DAG. It did not check for clbit successors. This meant that measurements and (potentially, unverified) classically conditioned gates could be re-ordered out from the correct topological ordering. The most notable effect of this was that measurements writing to the same bit could be re-ordered, changing the output of the circuit. See gh-7950 for more detail. * Add reno * Fix lint * Trim fat in SabreSwap._successors Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Fix _successors method Co-authored-by: Matthew Treinish <mtreinish@kortar.org> (cherry picked from commit 38f3705) Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Summary
Previously, SabreSwap only checked that it was valid to add a gate back
to the DAG by ensuring that all its qubit predecessors had already been
added to the DAG. It did not check for clbit successors. This meant
that measurements and (potentially, unverified) classically conditioned
gates could be re-ordered out from the correct topological ordering.
The most notable effect of this was that measurements writing to the
same bit could be re-ordered, changing the output of the circuit.
See gh-7950 for more detail.
Details and comments
Fix #7950. I also believe this to be the cause of the sporadic randomised test failures (see an example in the linked issue).
Ali (@ajavadia) - this might be something you ought to look at, since I don't understand SabreSwap well.