Sorts gate array to have deterministic gate selection#16139
Sorts gate array to have deterministic gate selection#16139amruthpremjith wants to merge 3 commits intoQiskit:mainfrom
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 following people are relevant to this code:
|
|
Thanks! That was fast. Do you think there is any meaningful test we could add? Could you also add a (short) bugfix release note? |
|
Sure, maybe we can add a test case that runs it twice and compares the gate count? |
|
The randomisation of |
| gates_1q = sorted(set(_BASIS_1Q.keys()) - {"v", "w", "id", "iden", "sinv"}) | ||
| gates_2q = sorted(_BASIS_2Q.keys()) |
There was a problem hiding this comment.
sorted is perhaps a bit unnecessarily heavy as a normalisation step; dict is already consistently ordered (including the dict_keys iterator), so the sort of gates_2q isn't needed, and the top line can be something along the lines of
ignore_1q = {"v", "w", "id", "iden", "sinv"}
gates_1q = [gate for gate in _BASIS_1Q if gate not in ignore_1q]and avoid the extra
There was a problem hiding this comment.
I updated it to the snippet you mentioned, I was thinking it was straightforward to just sort it it to be consistent across any changes in the source dictionary as well.
|
Lol, Jake beat me at replying :) |
Coverage Report for CI Build 25374288175Coverage decreased (-0.01%) to 87.587%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions20 previously-covered lines in 4 files lost coverage.
Coverage Stats
💛 - Coveralls |
|
I added a test case that passes in different seeds to a subprocess, without the change the test case failed and it was passing with it. |
AI/LLM disclosure
Fix #16138
Sort the gate array before selecting from it to return the same gates for the same set of inputs.
Tested with and without changes.
Without change
With change