-
Notifications
You must be signed in to change notification settings - Fork 309
Low-bit optim support for DTensor [to be closed] #490
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/490
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit 598569a with merge base 12ac498 ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Hey @guangy10, where do I need to add the
|
# but you will get the following error | ||
# AssertionError: s8 (could be from ["L['grad']._base._local_tensor.size()[0]"]) not in {s3: ["L['exp_avg']._local_tensor.scale.size()[0]", "L['exp_avg']._local_tensor.scale.size()[0]", "L['exp_avg']._local_tensor.scale.size()[0]", "L['exp_avg']._local_tensor.scale.size()[0]", "L['exp_avg']._local_tensor.scale.size()[0]"], s4: ["L['exp_avg']._local_tensor.qmap.size()[0]", "L['exp_avg']._local_tensor.qmap.size()[0]", "L['exp_avg']._local_tensor.qmap.size()[0]", "L['exp_avg']._local_tensor.qmap.size()[0]", "L['exp_avg']._local_tensor.qmap.size()[0]", "L['exp_avg_sq']._local_tensor.qmap.size()[0]", "L['exp_avg_sq']._local_tensor.qmap.size()[0]", "L['exp_avg_sq']._local_tensor.qmap.size()[0]", "L['exp_avg_sq']._local_tensor.qmap.size()[0]", "L['exp_avg_sq']._local_tensor.qmap.size()[0]"], s12: ["L['grad']._local_tensor.size()[0]", "L['grad']._local_tensor.size()[0]"], s10: ["L['grad']._local_tensor.storage_offset()", "L['grad']._local_tensor.storage_offset()"], s16: ["L['exp_avg_sq']._local_tensor.scale.size()[0]", "L['exp_avg_sq']._local_tensor.scale.size()[0]", "L['exp_avg_sq']._local_tensor.scale.size()[0]", "L['exp_avg_sq']._local_tensor.scale.size()[0]", "L['exp_avg_sq']._local_tensor.scale.size()[0]"], s23: ["L['p']._local_tensor.size()[0]", "L['p']._local_tensor.size()[0]"]}. If this assert is failing, it could be due to the issue described in https://github.com/pytorch/pytorch/pull/90665 | ||
# p = p.view(-1) | ||
# grad = grad.view(-1) |
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.
@bdhirsh The .view(-1)
is here. The snippet in the PR description is just to show that torch.compile can't generate dynamic kernel for DTensor (from what I understand).
To give more context. The low-bit optim here works fine with normal tensor. To avoid re-compilation when p has different ndim, I call .view(-1)
to flatten it (I observe torch.compile(dynamic=True)
still re-compiles when p has different ndim, thus the .view(-1)
trick).
So if I use the same trick for DTensor, the above error will show up.
The recompilation issue is worse for DTensor, because it seems like torch.compile can't generate dynamic kernel for it (as reported in the PR description as a standalone example).
* Fix runner-et on Mac and Android * Fix typo * Avoid fatal message * Change fatal to warning
I only opened this so it's easy to see the diff. Refer to #484
@awgu @wanchaol @weifengpy
If I don't
.view(-1)
to the DTensor, I will hit cache size limit. A min repro shows that torch.compile cannot generate dynamic kernel for the sharded dimension?If I add
.view(-1)
, torch compile will throw the following errorI'm seeing 2 ways to solve this (with optim state being DTensor)
.view(-1)
)cc @msaroufim @janeyx99