[Bug] TorchDist subgroup broadcast/gather passes group-local root=0/dst=0 as global rank, crashing non-zero subgroups and hanging tp_cp_broadcast
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- backend, distributed-systems
Research direction
Read tensorrt_llm/_torch/distributed/communicator.py, especially TorchDist subgroup gather and broadcast methods and the CUDA object-collective helpers. First trace how callers pass group-local roots, then run a multi-process test with nonzero subgroups; done means gather and broadcast work across the described TP, PP, and CP layouts without rank errors or hangs. The issue links open pull request #23034, so work may already be underway.
Written by the indexing model from the issue text.
Description
Summary
In tensorrt_llm/_torch/distributed/communicator.py (commit 1aa0192e62d219599930f125ada7067081fb44b7, present at HEAD), TorchDist subgroup broadcast and gather collectives pass group-local root=0 / dst=0 directly as PyTorch global ranks and compare torch.distributed.get_rank() == root/dst:
# tensorrt_llm/_torch/distributed/communicator.py:1741-1801, 1839-1884
@log_op
def tp_gather(self, obj, dst=0):
global_rank = torch.distributed.get_rank()
if isinstance(obj, torch.Tensor):
if global_rank == dst:
output_list = [
torch.empty_like(obj)
for _ in range(self.mapping.tp_group_pg.size())
]
else:
output_list = None
dist.gather(obj, output_list, dst=dst, group=self.mapping.tp_group_pg)
return output_list
elif (vote_pg := self._cuda_obj_pg("tp")) is not None:
return self._cuda_gather_object(obj, vote_pg, dst)
else:
...
if global_rank == dst:
output_list = [None] * self.mapping.tp_group_pg.size()
else:
output_list = None
dist.gather_object(obj, output_list, dst=dst, group=self.mapping.tp_group_pg)
return output_list
@log_op
def tp_broadcast(self, obj, root=0, **kwargs):
if isinstance(obj, torch.Tensor):
dist.broadcast(obj, src=root, group=self.mapping.tp_group_pg)
return obj
elif (vote_pg := self._cuda_obj_pg("tp")) is not None:
return self._cuda_broadcast_object(obj, vote_pg, root)
else:
ret = [obj]
torch.distributed.broadcast_object_list(
ret, src=root, group=self.mapping.tp_group_pg, device=torch.device("cpu")
)
return ret[0]
The identical pattern appears in cp_broadcast (1788-1801), pp_gather (1840-1867), pp_broadcast (1870-1883), _cuda_gather_object (1361-1368, is_dst = torch.distributed.get_rank() == dst), and _cuda_broadcast_object (1398-1479, is_root = torch.distributed.get_rank() == root and dist.broadcast(..., src=root, group=pg)).
Unlike MPIDist (914-935), where root=0/dst=0 on tp_comm/pp_comm/cp_comm is group-local rank 0 (and callers such as AutoTuner._broadcast_cache_data at autotuner.py:3179, py_executor.py:282, py_executor.py:8059-8076, and glm_5_3_flash_nvfp4__sm_10x__tp4/modeling.py:402 rely on group-local root=0), PyTorch's dist.broadcast(..., group=pg), dist.broadcast_object_list(..., group=pg), dist.gather(..., group=pg), and dist.gather_object(..., group=pg) require src/dst to be a global rank belonging to pg.
Consequently, under any 2D/3D parallelism where a subgroup excludes global rank 0 (PP > 1, TP > 1; TP > 1, CP > 1; or ADP + PP > 1):
- Every non-zero subgroup (e.g., PP stage >= 1 TP groups
[2, 3], TP rank >= 1 PP groups[1, 3]) immediately crashes withValueError: Global rank 0 is not part of group. - In
Distributed.tp_cp_broadcast(obj, root=0)underPP=1, TP=2, CP=2(tp0=[0, 2], tp1=[1, 3], cp0=[0, 1], cp1=[2, 3]), ranks1and3crash intp_broadcast, rank2succeeds intp_broadcastand crashes incp_broadcast, and rank0succeeds intp_broadcastand hangs insidecp_broadcastwaiting on crashed rank1.
Affected Location
- Repository:
NVIDIA/TensorRT-LLM(1aa0192e62d219599930f125ada7067081fb44b7, present atHEAD) - File & lines:
tensorrt_llm/_torch/distributed/communicator.py:1361-1368,1398-1479,1742-1883(TorchDist._cuda_gather_object,_cuda_broadcast_object,tp_gather,tp_broadcast,cp_broadcast,pp_gather,pp_broadcast)
Minimal Standalone Reproduction
import datetime, types
import torch.distributed as dist
import torch.multiprocessing as mp
from tensorrt_llm._torch.distributed.communicator import TorchDist
def worker(rank, port):
dist.init_process_group(
"gloo", init_method=f"tcp://127.0.0.1:{port}", rank=rank, world_size=4,
timeout=datetime.timedelta(seconds=3),
)
# Example 1: PP=2, TP=2 -> tp0=[0,1], tp1=[2,3], pp0=[0,2], pp1=[1,3]
tp0, tp1 = dist.new_group([0, 1]), dist.new_group([2, 3])
pp0, pp1 = dist.new_group([0, 2]), dist.new_group([1, 3])
mapping = types.SimpleNamespace(
tp_size=2, cp_size=1, pp_size=2,
tp_group_pg=tp0 if rank in (0, 1) else tp1,
pp_group_pg=pp0 if rank in (0, 2) else pp1,
cp_group_pg=None,
)
td = TorchDist(mapping)
print(rank, td.pp_broadcast(rank in (0, 1), root=0))
print(rank, td.tp_cp_broadcast({"tactic": rank}, root=0))
Observed behavior / output (4-process Gloo execution against verbatim communicator.py):
- Under
PP=2, TP=2:- Ranks
1and3(pp1=[1, 3]) immediately raiseValueError: Global rank 0 is not part of groupinpp_broadcast(..., root=0)andpp_gather(..., dst=0). - Ranks
2and3(tp1=[2, 3]) immediately raiseValueError: Global rank 0 is not part of groupintp_cp_broadcast(..., root=0)andtp_gather(..., dst=0).
- Ranks
- Under
PP=1, TP=2, CP=2:tp_broadcast(..., root=0)crashes on ranks1and3(tp1=[1, 3]);cp_broadcast(..., root=0)crashes on ranks2and3(cp1=[2, 3]).- Calling
td.tp_cp_broadcast({"k": rank}, root=0)crashes ranks1, 2, 3withValueError: Global rank 0 is not part of groupwhile rank0hangs insidecp_broadcast(alive_after_timeout = [True, False, False, False]).
- Note:
_cuda_broadcast_objectand_cuda_gather_objectshare the exact sametorch.distributed.get_rank() == root/dstand rawsrc=root/dst=dstbug on the CUDA object-collective fast path (hardware-gated for live CUDA/NCCL execution).
Suggested Fix
- Resolve group-local
root/dstto the corresponding global rank viaglobal_root = dist.get_global_rank(pg, root)(andglobal_dst = dist.get_global_rank(pg, dst)) before passingsrc/dsttodist.broadcast,dist.broadcast_object_list,dist.gather,dist.gather_object,_cuda_broadcast_object, and_cuda_gather_object. - In
tp_gather,pp_gather,_cuda_gather_object, and_cuda_broadcast_object, check group membership via group-local rank (dist.get_rank(pg) == local_rootortorch.distributed.get_rank() == global_root) rather than comparing global rank directly against0. - Add a multi-GPU unit test covering
PP=2, TP=2andPP=1, TP=2, CP=2(extendingtest_ops.py, which currently only testsPP=1, TP=1, CP=2).
- Dominant language
- Python
- Stars
- 15.2k
- Forks
- 3k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 477
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/TensorRT-LLM
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xPossibly taken @NimaVaziri claimed this today. OpenPytorch
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/TensorRT-LLM#23406 ·
Maintainers usually reply within 1 day
-
Inference runtime Windows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
NVIDIA/TensorRT-LLM#23394 ·
Maintainers usually reply within 1 day
-
[Bug]: MMLU subsampling changes when evaluators are interleavedPossibly taken @LeNeLeNeWo claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NVIDIA/TensorRT-LLM#23273 ·
Maintainers usually reply within 1 day
-
Trace-replay Pareto window includes the drain when sessions finish out of admission orderPossibly taken @sbeierle claimed this 3 days ago. OpenTesting
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NVIDIA/TensorRT-LLM#23077 ·
Maintainers usually reply within 1 day
-
LongBench V2 blog command breaks on inline comments after continuationsPossibly taken @ddlw claimed this 25 days ago. OpenDoc
Difficulty 1/5 Under an hour Newbie friendliness 91/100
NVIDIA/TensorRT-LLM#21879 ·
Maintainers usually reply within 1 day
All issues in NVIDIA/TensorRT-LLM
Similar issues
-
[Resource]: SpaicelyOpenresource-submission validation-passed
Difficulty 1/5 Under an hour Newbie friendliness 68/100
hesreallyhim/awesome-claude-code#3875 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
bvis/aegis-hass#725 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sOpen
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
Maintainers usually reply within 1 day