Skip to content

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.

Quick answer

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.
Training Stability#deepspeed#huggingface-trainer#auto_find_batch_size#hang#zero-offload#training-stability

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.

Live diagnosis, no signup

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.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free cloud diagnoses per day

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.

SymptomPossible explanation
Progress bar stuck at 0/N with cpu_adam loadedauto_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 steppingThese re-inits desync NCCL collectives across ranks, so the ranks deadlock waiting on each other
Hang correlates with auto_find_batch_size=Trueauto_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.

Use your company email, for example alex@yourcompany.com.

Who qualifies?

Company email domains activate the free 30-day Team evaluation (up to 50 diagnoses a day) after an email and domain check, whatever mail provider you use. If we cannot verify your domain automatically, support reviews it: write to support@denpex.com. Free local diagnosis in the editor extension needs no account.

Using a personal email (Gmail, Outlook, Naver, QQ) or solo cluster? Create a free $0 account (no work email required) to save 7-day history and unlock AI fallback, or send a cluster crash log for a live walkthrough.
Already have an account? Sign in

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 logs

No 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 extension

DeepSpeed 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 errors

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.