Skip to content
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

Change condition for ub tp overlap. #1055

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions transformer_engine/pytorch/module/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def forward(
assert_dim_for_fp8_exec(weight)

tp_world_size = get_distributed_world_size(tp_group)
ub_overlap_rs = False if tp_world_size == 1 else ub_overlap_rs
ub_overlap_rs = False if tp_world_size == 1 or parallel_mode != "row" else ub_overlap_rs

# Cast input to expected dtype
inputmat = cast_if_needed(inputmat, activation_dtype)
Expand Down Expand Up @@ -405,7 +405,9 @@ def backward(ctx, grad_output: torch.Tensor) -> Tuple[Union[torch.Tensor, None],
weight.main_grad = main_grad

tp_world_size = get_distributed_world_size(ctx.tp_group)
ctx.ub_overlap_ag = False if tp_world_size == 1 else ctx.ub_overlap_ag
ctx.ub_overlap_ag = (
False if tp_world_size == 1 or ctx.parallel_mode != "row" else ctx.ub_overlap_ag
)
if ctx.ub_overlap_ag:
dim_size = list(grad_output.size())
dim_size[0] = dim_size[0] * tp_world_size
Expand Down