-
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 BarrierBeforeFinalMeasurements
deterministic
#9568
Make BarrierBeforeFinalMeasurements
deterministic
#9568
Conversation
The barrier-merging step at the end directly converted its inner (unordered) sets of bits into (ordered) lists, which is an operation dependent on `PYTHONHASHSEED`. This can have an impact on subsequent topological iteration orders, if there are any barriers that are not full-width in the circuit, which can in turn cause later stochastic transpiler passes to have different outputs for fixed random seeds, depending on `PYTHONHASHSEED`.
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:
|
@@ -57,6 +57,7 @@ class MergeAdjacentBarriers(TransformationPass): | |||
|
|||
def run(self, dag): | |||
"""Run the MergeAdjacentBarriers pass on `dag`.""" | |||
indices = {qubit: index for index, qubit in enumerate(dag.qubits)} |
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.
releasenotes/notes/deterministic-barrier-before-final-measurements-04e817d995794067.yaml
Outdated
Show resolved
Hide resolved
Pull Request Test Coverage Report for Build 4145966758
💛 - 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.
LGTM, thanks for the quick update. Do you think this is applicable for 0.23.2 and we should tag this for backport?
I'm nervous about backporting because of the RNG changes, but I think we're technically within our rights to if we wanted, because it is a bugfix. |
* Make `BarrierBeforeFinalMeasurements` deterministic The barrier-merging step at the end directly converted its inner (unordered) sets of bits into (ordered) lists, which is an operation dependent on `PYTHONHASHSEED`. This can have an impact on subsequent topological iteration orders, if there are any barriers that are not full-width in the circuit, which can in turn cause later stochastic transpiler passes to have different outputs for fixed random seeds, depending on `PYTHONHASHSEED`. * Add direct test of MergeAdjacentBarriers
Summary
The barrier-merging step at the end directly converted its inner (unordered) sets of bits into (ordered) lists, which is an operation dependent on
PYTHONHASHSEED
. This can have an impact on subsequent topological iteration orders, if there are any barriers that are not full-width in the circuit, which can in turn cause later stochastic transpiler passes to have different outputs for fixed random seeds, depending onPYTHONHASHSEED
.Details and comments
This is what's causing the non-determinism in the test on #9560.