Skip to content

DDP Hang Due to Unused Parameters in Forward Pass

When find_unused_parameters=False (the default), DDP assumes every parameter in the model will receive a gradient. If a parameter is skipped in the forward pass (e.g., due to a conditional if-statement), its gradient is never computed. DDP waits indefinitely in the backward pass for the all-reduce operation on that missing gradient, deadlocking the training step.

Quick answer

When find_unused_parameters=False (the default), DDP assumes every parameter in the model will receive a gradient.

Symptom
RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one.
Root cause
When find_unused_parameters=False (the default), DDP assumes every parameter in the model will receive a gradient. If a parameter is skipped in the forward pass (e.g.
Recommended fix
Enable find_unused_parameters if the graph is truly dynamic. model = DDP(model, device_ids=[rank], find_unused_parameters=True) Instructs DDP to traverse the autograd graph before the backward pass to discover which parameters are unused and proactively mark them as ready for reduction.
How Denpex helps
Denpex matches DDP Hang Due to Unused Parameters in Forward Pass across every rank in a distributed run and reports which rank failed first, so you act on the initiating node instead of the loudest one.
Synchronization#Autograd Graph Deadlock

What this failure is

DDP Hang Due to Unused Parameters in Forward Pass is a Synchronization failure seen during ML training runs. When find_unused_parameters=False (the default), DDP assumes every parameter in the model will receive a gradient. If a parameter is skipped in the forward pass (e.g., due to a conditional if-statement), its gradient is never computed. DDP waits indefinitely in the backward pass for the all-reduce operation on that missing gradient, deadlocking the training step. Common tags: Autograd Graph Deadlock.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about DDP Hang Due to Unused Parameters in Forward Pass. Paste your own crash log or traceback below and get the real root cause for YOUR run, not this generic entry. No account, no card. Logs are masked at ingress and never saved to account history.

training_logs.txt
No log to hand? Try one:

3 free diagnoses/day

Want 14 days on the Scale plan?

Request an evaluation code. A verified workplace organization activates up to 50 diagnoses a day, alerts, history, and follow-up questions. No credit card or automatic subscription.

Evaluate one incident

Why it happens (the mechanism)

The script produces no crash or error message immediately. It simply hangs. Naive diagnosis might assume an NCCL network issue, GPU hardware failure, or a slow data loader, whereas the true issue is entirely in the autograd computation graph.

What you'll observe

  • RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one.
  • Process hangs indefinitely during loss.backward()

Common symptoms and what they mean

SymptomWhy it happens
The training script completely freezes during the backward pass.When find_unused_parameters=False (the default), DDP assumes every parameter in the model will receive a gradient. If a parameter is skipped in the forward pass (e.g., due to a conditional if-statement), its gradient is never computed. DDP waits indefinitely in the backward pass for the all-reduce operation on that missing gradient, deadlocking the training step.
No CPU or GPU utilization spikes; processes just sit idle waiting for communication.When find_unused_parameters=False (the default), DDP assumes every parameter in the model will receive a gradient. If a parameter is skipped in the forward pass (e.g., due to a conditional if-statement), its gradient is never computed. DDP waits indefinitely in the backward pass for the all-reduce operation on that missing gradient, deadlocking the training step.

Which systems are affected

  • PyTorch
  • DistributedDataParallel (DDP)

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.

  • Set environment variable TORCH_DISTRIBUTED_DEBUG=DETAIL to see exact parameter wait logs.
  • Check if any layers in the model's forward pass are inside conditional blocks that might not execute.
  • Temporarily set find_unused_parameters=True to see if the hang resolves.

Searchable error signature

search key
RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one.

Use this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.

The fix and the prevention pattern

The root cause is on this page and stays free. A free account adds the exact remediation steps, saved history, and the fix on every entry in the encyclopedia.

Sign up free. Unlock the full analysis

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 see the initiating rank, collateral failures, exact fix, and verification command without uploading the log.

Install the free VS Code extension

Root cause

  • When find_unused_parameters=False (the default), DDP assumes every parameter in the model will receive a gradient. If a parameter is skipped in the forward pass (e.g., due to a conditional if-statement), its gradient is never computed. DDP waits indefinitely in the backward pass for the all-reduce operation on that missing gradient, deadlocking the training step.

The fix and how to prevent it

Evaluate Denpex on your own logs

Request a Scale evaluation code. A verified workplace organization activates 14 days with up to 50 diagnoses a day. Every account keeps its current diagnosis allowance and gets a verification path. No card or automatic subscription.

We send a single-use code tied to that address. Static provider and TLD rules do not reject valid addresses. Account trust determines the benefit after signup.

Don't just read the fix, diagnose your run

The encyclopedia tells you what went wrong. Denpex tells you what went wrong in YOUR training run. With your logs, your config, and your stack.