[BUG] ZeRO-2 deadlocks at step 1 training HF MixtralForCausalLM (native experts) with 2-GPU data parallel

Abierto
#9,110 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

Start by comparing the backward and engine.step() stack locations with DeepSpeed’s ZeRO-2 gradient reduction path, especially stage_1_and_2.py and runtime/utils.py. The issue provides a two-GPU Mixtral reproduction configuration, but says the cause is not identified and a standalone script will follow. First minimize the repro and trace collective ordering across ranks; done when step 1 completes or fails with a clear error under the reported setup.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug training

Describe the bug
An unmodified Hugging Face MixtralForCausalLM (native expert loop, no AutoEP and no deepspeed.moe) trained with ZeRO-2 under plain data parallelism on 2 GPUs completes step 0, then hangs in step 1. GPUs stay at 100% utilization, with no error or timeout for more than 9 minutes.

Stack dumps (faulthandler) show the two ranks in different places:

  • One rank has finished backward and is in engine.step() → stage_1_and_2.py step → check_overflow → has_overflow_partitioned_grads_serial → runtime/utils.py:has_inf_or_nan. It is blocked on device sync.
  • The other rank is still inside engine.backward() (autograd engine).

This looks like the gradient-reduction collective sequence diverging between ranks during step 1. The root cause has not been identified yet.

To Reproduce

  • transformers.MixtralConfig(vocab_size=32000, hidden_size=1024, intermediate_size=1024, num_hidden_layers=12, num_attention_heads=16, num_key_value_heads=4, num_local_experts=16, num_experts_per_tok=2, output_router_logits=True, router_aux_loss_coef=0.01, tie_word_embeddings=False, use_cache=False, attn_implementation="sdpa"), random init.
  • DeepSpeed config: bf16, zero_optimization.stage=2, AdamW (torch_adam: true), gradient_clipping: 1.0, train_micro_batch_size_per_gpu: 8, WarmupCosineLR.
  • Inputs: packed SFT batches, seq 1024, labels with prompt tokens masked to -100; loss = engine(input_ids=x, labels=y).loss; engine.backward(loss); engine.step().
  • deepspeed --num_gpus 2 ...

Under the same config, the same model with its MoE blocks replaced by AutoEP (expert_parallel.enabled, EP=2) or by deepspeed.moe.layer.MoE (EP=2) trains for 400 steps without hanging.

Expected behavior
Training proceeds, or fails with an error, instead of deadlocking.

System info

  • 2× NVIDIA H100 80GB HBM3, driver 595.112.07, CUDA 12.9
  • torch 2.8.0+cu129, transformers 5.23.0, DeepSpeed 0.20.1+5420b75de (master), Python 3.12, Ubuntu 24.04

Additional context
Found while collecting MoE baselines for roadmap #8672. Not yet minimized; a smaller standalone repro script will follow in a comment. AI assistance (Claude Code) was used to run the experiment and draft this report.

Lenguaje dominante
Python
Estrellas
43.3k
Forks
5.1k
Merge medio
5 d 10 h
PR fusionados (30 d)
85

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de deepspeedai/DeepSpeed

Todos los issues de deepspeedai/DeepSpeed

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.