[NPU] reduce_sum_across_dp_group builds the all_reduce tensor on CPU when CUDA is unavailable
Los mantenedores suelen responder en 4 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- distributed-systems
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 5.2k
- Forks
- 466
- Merge medio
- 5 d 8 h
- PR fusionados (30 d)
- 44
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de InternLM/xtuner
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
Los mantenedores suelen responder en 4 días
-
enhancement good first issue
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
InternLM/xtuner#2246 · 3 comentarios ·
Los mantenedores suelen responder en 4 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
InternLM/xtuner#2134 · 1 reacción ·
Los mantenedores suelen responder en 4 días
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
InternLM/xtuner#2118 · 6 comentarios ·
Los mantenedores suelen responder en 4 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
Los mantenedores suelen responder en 4 días
Todos los issues de InternLM/xtuner
Issues similares
-
accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
future-agi/future-agi#5908 ·
Los mantenedores suelen responder en 1 día
-
Placeholder export disables HTML image input for picture descriptionPosiblemente ocupada @cloudiful la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
docling-project/docling-serve#817 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
Techiebutler/freeframe#687 ·
Los mantenedores suelen responder en 1 día
-
Parse truncated verbose GC logs up to the first XML errorPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug verbose GC
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
IBM/javacore-analyser#677 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 2 días