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

Maintain Consistent rng_key Valuing #317

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

AFg6K7h4fhy2
Copy link
Collaborator

This PR takes instances matching this pattern:

np.random.seed(223)
with numpyro.handlers.seed(rng_seed=np.random.randint(1, 60)):
    model.sample()

and updates them to this pattern:

with numpyro.handlers.seed(rng_seed=223):
    model.sample()

Oftentimes, in the same file or tutorial, the same rng_seed value will be used (e.g., 223 in the above example) across instances of numpyro.handlers.seed(). This PR maintains this consistency at the file level, so if all np.random.seed()s had value 62 in a file, then all rng_seed values in that file are also valued at 62.

@AFg6K7h4fhy2 AFg6K7h4fhy2 added the clean up Good code that could be better label Jul 25, 2024
@AFg6K7h4fhy2 AFg6K7h4fhy2 added this to the 🦆 Olorotitan milestone Jul 25, 2024
@AFg6K7h4fhy2 AFg6K7h4fhy2 self-assigned this Jul 25, 2024
@AFg6K7h4fhy2 AFg6K7h4fhy2 linked an issue Jul 25, 2024 that may be closed by this pull request
@AFg6K7h4fhy2 AFg6K7h4fhy2 changed the title random key cleaning Maintain Consistent rng_key Valuing Jul 25, 2024
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.80%. Comparing base (4ea2e4b) to head (2816b27).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #317   +/-   ##
=======================================
  Coverage   92.80%   92.80%           
=======================================
  Files          39       39           
  Lines         904      904           
=======================================
  Hits          839      839           
  Misses         65       65           
Flag Coverage Δ
unittests 92.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@dylanhmorris dylanhmorris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AFg6K7h4fhy2!

@dylanhmorris dylanhmorris merged commit fdd53c0 into main Jul 25, 2024
8 checks passed
@dylanhmorris dylanhmorris deleted the 310-simplify-all-uses-of-random-rng-keys branch July 25, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean up Good code that could be better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify all uses of random rng keys
2 participants