Skip to content

Commit

Permalink
[FSDP2] Follow-up fix to correct relaxed overlap test (pytorch#132953)
Browse files Browse the repository at this point in the history
The previous PR forgot to include dummy all-gathers before backward, so the reference time was too short, causing the test to still fail.

I verified the test passes locally.

This should close pytorch#120961 (again).

Pull Request resolved: pytorch#132953
Approved by: https://github.com/weifengpy
ghstack dependencies: pytorch#132869
  • Loading branch information
awgu authored and pytorchmergebot committed Aug 8, 2024
1 parent 636a7c4 commit ac6398b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/distributed/_composable/fsdp/test_fully_shard_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ def ref_fwd_bwd():
]
dist.all_gather_into_tensor(dummy_ag_output, dummy_ag_input)
loss = ref_model(inp).sum()
# Run dummy all-gathers per weight again since we are
# resharding after forward
for lin in ref_model:
dummy_ag_output = torch.empty_like(lin.weight)
dummy_ag_input = torch.chunk(dummy_ag_output, self.world_size)[
self.rank
]
dist.all_gather_into_tensor(dummy_ag_output, dummy_ag_input)
loss.backward()
# Run dummy reduce-scatters per weight
for lin in ref_model:
Expand Down

0 comments on commit ac6398b

Please sign in to comment.