-
Notifications
You must be signed in to change notification settings - Fork 24.9k
[DTensor] add op support: aten.squeeze_.dim #159532
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
base: gh/XilunWu/161/base
Are you sure you want to change the base?
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159532
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 4 New Failures, 1 Unrelated FailureAs of commit 0477c8f with merge base ddbdcdc ( NEW FAILURES - The following jobs have failed:
UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
output_spec = output_sharding.output_spec | ||
assert isinstance(output_spec, DTensorSpec) | ||
assert isinstance(args[0], DTensor) | ||
args[0]._spec = output_spec |
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.
@tianyu-l pointed out that, besides DTensor._spec.tensor_meta
, the subclass' metadata also needs override (but it seems not doable...)
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.
Edward suggests try return_and_correct_aliasing
to fix the outer tensor meta, will try.
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.
x = torch.randn((1, 4), device=self.device_type) | ||
dist_x = DTensor.from_local(x, mesh_2d, [Partial(), Shard(1)]) | ||
self._test_op_on_dtensor( | ||
torch.ops.aten.squeeze_.dim, |
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.
Should we also check if dist_x is changed or not?
**Summary** This PR enables in-place op `aten.squeeze_.dim` on DTensor with a change to DTensor dispatch logic: when processing in-place operator, we should assign `output_sharding.output_spec` back to the first argument. This is because the in-place op_call on `arg._local_tensor` could also shift the tensor meta. **Test** `pytest test/distributed/tensor/test_view_ops.py -s -k test_squeeze_` cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta tianyu-l [ghstack-poisoned]
need to debug why "distributed/tensor/test_math_ops.py::DistMathOpsTest::test_rms_norm_bwd" is broken by this change |
@XilunWu this is the table dump of the forward pass. as you said yeah it is missing a collective and all the values are off :/ Maybe something with how rsqrt uses squeeze_dim? not sure rn I can investigate further if needed Interesting part of the dump (note the partial vs replicate of rsqrt)
this PR
Full dump of forward pass
this PR
|
Stack from ghstack (oldest at bottom):
Summary
This PR enables in-place op
aten.squeeze_.dim
on DTensor with a change toDTensor dispatch logic: when processing in-place operator, we should assign
output_sharding.output_spec
back to the first argument. This is becausethe in-place op_call on
arg._local_tensor
could also shift the tensor meta.Test
pytest test/distributed/tensor/test_view_ops.py -s -k test_squeeze_
cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta @tianyu-l