-
Notifications
You must be signed in to change notification settings - Fork 5k
Probe the device module for train_cifar's fork_rng device entries #8407
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,7 +128,11 @@ def train_cifar(model, config, num_steps=400, average_dp_losses=True, fp16=True, | |
| fork_kwargs = {"device_type": get_accelerator().device_name()} | ||
| else: | ||
| fork_kwargs = {} | ||
| with get_accelerator().random().fork_rng(devices=[get_accelerator().current_device_name()], **fork_kwargs): | ||
| # fork_rng only needs entries for backends with per-device generators: the global | ||
| # CPU RNG is always saved, and torch.cpu has no get_rng_state to call anyway. | ||
| device_mod = torch.get_device_module(get_accelerator().device_name()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When these tests run with the supported minimum PyTorch 2.0 ( Useful? React with 👍 / 👎. |
||
| fork_devices = [get_accelerator().current_device_name()] if hasattr(device_mod, 'get_rng_state') else [] | ||
| with get_accelerator().random().fork_rng(devices=fork_devices, **fork_kwargs): | ||
| ds_utils.set_random_seed(seed) | ||
|
|
||
| # disable dropout | ||
|
|
||
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.
This is a non-merge commit, but its message has no
Signed-off-bytrailer. Recreate the commit with--signoffso it satisfies the repository's commit requirements.AGENTS.md reference: AGENTS.md:L8-L8
Useful? React with 👍 / 👎.