[NPU] reduce_sum_across_dp_group builds the all_reduce tensor on CPU when CUDA is unavailable
メンテナーはふだん 4 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Start in xtuner/v1/datasets/dataloader.py at reduce_sum_across_dp_group(), then inspect its callers through Dataloader.get_state_dict(). Reproduce the two-rank collective on an accelerator-backed process group and verify completion when the tensor uses the mesh device; done means both ranks report the expected reduced value without a CPU-backend error.
索引モデルが issue の本文から書いたものです。
説明
What happens
On a host without CUDA (for example an Ascend NPU host, where torch.cuda.is_available() is False), reduce_sum_across_dp_group() in xtuner/v1/datasets/dataloader.py builds the tensor for the DP all_reduce on CPU:
if torch.cuda.is_available():
device = torch.device(f"cuda:{torch.cuda.current_device()}")
else:
device = torch.device("cpu")
tensor = torch.tensor([local_value], dtype=torch.int64, device=device)
dist.all_reduce(tensor, op=dist.ReduceOp.SUM, group=dp_mesh.get_group())
The process group comes from dp_mesh, i.e. it is an NCCL/HCCL group on the accelerator, so handing it a CPU tensor fails.
Real-machine evidence
Ascend 910B4, torch 2.15.0.dev + torch_npu, 2 processes via torchrun, real HCCL process group, reduce_sum_across_dp_group(DeviceMesh("npu", [0, 1]), 3) with the unmodified file:
[rank0] current npu device=0 mesh.device_type=npu
[rank0] RAISED RuntimeError: No backend type associated with device type cpu
[rank1] current npu device=1 mesh.device_type=npu
[rank1] RAISED RuntimeError: No backend type associated with device type cpu
This is not an exotic path: it is reached from Dataloader.get_state_dict(), which is used when saving/restoring dataloader state, so on Ascend the dataloader state cannot be written at all.
Proposed fix
dp_mesh is guaranteed non-None at that point (the early return above handles None), and it already carries the device type of the collective, so use it instead of assuming CUDA:
device = torch.device(dp_mesh.device_type)
That is device-agnostic (cuda / npu / xpu / cpu) and keeps a CPU mesh working. I have the fix ready and verified on the same 2-rank HCCL setup (RESULT=6 expected=6 on both ranks) - opening a PR right after this.
- 主要言語
- Python
- スター
- 5.2k
- フォーク
- 466
- 平均マージ
- 5日 8時間
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
InternLM/xtuner のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 4 日以内に返信
-
enhancement good first issue
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
InternLM/xtuner#2246 · コメント 3 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
InternLM/xtuner#2134 · リアクション 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
InternLM/xtuner#2118 · コメント 6 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
メンテナーはふだん 4 日以内に返信
InternLM/xtuner の issue をすべて見る
似ている issue
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
future-agi/future-agi#5908 ·
メンテナーはふだん 1 日以内に返信
-
Placeholder export disables HTML image input for picture description対応中かも @cloudiful が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
docling-project/docling-serve#817 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
Techiebutler/freeframe#687 ·
メンテナーはふだん 1 日以内に返信
-
Parse truncated verbose GC logs up to the first XML error対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug verbose GC
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
IBM/javacore-analyser#677 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 2 日以内に返信