Skip to content

Watchdog Timeout from Inconsistent Tensor Shapes

Ranks attempt to perform an all_gather or all_reduce on tensors that have different shapes across different ranks (e.g., dynamic sequence lengths in NLP). NCCL expects the byte count of the transferred buffers to match perfectly. When they don't, the internal state machine of NCCL gets deadlocked waiting for data that will never arrive.

Quick answer

Ranks attempt to perform an all_gather or all_reduce on tensors that have different shapes across different ranks (e.

Symptom
NCCL WARN Cuda failure 'invalid argument'
Root cause
Ranks attempt to perform an all_gather or all_reduce on tensors that have different shapes across different ranks (e.g., dynamic sequence lengths in NLP).
Recommended fix
Pad tensors to a uniform size across all ranks. max_len = torch.tensor(local_tensor.shape[0], device=device)\ndist.all_reduce(max_len, op=dist.ReduceOp.MAX)\n# Pad local_tensor to max_len before collective Ensures the NCCL collective operation transfers the exact same number of bytes from every rank.
How Denpex helps
Denpex investigates Watchdog Timeout from Inconsistent Tensor Shapes 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.
Software#Collective API Desync

What this failure is

Watchdog Timeout from Inconsistent Tensor Shapes is a Software failure seen during ML training runs. Ranks attempt to perform an all_gather or all_reduce on tensors that have different shapes across different ranks (e.g., dynamic sequence lengths in NLP). NCCL expects the byte count of the transferred buffers to match perfectly. When they don't, the internal state machine of NCCL gets deadlocked waiting for data that will never arrive. Common tags: Collective API Desync.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about Watchdog Timeout from Inconsistent Tensor Shapes. 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 diagnoses/day

Why it happens (the mechanism)

NCCL does not gracefully validate tensor shapes across ranks before initiating the transfer; it just hangs until the watchdog times out.

What you'll observe

  • Watchdog caught collective operation timeout
  • NCCL WARN Cuda failure 'invalid argument'

Common symptoms and what they mean

SymptomWhy it happens
Training hangs randomly in the middle of an epoch.Ranks attempt to perform an all_gather or all_reduce on tensors that have different shapes across different ranks (e.g., dynamic sequence lengths in NLP). NCCL expects the byte count of the transferred buffers to match perfectly. When they don't, the internal state machine of NCCL gets deadlocked waiting for data that will never arrive.
Only happens with specific dynamic batch size configurations or sequence lengths.Ranks attempt to perform an all_gather or all_reduce on tensors that have different shapes across different ranks (e.g., dynamic sequence lengths in NLP). NCCL expects the byte count of the transferred buffers to match perfectly. When they don't, the internal state machine of NCCL gets deadlocked waiting for data that will never arrive.

Which systems are affected

  • PyTorch
  • NCCL
  • FSDP

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.

  • ✓Before the suspect collective operation, print tensor.shape on all ranks.
  • ✓Check for dynamic batching or variable sequence lengths that might not be padded equally.

Root cause

  • Ranks attempt to perform an all_gather or all_reduce on tensors that have different shapes across different ranks (e.g., dynamic sequence lengths in NLP). NCCL expects the byte count of the transferred buffers to match perfectly. When they don't, the internal state machine of NCCL gets deadlocked waiting for data that will never arrive.

The fix and how to prevent it

Searchable error signature

search key
NCCL WARN Cuda failure 'invalid argument'
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

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.