Skip to content

Commit

Permalink
[ddp] in-place AllReduce of Grad Buckets (PR#2333) (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
crcrpar authored Mar 27, 2024
1 parent 716fffd commit 94c9494
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion thunder/distributed/bucketing.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _maybe_allreduce(self, bucket: Bucket, group: ProcessGroup) -> None:
dist_prims.DistributedReduceOps.SUM,
group=group,
do_async=True,
skip_clone=False,
skip_clone=True,
)

def tell(self, grad: TensorProxy, group: ProcessGroup) -> None:
Expand Down
4 changes: 3 additions & 1 deletion thunder/executors/torchex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,9 @@ def _unpack_prim_impl(
tensors: list[torch.Tensor],
bucket_key: str,
) -> list[torch.Tensor]:
return torch._utils._unflatten_dense_tensors(buffer, tensors)
_, views = _key_to_bucket_and_views[bucket_key]
torch._foreach_copy_(tensors, views, non_blocking=True)
return tensors

# TODO(crcrpar): Make this compatible with the torch.compile executor as it's doing really well for cat and reshape.
# NOTE(crcrpar): why no caching/resue of buffer?
Expand Down

0 comments on commit 94c9494

Please sign in to comment.