[BUG] DeepSpeed ZeRO-3 deadlock in engine.step() at step 0 under 2-GPU execution (RTX 3090, torch 2.2.1, DS 0.14.2)
Describe the bug
A minimal DeepSpeed ZeRO stage 3 training script consistently hangs at step 0 inside engine.step() when launched with deepspeed --num_gpus 2. Both ranks reach step_begin, then make no forward progress while the script’s heartbeat confirms they are alive but stuck in the step phase. After 60 seconds, the testcase watchdog exits and prints Test Passed ✅ (this is intentional: the testcase defines the hang as the bug oracle).
This looks like a deadlock/hang during ZeRO-3 optimizer step / communication.
To Reproduce
- Create/activate an environment with:
- Python 3.10.19
- torch 2.2.1+cu121
- deepspeed 0.14.2
- Run with 2 GPUs:
# (optional debug; use what you used)
export PYTHONFAULTHANDLER=1
export TORCH_SHOW_CPP_STACKTRACES=1
export TORCH_DISTRIBUTED_DEBUG=DETAIL
# network selection used in reproduction
export NCCL_SOCKET_IFNAME=eno2
export GLOO_SOCKET_IFNAME=eno2
export NCCL_IB_DISABLE=1
# ZeRO stage
export DS_ZERO_STAGE=3
# run
deepspeed --num_gpus 2 testcases/deepspeed_testcase.py
- Observe logs: Both ranks print:
- R0 STEP0 route=0 -> forward
- R1 STEP0 route=0 -> forward
- ... -> backward
- R0 STEP0 route=0 -> step_begin
- R1 STEP0 route=0 -> step_begin
Then repeated:
- HEARTBEAT rank=0 step=0 phase=step_begin age=...
- HEARTBEAT rank=1 step=0 phase=step_begin age=...
After >60s:
- Test Passed ✅
- BUG_SIGNAL: HANG step=0 route=0 timeout>60s last_phase=step_begin
Expected behavior
The script should complete multiple iterations (configured for 6 iters) without hanging—i.e., engine.step() should return, and the run should proceed beyond step 0.
Actual behavior
The run consistently hangs at step 0 inside engine.step(), with both ranks stuck after printing step_begin. No step_end is printed. The heartbeat shows the program is still alive but deadlocked.
ds_report output
DeepSpeed C++/CUDA extension op report
- ninja: OKAY
- async_io: NOT installed / NOT compatible (libaio-dev missing)
- evoformer_attn: NOT installed / NOT compatible (CUTLASS_PATH not set)
- sparse_attn: NOT installed / NOT compatible (torch 2.2 detected; expected <2.0)
Other ops mostly NOT installed but compatible (JIT capable).
DeepSpeed general environment info:
torch install path ............... /home/talha/miniconda3/envs/ds_testcase/lib/python3.10/site-packages/torch
torch version .................... 2.2.1+cu121
deepspeed install path ........... /home/talha/miniconda3/envs/ds_testcase/lib/python3.10/site-packages/deepspeed
deepspeed info ................... 0.14.2, git-hash=unknown, git-branch=unknown
torch cuda version ............... 12.1
nvcc version ..................... 12.0
shared memory (/dev/shm) size .... 62.88 GB
Screenshots Not applicable (CLI hang with logs attached).
System info (please complete the following information):
- OS: Linux (exact distro not provided; can add if needed)
- Python: 3.10.19
- DeepSpeed: 0.14.2
- PyTorch: 2.2.1+cu121
- torch CUDA: 12.1
- Driver: 550.78
- System CUDA (from nvidia-smi): 12.4
- GPUs: 4× NVIDIA GeForce RTX 3090 (24GB each) available on the node
- Reproduction uses 2 GPUs via deepspeed --num_gpus 2
- Interconnects: single node; using interface eno2; IB disabled (NCCL_IB_DISABLE=1)
- /dev/shm: 62.88 GB
Launcher context
deepspeed --num_gpus 2 testcases/deepspeed_testcase.py
Docker context Not using Docker (not indicated in environment/logs).
Additional context
- Hang happens immediately at step 0 during
engine.step(). - The testcase includes barriers and a heartbeat thread to verify both ranks enter the step together and remain stuck.
ds_reportindicates some ops are not installed and some are not compatible (async_io,evoformer_attn,sparse_attn), but this testcase does not explicitly require those ops.- Warning present:
sparse_attnexpects torch < 2.0 but torch 2.2.1 is installed (not sure if relevant to the hang, but included for completeness).
Hi @griffinstalha,
I made a simple training loop script using DeepSpeed and ran it in the following environments, but I wasn't able to reproduce the issue.
- Python: 3.12.9 / PyTorch: 2.7.1+cu126 / DeepSpeed: 0.18.6+cabfebcd
- Python: 3.10.19 / PyTorch: 2.2.1+cu121 / DeepSpeed: 0.14.2
Can you share a repro script? Also, I recommend using a newer version of PyTorch and DeepSpeed.
Hi @tohtana and @griffinstalha,
I conducted a targeted reproduction study on DeepSpeed v0.14.2 to investigate the step_begin hang. While I could not reproduce the exact hang on a single-rank setup, the failure manifested as a critical initialization error that directly explains the multi-GPU deadlock.
1. Reproduction Observations
Using a minimal ZeRO-3 + Offload configuration, I found that the engine can reach the backward pass but fails with:
AttributeError: 'DeepSpeedZeRoOffload' object has no attribute 'backward'
This confirms that while deepspeed.initialize() returns an engine object, the internal ZeRO-3 optimizer state is not fully hooked. In the user's 2-GPU environment, this leads to a classic Collective Communication Deadlock:
- Both ranks reach the
step_beginbarrier. - Because the engine is in a "half-initialized" state, the underlying NCCL buffers or synchronization primitives are invalid.
- The ranks hang indefinitely waiting for a handshake that never occurs.
2. Root Cause: CUDA Toolchain Mismatch
Looking at the ds_report from @griffinstalha, there is a significant toolchain mismatch:
- System CUDA: 12.4
- Torch CUDA: 12.1
- DeepSpeed Ops: JIT (Just-In-Time) compiled.
In v0.14.2, ZeRO-3 Offload relies on JIT-compiled kernels for memory coordination. A mismatch between the system compiler and the Torch runtime often causes silent JIT failures. DeepSpeed's initialization logic in this version appears to swallow some of these errors, leaving a "zombie" engine that is initialized but lacks its core functional attributes (like .backward).
3. Recommended Fix/Verification
To verify if this is a JIT/Toolchain failure, @griffinstalha should attempt to force pre-compilation of the DeepSpeed binaries:
# Force pre-build of all ops to surface hidden compilation errors
DS_BUILD_OPS=1 pip install deepspeed==0.14.2 --force-reinstall
Thank you for the detailed investigation, @amadhan882! We might need to add a verification to throw a clearer error. Do you know if we still have the issue with master brach?
Hi @tohtana,
I’ve verified the current master branch (Commit: 8a63a2a) using a targeted reproduction script. The engine now initializes correctly and proceeds through the backward pass and optimizer step without any deadlocks.
Full Reproduction Logs on Master:
--- Fast Verify Master Branch (Commit: 8a63a2a) ---
Stage 3 initialize beginning
MA 1.88 GB Max_MA 1.9 GB CA 1.93 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.21 GB, percent = 33.2%
DeepSpeedZeRoOffload initialize [begin]
MA 1.88 GB Max_MA 1.88 GB CA 1.93 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.21 GB, percent = 33.2%
Parameter Offload - Persistent parameters statistics: param_count = 1, numel = 1
DeepSpeedZeRoOffload initialize [end]
MA 1.88 GB Max_MA 1.88 GB CA 1.93 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.21 GB, percent = 33.2%
Before creating fp16 partitions
MA 1.88 GB Max_MA 1.88 GB CA 1.93 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.21 GB, percent = 33.2%
After creating fp16 partitions: 1
MA 1.88 GB Max_MA 1.88 GB CA 1.9 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.22 GB, percent = 33.3%
Before creating fp32 partitions
MA 1.88 GB Max_MA 1.88 GB CA 1.9 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.23 GB, percent = 33.4%
After creating fp32 partitions
MA 1.88 GB Max_MA 1.88 GB CA 1.9 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.25 GB, percent = 33.5%
Before initializing optimizer states
MA 1.88 GB Max_MA 1.88 GB CA 1.9 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.26 GB, percent = 33.6%
After initializing optimizer states
MA 1.88 GB Max_MA 1.88 GB CA 1.9 GB Max_CA 2 GB
CPU Virtual Memory: used = 4.28 GB, percent = 33.8%
After initializing ZeRO optimizer
MA 3.75 GB Max_MA 3.75 GB CA 3.77 GB Max_CA 4 GB
CPU Virtual Memory: used = 4.29 GB, percent = 33.9%
SUCCESS: Master branch works without silent deadlock.
Analysis:
While the latest version handles the initialization gracefully, the silent deadlock observed in v0.14.2 confirms that a 'half-initialized' or 'zombie' engine state is possible under specific toolchain mismatches.
As a safeguard, would it be beneficial to add a verification check within deepspeed.initialize() to ensure core functional attributes (like .backward or the optimizer state) are fully hooked before returning to the user? This would provide a clearer error message and prevent hard-to-debug hangs in multi-GPU environments.
Hi @amadhan882, thank you for the investigation! I'm glad that the master branch doesn't have the issue. It would be beneficial to check if the engine state is healthy or not. If you can open a PR for that, I'm happy to review it. (Please feel free to pin my name)
Thanks for checking this.
I agree the behavior appears version- and environment-specific rather than reproducible on current master.
My original report was specifically for:
- Python 3.10.19
- torch 2.2.1+cu121
- DeepSpeed 0.14.2
- ZeRO stage 3
- 2-GPU launch
- single-node setup with NCCL/GLOO bound to the active interface and IB disabled
I’ll do two follow-ups:
- share a stripped minimal repro script, and
- rerun the original scenario in a clean env while also forcing DeepSpeed op prebuild to check whether hidden JIT/toolchain failures are involved.
I’ll report back with:
- the exact repro script,
- full logs,
- ds_report,
- package versions,
- network interface used,
- and whether the issue still reproduces after forcing op prebuild.
Also, thanks for checking master. That suggests the issue may be limited to the older stack or at least handled more safely there now.
Thanks for the follow-up.
I rebuilt the original stack and reran the test on my side with:
- Python 3.10.19
- torch 2.2.1+cu121
- DeepSpeed 0.14.2
- 2 GPUs
- ZeRO stage 3
- NCCL/GLOO bound to eno2
- NCCL_IB_DISABLE=1
One important note: my first rebuild attempt was invalid because NumPy 2.x caused DeepSpeed 0.14.2 import/runtime issues. After pinning NumPy to 1.26.4, the old stack became usable again.
With that corrected environment, "I was not able to reproduce the original step-0 deadlock"
on this node. The run completed successfully.
I also tried a separate DS_BUILD_OPS=1 install path, but that failed at async_io prebuild due missing libaio dev files, which seems orthogonal to this specific repro because the successful ZeRO-3 run did not use param/optimizer offload.
At this point, the issue appears environment-specific and I can no longer reproduce it reliably on the rebuilt original stack.
Please view the attached files.
deepspeed_testcase_used.py ds_report.txt repro_original_stack.log testcase_sha256.txt
Heads up — this looks like a together streaming issue. Might be worth trying npx ai-doctor for a fallback.