google / google/torchax

How do RNGs work in torchax

Open
#17 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
243
Forks
38
Avg merge
15h 32m
Merged PRs (30d)
2

Description

I’ve read the code, and it seems that we just let PyTorch manage the RNGs (I’ve tested it, and it works on eager mode), but I have a question.

I’m not entirely sure how this works, but in JAX we sometimes provide RNG keys (e.g., jax.random.key) as arguments to the loss function. Since these keys are JAX arrays, they’re tracer objects. When we generate random numbers (random boolean, for dropout mask)based on these keys, the results also become tracer objects, which are then captured in the computation graph. Shouldn’t there be an equivalent mechanism for this in the torchax?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.