vae example: provide an additional --xla flag to be able to run this test on TPU if available#1416
Open
fedebongio wants to merge 2 commits intopytorch:mainfrom
Open
vae example: provide an additional --xla flag to be able to run this test on TPU if available#1416fedebongio wants to merge 2 commits intopytorch:mainfrom
fedebongio wants to merge 2 commits intopytorch:mainfrom
Conversation
- Add optional --xla flag to enable XLA device (e.g. TPU) via torch_xla - Graceful ImportError guard so torch_xla is not required for CPU/GPU runs - XLA-specific DataLoader kwargs (persistent_workers, drop_last) - Call torch_xla.sync() after optimizer.step() each batch - Update README with --xla usage and torch_xla install instructions https://claude.ai/code/session_019ipwBaRzzfeEGFDdAdoeWJ
Calling .item() every batch forces a device sync which stalls XLA/TPU. Accumulate loss as a tensor and only call .item() at epoch end. https://claude.ai/code/session_019ipwBaRzzfeEGFDdAdoeWJ
✅ Deploy Preview for pytorch-examples-preview canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm a Kubernetes/Kubernetes contributor, and this is my second PR to Pytorch.
Thanks!
Federico