Skip to content
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

Bugfix matrixmod2 determinism #268

Merged
merged 2 commits into from
Nov 7, 2022
Merged

Conversation

enielse
Copy link
Collaborator

@enielse enielse commented Nov 7, 2022

Adds the ability to seed Clifford compilations used in RB so deterministic behavior results

Plumbs a RandomState object through functions in compilers.py and matrixmod2.py so that the randomness used therein can be seeded properly. This PR also removes a duplicate done_editing call in randomcircuit.py that I stumbled upon as I was making the main updates.

I think (& hope) that this PR may fix a long-standing issue of the pyGSTi unit tests occasionally failing because of an RB circuit mismatch. This erroring could be "fixed" by simply rerunning the unit tests again, which was suspicious and unnerving.

These functions previously just called _np.random(...) and so their
pseudo-randomness could not be nicely seeded and easily made deterministic.
This commit fixes this issue, adding `rand_state` arguments to several
matrixmod2.py functions and updating the use of these function within
matrixmod2.py and compilers.py (this is the only other modules where these
functions are used within pyGSTi).  All added `rand_state` arguments can be
set to a `numpy.random.RandomState` object or left as None (the default), in
which case a new random state is created.
@coreyostrove
Copy link
Contributor

Took a look through the changes and this all looks good to me, fwiw.

Copy link
Contributor

@sserita sserita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me too.

@sserita sserita merged commit 6fbb5d5 into develop Nov 7, 2022
@sserita sserita deleted the bugfix-matrixmod2-determinism branch November 7, 2022 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants