Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

[BUG] rng runs with each microbatch #592

Open
ZYHowell opened this issue Jul 6, 2022 · 0 comments
Open

[BUG] rng runs with each microbatch #592

ZYHowell opened this issue Jul 6, 2022 · 0 comments
Labels
known bug Something isn't working

Comments

@ZYHowell
Copy link
Collaborator

ZYHowell commented Jul 6, 2022

Each microbatch runs the traced Jaxpr once. However, some parts of the Jaxpr is not related to microbatch. This results in redundant computations and wrong behavior. For example:

def f(x, key):
    random_num = jax.random.uniform(key, (x.shape[-1], 2))
    return x @ random_num

Here the random_num is not related to batch args(x), but each microbatch generates its own random_num. If there are two microbatches x = [x1, x2], the expected result is [x1@rn, x2@rn], but we actually get [x1@rn1, x2@rn2]. We should separate the rng and reuse the result in all microbatches

@ZYHowell ZYHowell added the known bug Something isn't working label Jul 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
known bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant