-
Notifications
You must be signed in to change notification settings - Fork 25.7k
add test cases for GradScaler on CPU #109994
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
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/109994
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit c2b2fec with merge base a43c283 ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
| with self.assertWarns(FutureWarning): | ||
| scaler.step(o1) | ||
| scaler.step(o2) | ||
| scaler.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.
You should seriously just consider making a dedicated test file for this though
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.
Do you mean making a dedicated test file like test_grad_scaler.py for all GradScaler related tests above ? It's okay for me. I will move such tests to a new file test_grad_scaler.py.
| @skipIfTorchDynamo("Failed running call_function for sparse_coo_tensor. See https://github.com/pytorch/pytorch/issues/118856") | ||
| @onlyNativeDeviceTypes | ||
| @dtypes(torch.float) | ||
| def test_grad_scaling_unscale_sparse(self, device, dtype): |
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.
Any code changes besides changing device? (A diff perhaps?)
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.
No, only the device change.
The simple code would also fail (will also fail on CUDA with device="cuda"):
torch._dynamo.exc.TorchRuntimeError: Failed running call_function <built-in method sparse_coo_tensor of type object at 0x7f105afdb9a0>(*(FakeTensor(..., size=(2, 3), dtype=torch.int64), FakeTensor(..., size=(3,)), (2, 3)), **{'device': 'cpu', 'dtype': torch.float32}): The tensor has a non-zero number of elements, but its data is not allocated yet. Caffe2 uses a lazy allocation, so you will need to call mutable_data() or raw_mutable_data() to actually allocate memory.
@onlyNativeDeviceTypes
@dtypes(torch.float)
def test_grad_scaling_unscale_sparse(self, device, dtype):
i = torch.tensor([[0, 1, 1],
[2, 0, 2]], device="cpu", dtype=torch.int64)
v = torch.tensor([16., 32., 64.], device="cpu", dtype=torch.float)
s = torch.sparse_coo_tensor(i, v, torch.Size([2, 3]), device="cpu", dtype=torch.float)
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Pull Request resolved: #109994 Approved by: https://github.com/jgong5, https://github.com/ezyang
Stack from ghstack (oldest at bottom):