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.
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 matches Watchdog Timeout from Inconsistent Tensor Shapes 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.
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.
Is this what broke your run? Paste your log.
You're reading about Watchdog Timeout from Inconsistent Tensor Shapes. 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.
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.
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
| Symptom | Why 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.
Searchable error signature
NCCL WARN Cuda failure 'invalid argument'
Watchdog caught collective operation timeoutUse 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 analysisNo 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 extensionRoot 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
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.
References
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.