-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add support for numpy.random.Generator #8374
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 functionalitykind/healthFor CI/testing/release process/refactoring/technical debt itemsFor CI/testing/release process/refactoring/technical debt itemstriage/discussNeeds decision / discussion, bring these up during Cirq CynqueNeeds decision / discussion, bring these up during Cirq Cynque
Description
Activity
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 functionalitykind/healthFor CI/testing/release process/refactoring/technical debt itemsFor CI/testing/release process/refactoring/technical debt itemstriage/discussNeeds decision / discussion, bring these up during Cirq CynqueNeeds decision / discussion, bring these up during Cirq Cynque
Is your feature request related to a use case or problem? Please explain
np.RandomStatehas been effectively deprecated by numpy but it is still used throughout much of Cirq. Additionally, when multiple threads are used,RandomStatealso becomes a shared object, causing blocking between threads.Describe the solution you would prefer
We should instead use
numpy.random.Generator, the modern approach. We should provide a separate path for generating random numbers withGeneratorsand ensure multithreading support. The oldRandomStatebased paths may then be deprecated. Per previous work on this issue, the general approach should be:PRNG_OR_SEED_LIKEshould be added, allowing for either a generator or a seed.parse_random_generatorshould be added, which returns anp.random.Generator.parse_random_statewithin cirq should be replaced withparse_random_generator.parse_random_stateshould be deprecated.How urgent is this for you? Is it blocking important work?
P2 – we should do it in the next couple of quarters
Provide additional information or context (e.g., screenshots)
This is an amalgamation of the discussion and conclusions reached within several issues and PRs: #6566, #6531, #6321, #8184
Related: #6567