-
Notifications
You must be signed in to change notification settings - Fork 22k
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
[dtensor][3/n] use dedicated TensorMeta instead of the fx one #108261
Conversation
This PR switches the usage of fx's shape prop TensorMetadata to dtensor's own dedicated defined TensorMeta, this is because DTensor only cares three fields: shape/stride/dtype, all other fields are not necessary and can be inferred from local_tensor directly. This would help significantly simplify how we deal with the tensor metadata by not caring other fields. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/108261
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 5f02515 with merge base 6dc56d3 (): UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…one" This PR switches the usage of fx's shape prop TensorMetadata to dtensor's own dedicated defined TensorMeta, this is because DTensor only cares three fields: shape/stride/dtype, all other fields are not necessary and can be inferred from local_tensor directly. This would help significantly simplify how we deal with the tensor metadata by not caring other fields. [ghstack-poisoned]
@@ -367,14 +366,23 @@ def __str__(self) -> str: | |||
return "P" | |||
|
|||
|
|||
class TensorMeta(NamedTuple): |
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.
Not a strong opinion here, maybe call it DTensorMeta
? WDYT?
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.
I think for this dataclass is intended to record "tensor" metadata like shape/stride/dtype, these fields are not quite related to DTensor
, if we rename it to "DTensorMeta" I think we would expect this to include "device_mesh" and "placements", which is already recorded in the DTensorSpec, this might lead to some confusion. I'll also think more about the naming and see whether we need to consolidate it with DTensorSpec a bit
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.
Other than the naming, the rest looks good to me.
…one" This PR switches the usage of fx's shape prop TensorMetadata to dtensor's own dedicated defined TensorMeta, this is because DTensor only cares three fields: shape/stride/dtype, all other fields are not necessary and can be inferred from local_tensor directly. This would help significantly simplify how we deal with the tensor metadata by not caring other fields. [ghstack-poisoned]
We were using make_fx for strategy based propagation so that we can get a graph and the shape related metadata, this becomes too much overkill for the sharding propagation purpose. This change refactors the strategy propagation to remove the graph based propagation, instead just use the op to index to the strategy functions. We also just use a fake shape prop instead of relying on fx tracing for the shape/stride propagation. for a future possible decomposed propagation, we will exercise different codepath to enable that NOTE that this would also greatly reduce the latency of: 1. first time dtensor operations when populating the cache, the first iter would become faster again! 2. greatly reduce the test_dtensor_ops.py time again, right now the whole test finished within 2-3 mins again. Pull Request resolved: #108262 Approved by: https://github.com/fduwjj ghstack dependencies: #107306, #108261
Stack from ghstack (oldest at bottom):
This PR switches the usage of fx's shape prop TensorMetadata to
dtensor's own dedicated defined TensorMeta, this is because DTensor
only cares three fields: shape/stride/dtype, all other fields are not
necessary and can be inferred from local_tensor directly. This would
help significantly simplify how we deal with the tensor metadata by not
caring other fields.