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

Đang mở
#9,082 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
8/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
python, pytorch

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
43.3k
Fork
5.1k
Merge trung bình
5 ngày 10 giờ
Pull request đã merge (30 ngày)
85

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của deepspeedai/DeepSpeed

Tất cả issue của deepspeedai/DeepSpeed

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.