Skip to content

Fix FT allreduce bug #1170

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions torchtitan/components/ft.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import ContextManager, Optional, TYPE_CHECKING, Union

import torch
import torch.distributed as dist
import torch.distributed._functional_collectives as funcol
from torch.distributed._composable.fsdp.fully_shard import FSDPModule
from torch.distributed.device_mesh import DeviceMesh
Expand Down Expand Up @@ -59,7 +58,7 @@ def get_dp_info(self, dp_degree: int, dp_rank: int) -> tuple[int, int]:

def set_all_reduce_hook(self, model_parts: list[torch.nn.Module]) -> None:
def all_reduce_hook(output):
dist.all_reduce(output, group=self.replicate_pg, op=ReduceOp.AVG)
self.replicate_pg.allreduce(output, opts=ReduceOp.AVG)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment discussing why we need to use this call instead of the original one? This is less intuitive.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure I will add a comment, this is due to these changes (pytorch/pytorch@35c45a4#diff-61109d1cb2a0bd13fc51d678a82666295289da1ec0a1a694e73d9e8c28f51bdcR2885, so the regular dist.all_reduce() is no longer compatible

Copy link
Member

Choose a reason for hiding this comment

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

@H-Huang can we fix this in the torchft side? We should just be able to ignore the case when there's no return work object iiuc


def apply_set_all_reduce_hook(m):
if isinstance(m, FSDPModule):
Expand Down
Loading