Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 88e3466

Browse filesBrowse files
mvpatel2000pytorchmergebot
authored andcommitted
Patch all_gather to support HSDP + TP (#118638)
Update all_gather to support HSDP + TP. Currently, the `_all_gather_dtensor` function for dtensors only replaces the first dimension with replicate (the FSDP dimension) and does not touch the second dimension (which is assumed to be the TP dimension). With HSDP, we have two dimensions ahead of the TP dimension as opposed to 1. This PR updates to replace all other dimensions with replicate to run the all-gather. Pull Request resolved: #118638 Approved by: https://github.com/fegin, https://github.com/awgu, https://github.com/wz337
1 parent f481835 commit 88e3466
Copy full SHA for 88e3466

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Filter options
  • torch/distributed/tensor/parallel
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed

‎torch/distributed/tensor/parallel/fsdp.py

Copy file name to clipboardExpand all lines: torch/distributed/tensor/parallel/fsdp.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ def _all_gather_dtensor(
304304

305305
placements = list(copy.deepcopy(tensor.placements))
306306
# FSDP + TP: [Shard(0), tp_placement] -> [Replicate(), tp_placement]
307-
placements[0] = Replicate()
307+
# HSDP + TP: [Replicate(), Shard(0), tp_placement] -> [Replicate(), Replicate(), tp_placement]
308+
for i in range(0, len(placements) - 1):
309+
placements[i] = Replicate()
308310
tensor = tensor.redistribute(
309311
device_mesh=tensor.device_mesh,
310312
placements=placements,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.