Skip to content

NCCL Watchdog Timeout due to Uneven Dataset Sharding

When sharding datasets across multiple workers, if the total number of samples is not perfectly divisible by the world size and drop_last=False, some ranks will have fewer batches. These ranks will finish their loop early, while the remaining ranks enter a collective operation (e.g., gradient all_reduce) expecting participation from all ranks, leading to a hang until the watchdog times out.

Quick answer

When sharding datasets across multiple workers, if the total number of samples is not perfectly divisible by the world size and drop_last=False, some ranks will have fewer batches.

Symptom
NCCL WARN local rank * failed to connect to ring
Root cause
When sharding datasets across multiple workers, if the total number of samples is not perfectly divisible by the world size and drop_last=False, some ranks will have fewer batches. These ranks will finish their loop early, while the remaining ranks enter a collective operation (e.g.
Recommended fix
Ensure all ranks process the exact same number of batches. Use drop_last=True in DistributedSampler or PyTorch's Join context manager. This guarantees all ranks participate in all expected collective operations.
How Denpex helps
Denpex matches NCCL Watchdog Timeout due to Uneven Dataset Sharding 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.
Data#Rank Desync / Straggler

What this failure is

NCCL Watchdog Timeout due to Uneven Dataset Sharding is a Data failure seen during ML training runs. When sharding datasets across multiple workers, if the total number of samples is not perfectly divisible by the world size and drop_last=False, some ranks will have fewer batches. These ranks will finish their loop early, while the remaining ranks enter a collective operation (e.g., gradient all_reduce) expecting participation from all ranks, leading to a hang until the watchdog times out. Common tags: Rank Desync / Straggler.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about NCCL Watchdog Timeout due to Uneven Dataset Sharding. 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 error message 'Watchdog caught collective operation timeout' suggests a network or NCCL failure, making engineers investigate networking hardware or drivers, when the actual cause is a simple data loading desync.

What you'll observe

  • RuntimeError: Watchdog caught collective operation timeout
  • NCCL WARN local rank * failed to connect to ring

Common symptoms and what they mean

SymptomWhy it happens
Training hangs indefinitely after a specific number of epochs or steps.When sharding datasets across multiple workers, if the total number of samples is not perfectly divisible by the world size and drop_last=False, some ranks will have fewer batches. These ranks will finish their loop early, while the remaining ranks enter a collective operation (e.g., gradient all_reduce) expecting participation from all ranks, leading to a hang until the watchdog times out.
One rank finishes early and exits, while others are stuck at an all_reduce barrier.When sharding datasets across multiple workers, if the total number of samples is not perfectly divisible by the world size and drop_last=False, some ranks will have fewer batches. These ranks will finish their loop early, while the remaining ranks enter a collective operation (e.g., gradient all_reduce) expecting participation from all ranks, leading to a hang until the watchdog times out.

Which systems are affected

  • PyTorch
  • NCCL
  • DistributedDataParallel

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.

  • Check the number of batches yielded by the dataloader on each rank by logging len(dataloader).
  • Examine if one rank logs a 'finished training' message before the crash.

Searchable error signature

search key
NCCL WARN local rank * failed to connect to ring
RuntimeError: Watchdog caught collective operation timeout

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

NCCL errors in context

NCCL is where a distributed job reports failure, which is not the same as where it failed. The hub lists every common NCCL error next to what it actually indicates, and the environment variables that tell them apart.

Compare every nccl error side by side

Root cause

  • When sharding datasets across multiple workers, if the total number of samples is not perfectly divisible by the world size and drop_last=False, some ranks will have fewer batches. These ranks will finish their loop early, while the remaining ranks enter a collective operation (e.g., gradient all_reduce) expecting participation from all ranks, leading to a hang until the watchdog times out.

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.