Skip to content

Support of dtensor redistribute with device order #160266

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

Open
wants to merge 3 commits into
base: gh/zpcore/12/base
Choose a base branch
from

Conversation

zpcore
Copy link
Member

@zpcore zpcore commented Aug 10, 2025

[Prototype; for RFC, not ready for review]

Now redistribute dtensor honors the device ordering. If no order information specified, it will use the default device order [0,1,2,...]. We can specify device_order as follow:

sharded_dt = distribute_tensor(input_data, mesh, placement, device_order)

and

out_dt = sharded_dt.redistribute(mesh, placement, device_order)

Note that device order information is added into the DTensorSpec. So redistribute_local_tensor doesn't need the src_device_order and dst_device_order. I leave them here as a reference for AutoParallel (cc @fmassa ). I will remove those order related args from redistributed related API in this PR.

Stack from ghstack (oldest at bottom):

cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta

Copy link

pytorch-bot bot commented Aug 10, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/160266

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 1 Unrelated Failure

As of commit 12fe67c with merge base 24257f5 (image):

NEW FAILURES - The following jobs have 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.

zpcore added a commit that referenced this pull request Aug 10, 2025
ghstack-source-id: c5dd358
Pull Request resolved: #160266
@pytorch-bot pytorch-bot bot added ciflow/inductor oncall: distributed Add this issue/PR to distributed oncall triage queue labels Aug 10, 2025
):
mesh_dim_size = device_mesh.size(mesh_dim=mesh_dim)
current_placement = sorted_dst_placement[mesh_dim]
assert isinstance(current_placement, Shard)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be doing something wrong when trying this out, but I'm hitting this assertion, where current_placement is Replicate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have instructions on how to reproduce the issue? I tried python examples/example_autoparallel.py and it complained RuntimeError: Function CompiledFunctionBackward returned an invalid gradient at index 0 - got [1, 6144] but expected shape compatible with [24, 6144].

[Prototype; for RFC, not ready for review]

Now redistribute dtensor honors the device ordering. If no order information specified, it will use the default device order [0,1,2,...]. We can specify `device_order` as follow:
```
sharded_dt = distribute_tensor(input_data, mesh, placement, device_order)
```
and
```
out_dt = sharded_dt.redistribute(mesh, placement, device_order)
```

Note that device order information is added into the DTensorSpec. So `redistribute_local_tensor` doesn't need the `src_device_order` and `dst_device_order`. I leave them here as a reference for AutoParallel (cc fmassa ). I will remove those order related args from redistributed related API in this PR.





cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta

[ghstack-poisoned]
zpcore added a commit that referenced this pull request Aug 10, 2025
ghstack-source-id: 0e27cda
Pull Request resolved: #160266
[Prototype; for RFC, not ready for review]

Now redistribute dtensor honors the device ordering. If no order information specified, it will use the default device order [0,1,2,...]. We can specify `device_order` as follow:
```
sharded_dt = distribute_tensor(input_data, mesh, placement, device_order)
```
and
```
out_dt = sharded_dt.redistribute(mesh, placement, device_order)
```

Note that device order information is added into the DTensorSpec. So `redistribute_local_tensor` doesn't need the `src_device_order` and `dst_device_order`. I leave them here as a reference for AutoParallel (cc fmassa ). I will remove those order related args from redistributed related API in this PR.





cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta

[ghstack-poisoned]
zpcore added a commit that referenced this pull request Aug 10, 2025
ghstack-source-id: ad23157
Pull Request resolved: #160266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/inductor oncall: distributed Add this issue/PR to distributed oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants