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

How are random seeds set for RNG operations? #13300

Open
Ebanflo42 opened this issue Jun 1, 2024 · 3 comments
Open

How are random seeds set for RNG operations? #13300

Ebanflo42 opened this issue Jun 1, 2024 · 3 comments

Comments

@Ebanflo42
Copy link

I noticed that the only XlaOp which seems to take a random state is XlaOp RngBitGenerator(RandomAlgorithm algorithm, XlaOp initial_state, const Shape& shape);, but for the other ops like RngUniform and RngNormal it is not clear to me where the seed could be set. I thought it would be initialized either in the builder or when the pjrt executable is invoked but, at least based on my search through the code, there doesn't seem to be a method for that? What is the expected way for a higher-level API to manually set an RNG seed?

@cheshire
Copy link
Contributor

cheshire commented Jun 3, 2024

In my understanding ops like RngUniform are deprecated and are not used by JAX, and the ops which require explicit passing and generation of random seeds are the ones used.

@cheshire
Copy link
Contributor

cheshire commented Jun 3, 2024

@hawkinsp for more details [should we also call it out in the docs?]

@Ebanflo42
Copy link
Author

Thanks for the info! I'm looking at the headers in the xla_extension and the only op which takes a seed looks like RngBitGenerator, but I still cannot find where the RandomAlgorithm class/enum/typedef is declared. I guess this argument is determining which kind of distribution is to be sampled, But not knowing how to instantiate the argument makes it difficult to understand how this op interacts with the rest of the computation.

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

No branches or pull requests

2 participants