-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update cirq.RANDOM_STATE_OR_SEED_LIKE to support np.random.Generator #6531
Copy link
Copy link
Open
Labels
good first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.This issue can be resolved by someone who is not familiar with the codebase. A good starting issue.kind/feature-requestDescribes new functionalityDescribes new functionalitytriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on
Metadata
Metadata
Assignees
Labels
good first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.This issue can be resolved by someone who is not familiar with the codebase. A good starting issue.kind/feature-requestDescribes new functionalityDescribes new functionalitytriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on
Type
Projects
Status
No status
Is your feature request related to a use case or problem? Please describe.
We have several modules that spwan multiple threads for performance. each of those threads would be running a random operation using a random state or state. when those threads share the same
RandomStatethe multithreading degenerate into sequential processing since those threads will be waiting on write operation of the random state.Describe the solution you'd like
Start supproting
np.random.Generator. This class provides the same API ofnp.random.RandomStatein addition to aspawnfunction which can be used to create independent streams of random values. This will help when starting threads e.g.Describe alternatives/workarounds you've considered
Before calling multithreads generate multipleseeds using a
np.randomorRandomState. While this seems like what we are doing withnp.random.Generator.spawn; it's actually different in that the radom seeds and hence the random sequences created will correlate. This means that when running the same operation (e.g. simulation) multiple times in parallel, the results will correlate.Additional context (e.g. screenshots)
The cirq random number support is implemented in cirq-core/cirq/value/random_state.py
What is the urgency from your perspective for this issue? Is it blocking important work?
P2 - we should do it in the next couple of quarters