Skip to content

Megatron-LM Pipeline Parallel p2p recv_forward Hang

Isolate the failed upstream stage in Megatron-LM 1F1B pipeline-parallel p2p_communication hangs with PyTorch Flight Recorder and sequence checks.

Quick answer

In Megatron-LM 1F1B pipeline parallelism, downstream stages stuck inside p2p_communication recv_forward or batch_isend_irecv are waiting on an upstream pipeline stage that either crashed, hung in an earlier tensor-parallel collective, or sent mismatched tensor shapes. Capture per-stage logs across all PP ranks and inspect TORCH_NCCL_TRACE_BUFFER_SIZE dumps before touching timeouts.

Symptom
[rank16]: File "/workspace/Megatron-LM/megatron/core/pipeline_parallel/p2p_communication.py", line 294, in _p2p_ops
[rank16]:   reqs = p2p_func(ops)
[rank16]: RuntimeError: [Rank 16] Watchdog caught collective operation timeout: WorkNCCL(SeqNum=1904, OpType=COALESCED, Timeout(ms)=600000) while waiting in recv_forward from PP stage 1
Root cause
Upstream pipeline stage crash, intra-stage TP hang, or tensor shape disagreement between producer and consumer stages halted P2P handoff.
Recommended fix
TORCH_NCCL_TRACE_BUFFER_SIZE=2000
How Denpex helps
Denpex investigates Megatron-LM Pipeline Parallel p2p recv_forward Hang 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.
Distributed Training#megatron-lm#pipeline-parallel#nccl#p2p#flight-recorder#distributed

What this failure is

A pipeline-parallel collective stall where healthy Megatron-LM stages block waiting to send or receive activation/gradient tensors between pipeline stages.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about Megatron-LM Pipeline Parallel p2p recv_forward Hang. 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)

Because 1F1B schedules interleave forward sends and backward receives across stages, a single crash, OOM, NaN divergence, or dynamic microbatch sequence-length mismatch on stage k freezes neighboring stages k-1 and k+1 until the NCCL watchdog fires across the whole job.

What you'll observe

  • Multiple pipeline stages print NCCL watchdog timeout inside megatron/core/pipeline_parallel/p2p_communication.py
  • Job hangs silently after N microbatches with ranks spread across recv_forward and send_backward

Common symptoms and what they mean

Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.

SymptomPossible explanation
WorkNCCL watchdog timeout inside batch_isend_irecv or recv_forward / send_forwardUpstream pipeline stage crash, intra-stage TP hang, or tensor shape disagreement between producer and consumer stages halted P2P handoff.
One pipeline stage rank exited or stalled while neighbor stages timed out waiting for microbatch activation tensorsUpstream pipeline stage crash, intra-stage TP hang, or tensor shape disagreement between producer and consumer stages halted P2P handoff.

Which systems are affected

  • Megatron-LM / Megatron-Core 3D-parallel (TP x PP x DP) training runs
  • Multi-node H100/B200 clusters using virtual pipeline stages or interleaved 1F1B

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 all pipeline stages progress past the failing microbatch boundary and complete multi-step gradient sync cleanly.

Root cause

  • Upstream pipeline stage crash, intra-stage TP hang, or tensor shape disagreement between producer and consumer stages halted P2P handoff.

The fix and how to prevent it

How to fix it

  • Collect stdout/stderr from ALL global ranks (especially earliest failing ranks in other PP stages) instead of only stage 0 or rank 0; sort errors by timestamp.
  • Check whether all pipeline stages received identical --seq-length, --micro-batch-size, --num-microbatches, and variable-seq-length (--variable-seq-lengths) flags.
  • Enable PyTorch NCCL Flight Recorder (TORCH_NCCL_TRACE_BUFFER_SIZE=2000 TORCH_NCCL_DUMP_ON_TIMEOUT=1) and run torchfrtrace to identify which PP stage failed to enqueue its matching send or recv.
  • Inspect intra-stage tensor-parallel collectives and host dmesg on the stalled stage node before altering global pipeline schedules.

Step-by-step remediation

  1. 1Search all rank logs from stages 0..PP-1 by earliest timestamp before focusing on rank 0's timeout.
  2. 2Confirm microbatch sizes, sequence lengths, and PP/TP dimensions match across ranks.
  3. 3Enable TORCH_NCCL_TRACE_BUFFER_SIZE=2000 and inspect which stage stopped sending.

How to prevent it

  • Persist rank-indexed logs across every pipeline stage and enable Flight Recorder dumps in cluster training configs
  • Validate TP * PP * DP == WORLD_SIZE and enforce deterministic microbatch tensor shapes across ranks

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

Searchable error signature

search key
[rank16]: File "/workspace/Megatron-LM/megatron/core/pipeline_parallel/p2p_communication.py", line 294, in _p2p_ops
[rank16]:   reqs = p2p_func(ops)
[rank16]: RuntimeError: [Rank 16] Watchdog caught collective operation timeout: WorkNCCL(SeqNum=1904, OpType=COALESCED, Timeout(ms)=600000) while waiting in recv_forward from PP stage 1

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.

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.

Why the recommended fix works

Matching Flight Recorder send/recv sequence numbers across all pipeline stages reveals the exact silent or shape-mismatched producer stage rather than mistaking the waiting downstream receiver for the fault.

Code examples

snippet
export TORCH_NCCL_TRACE_BUFFER_SIZE=2000
export TORCH_NCCL_DUMP_ON_TIMEOUT=1
export TORCH_NCCL_ENABLE_TIMING=1
# Check earliest timestamped traceback across all ranks:
grep -rnE 'Error|Exception|Xid|OOM|Killed' /shared/logs/$JOB_ID/ | sort

This snippet illustrates the entry-specific check. Verify the installed versions, permissions, target and workload context before using it. A command or API example is not proof of recovery.

Best practices by model family

Model / StackRecommendationNotes
Locate failing stageDump Flight Recorder + sort rank logs by timestampFinds the missing send/recv producer rather than waiting receivers.
Variable sequence shapesVerify --variable-seq-lengths or pad microbatchesMismatch in expected P2P tensor buffer bytes deadlocks recv_forward.

With the fix vs without the fix

DimensionWith the fixWithout the fix
Timeout escalationInspect Flight Recorder active PP sends/recvsRaising NCCL timeout when one stage has already stopped
3D topology checkTrace both P2P (PP) and intra-node AllReduce (TP)Debugging only rank 0 logs

Diagnostic note

“Rank 0 sits on Pipeline Stage 0. When Stage 2 crashes or hangs internally, Stage 0 blocks inside recv_backward after finishing its forward microbatches and is often the first watchdog message operators read, even though Stage 0 is healthy.”

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

NCCL errors in context

An NCCL error can follow an earlier worker failure. The hub connects documented collective errors with their interpretation limits, worker evidence and configuration checks.

Compare related nccl errors

Frequently asked questions

Questions engineers and on-call staff commonly ask about this failure.

Why does p2p_communication report OpType=COALESCED instead of Send/Recv?
PyTorch fuses bidirectional pipeline send and receive calls inside torch.distributed.batch_isend_irecv into a COALESCED WorkNCCL operation.
Will raising NCCL_TIMEOUT resolve a Megatron pipeline recv hang?
No. If the upstream pipeline stage crashed or mismatched shapes, waiting longer only delays failure detection and wastes cluster GPU hours.

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.