DeepSpeed Hang with Trainer auto_find_batch_size
Fix multi-GPU DeepSpeed ZeRO hangs at step 0 when Hugging Face Trainer auto_find_batch_size=True restarts the engine and desynchronizes ranks.
Enabling `auto_find_batch_size=True` in Hugging Face `Trainer` alongside DeepSpeed ZeRO hangs multi-GPU runs right after model load at step 0 because OOM retry loops re-initialize the DeepSpeed engine out of sync across ranks. Disable `auto_find_batch_size` and set an explicit micro-batch size.
- Root cause
- auto_find_batch_size retries the first step with progressively smaller batch sizes, re-initializing or re-synchronizing the DeepSpeed engine each attempt. These re-inits desync NCCL collectives across ranks, so the ranks deadlock waiting on each other.
- Recommended fix
auto_find_batch_size=False- How Denpex helps
- Denpex investigates DeepSpeed Hang with Trainer auto_find_batch_size using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
What this failure is
DeepSpeed Training Hangs at Start with HuggingFace auto_find_batch_size is a Training Stability failure seen during ML training runs. DeepSpeed (ZeRO offload) training with HuggingFace Trainer auto_find_batch_size=True hangs right after model load at 0/N steps. The batch-size auto-search re-initializes the engine and desynchronizes collectives across ranks. Disable auto_find_batch_size for distributed runs. Common tags: Deepspeed, Huggingface Trainer, Auto_find_batch_size, Hang.
Is this what broke your run? Paste your log.
You're reading about DeepSpeed Hang with Trainer auto_find_batch_size. Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
Why it happens (the mechanism)
Auto_find_batch_size retries the first step with progressively smaller batch sizes, re-initializing or re-synchronizing the DeepSpeed engine each attempt. These re-inits desync NCCL collectives across ranks, so the ranks deadlock waiting on each other. Taken together, these mechanisms explain why the failure is reproducible, why it tends to surface on specific workloads or scales, and why generic mitigation attempts often fall short without addressing the underlying cause.
What you'll observe
- Training hangs at 0% right after model/optimizer load
- No error, just a stalled progress bar
- Removing auto_find_batch_size unblocks the run
Common symptoms and what they mean
Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.
| Symptom | Possible explanation |
|---|---|
| Progress bar stuck at 0/N with cpu_adam loaded | auto_find_batch_size retries the first step with progressively smaller batch sizes, re-initializing or re-synchronizing the DeepSpeed engine each attempt |
| Multi-GPU DeepSpeed run never starts stepping | These re-inits desync NCCL collectives across ranks, so the ranks deadlock waiting on each other |
| Hang correlates with auto_find_batch_size=True | auto_find_batch_size retries the first step with progressively smaller batch sizes, re-initializing or re-synchronizing the DeepSpeed engine each attempt |
Which systems are affected
- DeepSpeed ZeRO-2/3 with optimizer/param offload
- HuggingFace Trainer auto_find_batch_size
- Multi-rank launches
How to confirm this is the problem
Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.
- ✓Verify `auto_find_batch_size=True` is present in `TrainingArguments` while logs stall at `0/N` after `cpu_adam` or DeepSpeed init.
- ✓Check whether ranks enter divergent retry paths when memory estimation triggers on one worker.
Root cause
- auto_find_batch_size retries the first step with progressively smaller batch sizes, re-initializing or re-synchronizing the DeepSpeed engine each attempt
- These re-inits desync NCCL collectives across ranks, so the ranks deadlock waiting on each other
The fix and how to prevent it
How to fix it
- Set `auto_find_batch_size=False` in `TrainingArguments` for distributed DeepSpeed runs.
- Configure explicit `per_device_train_batch_size` and `gradient_accumulation_steps` synced with the DeepSpeed config.
How to prevent it
- Never combine DeepSpeed with batch-size auto-search
- Fix the batch size for distributed runs and size it deliberately
Save this diagnosis and catch the next crash automatically
All root cause, fix, and prevention steps above are free to read. Create a free account with any email or GitHub to keep your saved diagnosis history across the encyclopedia and run cloud checks, or use a work email below for the 30-day Team evaluation. No card required.
Or start a 30-day free Team trial (work email)
Verified work email unlocks all 14 fleet diagnostic tools, Slack alerts, and team history for 30 days. No card and no automatic charge.
Diagnose your own log automatically
The root cause and fix steps above stay free. Create a free account to analyze full job logs, attribute the first failed rank, and keep saved incident history.
Sign up free. Analyze your cluster logsNo credit card. Daily allowance follows verified trust tier. Instant access.
Diagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to inspect matched failure patterns, supporting evidence and next checks without uploading the log. Verify recommendations against your workload before changing production.
Install the free VS Code extensionDeepSpeed errors in context
DeepSpeed changes when parameters, gradients and optimizer state are created, partitioned, gathered and offloaded. The hub separates ZeRO, memory, checkpoint and pipeline failures by lifecycle phase.
Compare related deepspeed errorsRelated failures to investigate next
Don't just read the fix, diagnose your run
The encyclopedia explains documented failure patterns. Denpex investigates your logs, configuration and stack, shows the supporting evidence, and asks for missing details when needed.