[BUG] ZeRO-3 GPU memory spike and OOM with Qwen3.5 35B-A3B MoE on DeepSpeed 0.20.0; 0.19.0 works

Abierto
#9,082 0 comentarios 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
8/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

Start from the trace: the ZeRO-3 pre-forward hook path (fetch_sub_module, then all_gather_coalesced, then torch.empty) during checkpoint recomputation of the MoE decoder layer. Compare how DeepSpeed 0.19.0 and 0.20.0 handle parameter gathering and release in that path. Done means finding the cause, or per-rank peak memory that matches the 0.19.0 run on a reproducer.

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

Descripción

Description

When LoRA fine-tuning Qwen3.5-35B-A3B with LlamaFactory 0.9.6.dev and DeepSpeed ZeRO-3, GPU memory rises sharply in the first training batch and causes OOM on 8 × 72 GB RTX PRO 5000 Blackwell GPUs with DeepSpeed 0.20.0. After installing DeepSpeed 0.19.0 (and reinstalling the same Transformers, Accelerate and PEFT versions), the reporter says training works. This suggests a version-sensitive regression or interaction; the root cause is not yet established and transitive dependency changes have not been ruled out.

The reporter confirms the issue was reproduced on both A100 and RTX PRO 5000 GPUs, and also observed it with Qwen3.6 35B MoE. A100-specific failing logs and measurements are not yet included here. The specific run and stack trace below are for Qwen3.5; a separate Qwen3.6 trace is not available in this report.

Environment

  • 8 × NVIDIA RTX PRO 5000 72GB Blackwell (SM 12.0), driver 580.126.20 (trace below)
  • Also reproduced on NVIDIA A100 PCIe 40GB according to the reporter; the exact failing-run software versions and logs still need confirmation.
  • DeepSpeed 0.20.0 failing; 0.19.0 reported working after the package change
  • PyTorch 2.10.0+cu130, Python 3.12, Triton 3.6.0
  • Transformers 5.8.0, Accelerate 1.11.0, PEFT 0.18.1
  • LlamaFactory 0.9.6.dev, commit 673048c6a543cbbeaed5b8444b8223dc4e23c721
  • flash-attn, flash-linear-attention, and causal-conv1d were not installed in the failing run; Qwen linear attention logged that it fell back to the PyTorch implementation.

Steps to reproduce

  1. Install the versions above with DeepSpeed 0.20.0 and load Qwen/Qwen3.5-35B-A3B in LlamaFactory.
  2. Launch 8 distributed ranks for multimodal SFT with BF16, LoRA rank 128 / alpha 256, lora_target: all, batch size 1 per GPU, gradient accumulation 16, cutoff length 8192, image max pixels 1048576, and gradient checkpointing enabled. The training data consists of private multimodal examples, so this is not yet a standalone reproducer.
  3. Enable ZeRO-3 without CPU offload. The relevant configuration is:
{
  "train_batch_size": "auto",
  "train_micro_batch_size_per_gpu": "auto",
  "gradient_accumulation_steps": "auto",
  "bf16": {"enabled": "auto"},
  "zero_optimization": {
    "stage": 3,
    "overlap_comm": false,
    "contiguous_gradients": true,
    "sub_group_size": 1000000000,
    "reduce_bucket_size": "auto",
    "stage3_prefetch_bucket_size": "auto",
    "stage3_param_persistence_threshold": "auto",
    "stage3_max_live_parameters": 1000000000,
    "stage3_max_reuse_distance": 1000000000,
    "stage3_gather_16bit_weights_on_model_save": true
  }
}

Observed

The log confirms Detected DeepSpeed ZeRO-3: activating zero.init() for this model. After model loading, nvidia-smi showed about 9.4 GiB per GPU; during the first training batch this grew to roughly 70 GiB per GPU, and the run failed before the first optimizer step. On rank 6, the recorded error was:

torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 1.51 GiB.
GPU 6 has a total capacity of 71.12 GiB of which 1.20 GiB is free.
Including non-PyTorch memory, this process has 69.92 GiB memory in use.
Of the allocated memory 69.03 GiB is allocated by PyTorch,
and 277.58 MiB is reserved by PyTorch but unallocated.

The stack shows accelerator.backward → torch.utils.checkpoint.backward (recomputed forward) → Qwen3_5MoeDecoderLayer.forward / self.mlp → DeepSpeed ZeRO-3 pre-forward hook → fetch_sub_module → all_gather_coalesced → torch.empty. Other ranks also failed while concatenating parameter partitions. The all-gather is the failing allocation, not proof of what accounted for all previously allocated memory.

Expected

The run should fit in available memory, or memory usage should be comparable to the reported successful 0.19.0 setup. Is there a known change in ZeRO-3 parameter gathering or retention in 0.20.0 that might explain this behavior? Guidance on collecting useful per-rank memory traces or constructing a minimal reproduction would be appreciated.

Version comparison limitations

The reporter changed packages with pip install transformers==5.8.0 deepspeed==0.19.0 accelerate==1.11.0 peft==0.18.1 and reports the issue resolved. The latter three versions other than DeepSpeed were already the same before the change, and the current environment confirms DeepSpeed 0.19.0 and PyTorch 2.10.0+cu130. A full before/after dependency lock and matched peak measurements are not yet available, so this is not a fully controlled bisect.

Lenguaje dominante
Python
Estrellas
43.4k
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.