[Bug] TorchDist.allreduce / tp_allreduce convert Python int vs float scalars to int64 vs float32 on CPU fallback, crashing or hanging on mixed scalar types
メンテナーはふだん 1 日以内に返信
@DaDerekkk がすでに取り組んでいます。
2026年12月3日 から。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
Read tensorrt_llm/_torch/distributed/communicator.py around TorchDist.allreduce and TorchDist.tp_allreduce, then check how _cuda_allreduce_scalar handles scalar dtypes. Reproduce the mixed int and float case with the two-rank Gloo example in the issue. Done means both methods handle mixed scalar types without rank failures; add the two-rank Gloo tests described in the issue.
索引モデルが issue の本文から書いたものです。
説明
Summary
In tensorrt_llm/_torch/distributed/communicator.py (commit 1aa0192e62d219599930f125ada7067081fb44b7, present at HEAD), TorchDist.allreduce and TorchDist.tp_allreduce support obj: int | float | torch.Tensor:
# tensorrt_llm/_torch/distributed/communicator.py:1657-1696
@log_op
def allreduce(
self,
obj: int | float | torch.Tensor,
op: ReduceOp = ReduceOp.SUM,
):
is_base_type = isinstance(obj, int) or isinstance(obj, float)
if is_base_type:
vote_pg = self._cuda_obj_pg("world")
if op in self._CUDA_SCALAR_REDUCE_OPS and vote_pg is not None:
return self._cuda_allreduce_scalar(obj, op, vote_pg)
obj = torch.tensor(obj)
dist.all_reduce(obj, op=reduce_op_to_torch(op))
if is_base_type:
obj = obj.item()
return obj
While _cuda_allreduce_scalar explicitly promotes scalars to dtype=torch.float64 (line 1650), the CPU/Gloo fallback path (vote_pg is None or op not in _CUDA_SCALAR_REDUCE_OPS) calls obj = torch.tensor(obj) without specifying a unified dtype.
In PyTorch:
torch.tensor(int)producestorch.int64(8 bytes)torch.tensor(float)producestorch.float32(4 bytes)
If one rank passes an int and another passes a float (for example in KV-cache sizing or step counters where one rank holds a literal/config int and another holds a computed float), dist.all_reduce(obj, ...) executes with mismatched tensor dtypes and element byte sizes across ranks. On Gloo, this triggers a fatal C++ gloo::EnforceNotMet (op.nread == op.preamble.nbytes) SIGABRT on the sender/receiver and Timed out waiting ... for recv operation to complete on peer ranks.
Affected Location
- Repository:
NVIDIA/TensorRT-LLM(1aa0192e62d219599930f125ada7067081fb44b7, present atHEAD) - File & lines:
tensorrt_llm/_torch/distributed/communicator.py:1657-1696(TorchDist.allreduce,TorchDist.tp_allreduce)
Minimal Standalone Reproduction
import datetime, os, socket
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from tensorrt_llm._torch.distributed.communicator import TorchDist
def free_port():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("127.0.0.1", 0))
return s.getsockname()[1]
def worker(rank, port):
dist.init_process_group(
"gloo", init_method=f"tcp://127.0.0.1:{port}", rank=rank, world_size=2,
timeout=datetime.timedelta(seconds=3),
)
td = TorchDist.__new__(TorchDist)
td.mapping = None
td._cuda_obj_pg = lambda dim: None
val = 1024 if rank == 0 else 512.0 # int (int64, 8B) vs float (float32, 4B)
print(rank, td.allreduce(val, op=dist.ReduceOp.MIN))
dist.destroy_process_group()
if __name__ == "__main__":
port = free_port()
mp.spawn(worker, args=(port,), nprocs=2, join=True)
Observed behavior (2-process Gloo execution against allreduce):
- Rank 0 aborts with
SIGABRT(exitcode=-6):gloo::EnforceNotMet: [enforce fail at .../gloo/transport/uv/pair.cc:253] op.nread == op.preamble.nbytes. - Rank 1 raises
RuntimeError: ... Timed out waiting 3000ms for recv operation to complete.
Suggested Fix
- In both
TorchDist.allreduceandTorchDist.tp_allreduce, normalize scalar inputs to a common floating-point dtype beforedist.all_reduce, matching_cuda_allreduce_scalar:
(Or preserveif is_base_type: ... obj = torch.tensor(obj, dtype=torch.float64)intonly if all callers are guaranteed integer-only, or convert viafloat(obj)/dtype=torch.float64consistently with line 1650.) - Add a 2-rank Gloo unit test exercising
allreduceandtp_allreducewhen rank 0 passesintand rank 1 passesfloat.
- 主要言語
- Python
- スター
- 15.2k
- フォーク
- 3k
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 477
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/TensorRT-LLM のほかの issue
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.x対応中かも @NimaVaziri が今日担当しました。 オープンPytorch
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/TensorRT-LLM#23406 ·
メンテナーはふだん 1 日以内に返信
-
Inference runtime Windows
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
NVIDIA/TensorRT-LLM#23394 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: MMLU subsampling changes when evaluators are interleaved対応中かも @LeNeLeNeWo が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NVIDIA/TensorRT-LLM#23273 ·
メンテナーはふだん 1 日以内に返信
-
Trace-replay Pareto window includes the drain when sessions finish out of admission order対応中かも @sbeierle が 3 日前に担当しました。 オープンTesting
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
NVIDIA/TensorRT-LLM#23077 ·
メンテナーはふだん 1 日以内に返信
-
LongBench V2 blog command breaks on inline comments after continuations対応中かも @ddlw が 25 日前に担当しました。 オープンDoc
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
NVIDIA/TensorRT-LLM#21879 ·
メンテナーはふだん 1 日以内に返信
NVIDIA/TensorRT-LLM の issue をすべて見る
似ている issue
-
[Resource]: Spaicelyオープンresource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
hesreallyhim/awesome-claude-code#3875 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
bvis/aegis-hass#725 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
メンテナーはふだん 1 日以内に返信