-
Notifications
You must be signed in to change notification settings - Fork 980
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
[docs] update set-seed #3228
base: main
Are you sure you want to change the base?
[docs] update set-seed #3228
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the docs.
IMO, it would also be fine to remove the code snippet completely (as it's just a matter of time until it gets out of date again) and just explain in words what's happening.
I think code is easier to read and understand. Only using cuda is a bit unfair. Maybe I can update other devices in a comment? |
My main concern is mostly the example and the actual code getting out of sync. It's not a big deal, would just be nice to prevent it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, there is always a fear of what would happen if code gets out of sync, esp as even this code doesn't quite fully align to what we're up to. (e.g. there's now a by_index).
While it's not per-se "fair", I'm not sure if it's more or less readable now than before for our docs. It is a concept guide, so we can show more code. Just wish we could show the source itself.
I think we could get by just saying:
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # or torch.npu.manual_seed_all, etc
# ^^ safe to call this function even if cuda/backend is not available
if is_torch_xla_available():
xm.set_rng_state(seed)
Since we care more about manual_seed_all
than the backend specifically
Thanks for the feedback! Agree. Code looks much cleaner now. @muellerzr @BenjaminBossan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
What does this PR do?
The current
set-seed
in documentation only includes the cuda part, which is out-dated. This PR updates it with the current implementation.@muellerzr