Skip to content
Merged
Show file tree
Hide file tree
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: 5 additions & 1 deletion tensorrt_llm/_torch/custom_ops/torch_custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,11 @@ def forward(
do_preparation=True)
return input
if tactic == -1:
tactic = AllReduceStrategy.NCCL_SYMMETRIC.value
# tactic == -1 means the autotuner cache missed for this shape,
# so we fall back to plain NCCL instead of NCCL_SYMMETRIC.
# NCCL_SYMMETRIC requires ncclMemAlloc which can fail asymmetrically
# across ranks under OOM, causing a deadlock at ncclCommWindowRegister.
tactic = AllReduceStrategy.NCCL.value
Comment thread
Tabrizian marked this conversation as resolved.

return torch.ops.trtllm.allreduce(
input,
Expand Down
6 changes: 4 additions & 2 deletions tensorrt_llm/_torch/models/modeling_deepseekv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def weight_dequant(x: torch.Tensor,
@torch.compile(dynamic=True)
def moe_reduce_add_shared_output(routed_output, shared_output):
routed_output = torch.sum(routed_output, dim=1, keepdim=False)
return shared_output + routed_output
# In-place add to avoid allocating a temporary tensor, reducing peak memory
return shared_output.add_(routed_output)


class DeepseekV3WeightLoader:
Expand Down Expand Up @@ -1157,7 +1158,8 @@ def _compute_routed_output():
else:
assert shared_output.size() == routed_output.size(
), 'unmatched tensor shape'
final_hidden_states = shared_output + routed_output
# In-place add to avoid allocating a temporary tensor, reducing peak memory
final_hidden_states = shared_output.add_(routed_output)

if not self.use_dp and self.mapping.tp_size > 1:
final_hidden_states = self.allreduce(
Expand Down
Loading