Hangs, health, and elastic restart
Use progress markers and phase-specific timeouts to distinguish a hang from a valid straggler, capture the first divergence, and choose group recovery behavior
Before you begin
Follow a linked prerequisite when you cannot explain it from memory. Background skills without links are stated as abilities rather than hidden terminology.
- Chapter 13 NCCL sequence and health diagnosis
- Chapter 14 process-group ownership
- Ability to compare elapsed time with a phase-specific distribution
An eight-rank job normally completes a step in 900 to 1,300 milliseconds. During step 7,420, no rank records another completed-step marker for 90 seconds. Ranks 0 through 6 show the same pending all-reduce, while rank 7's last log entry precedes an asynchronous device error. The observed absence of expected progress is called a hang; the term describes the symptom, not the cause.
Use monotonic progress markers from several layers. The application records completed steps and input advancement. The framework records collective sequence numbers. CUDA error checks record device faults. NCCL reliability, availability, and serviceability status reports communicator and process responsiveness in supported releases. Process stacks and host logs show whether a worker is blocked or still executing ordinary code.
A timeout compares elapsed time with a justified upper bound for a named phase. One global threshold is unsuitable when a 20-microsecond collective and a 40-second checkpoint are both valid operations. Phase-specific distributions make a timeout sensitive enough to detect missing progress without terminating legitimate tail work.
Preserve the earliest bounded evidence before terminating workers when collection is safe. A surviving synchronous process group cannot usually continue after one participant disappears inside a collective, so the launcher terminates or reforms the group and restores portable state. Retry budgets and resource quarantine prevent an elastic launcher from repeatedly returning the job to one persistent device, data, or network fault.
Define progress at several layers
Process liveness answers whether the operating system still sees the process. In this design, a worker-side watchdog thread emits a timestamped host heartbeat to the external job supervisor every five seconds; heartbeat freshness answers whether that CPU thread can run and communicate with the supervisor. A CUDA event polled by the watchdog records whether a declared GPU stream has retired new work. A framework collective-sequence record answers whether ranks launch and complete compatible communication. An application completed-step counter answers whether the job retains useful progress. Each producer, record, and boundary is different, so each signal excludes some causes but not all causes.
Make progress markers monotonic and attach timestamps and operation identities. Useful fields include current step and microbatch, last launched and completed collective sequence, collective type and element count, current input shape, last completed device event, checkpoint phase, hostname, device identifier, and topology location. A single message such as rank alive contains too little information for causal comparison.
Use operation-aware time bounds
A timeout is a claim about how long valid work can take. One fixed value is usually poor. A large checkpoint write, process-group initialization, expert all-to-all, and small gradient all-reduce have different distributions. Long sequences or compilation can also extend a step without indicating failure.
Record healthy duration distributions by phase, shape, message size, and scale. Set a warning bound before a termination bound. The warning can collect state while the operation still has an opportunity to complete. Keep an absolute upper bound for cases where progress counters move but useful work never completes. Review tail events because changing workloads can invalidate old thresholds.
Compare ranks by logical operation
When a collective stalls, collect the sequence number, collective kind, tensor size, group identity, and launch time from every member. If rank 11 reports all-reduce sequence 402 while rank 12 reports broadcast sequence 402, the process group has a contract mismatch. If all ranks report the same operation but one has not reached it, walk backward through that rank's preceding device, input, and host work.
Arrival skew and transfer failure require different repairs. Late arrival points to imbalance, input delay, or earlier computation. Similar arrival followed by no completions points more strongly to communication, device, or runtime state. Cross-rank timelines established in the profiling chapter provide the same comparison during incidents.
Capture evidence before teardown
On the warning path, gather recent structured logs, process stacks, device error reports, collective state, network counters, topology identity, and a bounded trace window. Time-stamp the collection. Preserve the earliest asynchronous device error and first rank divergence separately from later peer-abort messages.
NCCL RAS provides an out-of-band Transmission Control Protocol mechanism for querying communicator health and identifying missing or unresponsive processes in supported NCCL versions. RAS helps establish communicator state; RAS does not by itself prove whether the initiating cause was invalid collective order, a device fault, a network fault, or stalled application code. Combine RAS output with application and system evidence.
Treat the communicator as invalid after serious failure
A process group depends on agreement among members and on the state of communication and device work. After a fatal asynchronous error, abrupt member loss, or incompatible collective sequence, continuing with the same communicator can propagate invalid state or wait forever. The safe recovery boundary is commonly the whole affected process group, even when one rank first reported the problem.
Recovery can terminate the group, allocate or select resources, create a new membership, construct new ranks, and restore a known checkpoint. Under elastic launch, rank numbers are not stable across restarts. Application state and data partitioning must not assume that a global or local rank always maps to the same host.
Recent NCCL releases also provide communicator-shrink functionality for supported recovery designs. Removing failed ranks from communication does not validate the interrupted training iteration or reshard model and optimizer state automatically. The application must still define the rollback boundary, reconstruct compatible ownership, and prove that surviving buffers do not contain partial collective or optimizer results before continuing.
Control retries and side effects
Record resource identities and incident signatures across attempts. Quarantine a node, GPU, NIC, or route after repeated matching faults according to policy. Limit automated retries and escalate when failures repeat, checkpoint restore fails, or no clean replacement exists. Immediate retries on the same placement can consume more time than diagnosis or reallocation.
Training usually repeats computation after restore, but distributed applications can also write metrics, samples, evaluation records, or external status. Make these effects idempotent or associate them with checkpoint and step identities. A restarted attempt should not publish the same supposedly final result twice or advance an external cursor beyond recoverable state.
Worked example: Separating a hang from a straggler
No step has completed for five minutes. Most ranks wait in a collective; one rank's GPU still shows activity.
- Read the collective records. Most ranks entered gradient all-reduce sequence 918 four minutes ago. Rank 37 has not launched sequence 918 and still reports the preceding attention operation for a sequence shard twice the usual length.
- Inspect rank 37's device events. Completion counters continue to advance, and the operation's shape-based warning threshold is six minutes. Process, host heartbeat, and device signals agree that slow work is still moving. Issue a straggler warning and collect a trace, but do not terminate at five minutes.
- At seven minutes, suppose the device completion counter has not changed for 90 seconds and exceeds the operation's termination policy. Capture rank 37's stack, device error state, recent kernels, and input identity. Capture peers' collective records and NCCL health state before aborting the group.
- If the evidence shows valid completion at five and a half minutes, address input balancing or shape limits. If it shows a device error at minute six, quarantine according to the repeated-fault policy, form a new membership, and restore. If rank 37 entered a different collective, fix the divergent control path.
- After restart, verify that new rank identities do not reuse stale data ownership assumptions. Confirm the restored step and observe the first several collective sequences before returning the run to normal monitoring.
Conclusion: The layered signals separate ongoing expensive work from stopped progress, while the warning interval preserves the evidence needed to choose among workload, device, network, and control-flow repairs.
Common errors
- Using one long global timeout. A long global timeout delays true failure detection and still lacks diagnostic specificity.
- Destroying processes before collecting the first divergence. Teardown errors can overwrite the causal signal.
- Retrying indefinitely on the same resources. Recovery policy needs quarantine and escalation for repeated faults.
- Treating a moving GPU utilization value as useful progress. Device work can repeat or remain unrelated to completion of the blocked dependency.
- Assuming ranks retain their identities after an elastic restart. Reconstruct ownership from current membership and logical state.
Reference summary
A hang means that expected progress did not occur within an allowed interval. Missing progress can result from mismatched collective order, a process crash, an asynchronous GPU error, a failed network path, deadlocked host code, blocked input, or an extreme but valid long-running operation. Detection, diagnosis, and recovery are separate system functions.
- Use monotonic progress markers from named producers: application completed-step and input counters, framework collective-sequence records, CUDA error and event records, and checkpoint-state records.
- Have a worker-side watchdog thread emit a timestamped host heartbeat to the external job supervisor at a declared period. Heartbeat freshness proves only that the thread can run and contact the supervisor; it does not prove GPU or training progress.
- Set operation- and phase-aware timeouts from valid tail behavior. One global timeout is usually too slow for small operations and too aggressive for legitimate long work.
- Collect rank stacks, communicator state, GPU errors, network counters, recent logs, and topology identity before teardown when safe.
- Use NCCL RAS to identify incomplete communicator state and unresponsive processes; use other evidence to determine why the process stopped responding.
- Treat the current synchronous iteration as invalid after a participant fails. Terminate or reform the affected process group according to supported semantics.
- Elastic launchers can create a new worker group, but the application must not assume stable rank identities and must restore portable state.
- Use retry budgets, backoff, quarantine, and escalation to avoid repeated restarts on a persistent hardware or data fault.
Knowledge check
Why must surviving workers often be terminated after one rank fails inside a collective?
Show the answer guide
- A collective can leave partial communication and device state on every participant, and surviving ranks cannot know that their local buffers represent one valid completed iteration after a peer disappears.
- The communicator membership and operation sequence no longer match the original contract, so continuing can hang, consume partial results, or propagate inconsistent optimizer state.
- The recovery policy normally invalidates the affected iteration and group, preserves bounded evidence, forms a supported new membership, restores a verified checkpoint, and validates the first resumed step.
Inject a worker failure and trace recovery
Kill or stall one worker during a declared collective in a toy multi-rank job. Use phase-specific warnings, capture evidence, stop or reform the group according to supported semantics, and restore.
Evidence to keep: Named progress-marker sources, heartbeat and CUDA-event timeline, collective sequences, first divergence, timeout decision, teardown evidence, restored step, repeated-work calculation, and first valid post-restore step.
The final reliability model treats detection, checkpointing, spare capacity, and recovery time as resources allocated against the value and risk of the workload.
Sources and further reading
The lesson explanations synthesize primary papers and official references. Follow the originals for proofs, exact APIs, architecture details, and version-sensitive behavior.