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

Refactor simulator RNG handling #6944

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

justinpan0
Copy link
Contributor

Support both numpy RandomState and Generator for RNG handling in simulators #6567

@justinpan0 justinpan0 force-pushed the random-number-generator-arg branch from 2c4434c to c700603 Compare January 17, 2025 07:10
@justinpan0
Copy link
Contributor Author

Updating the random number generation methods across various files in the cirq-core package to use the newer np.random.Generator instead of the older np.random.RandomState.

One small hack:

  1. For random_state.py, directly assigning RandomState._bit_generator could not yield the same result as Generator, even though the RandomState object is created with the same seed; instead I tried to get the RandomState's seed by the following line, and construct from there:
np.random.default_rng(random_state.get_state()[1][0])

Updates to random number generation:

@CirqBot CirqBot added the size: M 50< lines changed <250 label Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants