ELLMEngineering Large
Language Models
Download PDF

Chapter 46

Cluster Scheduling, Observability, and Distributed Diagnosis

On this page

A distributed job is a coordinated tenant of accelerators, network, storage, CPUs, and control-plane services. Production performance depends on placement, reproducibility, and the ability to identify the first rank or resource that diverges.

The distributed system has a control loop: placement and policy shape execution; telemetry, failures, and checkpoints feed the next scheduling decision.
Open full diagram ↗

The distributed system has a control loop: placement and policy shape execution; telemetry, failures, and checkpoints feed the next scheduling decision.

Job specification and rendezvous

A reproducible job specification binds:

  • code and container or environment digest;
  • model architecture, data, tokenizer, and training recipe versions;
  • world size and every parallel degree;
  • rank-to-device and group mapping policy;
  • network, storage, CPU, and memory requirements;
  • checkpoint input/output and recovery policy;
  • retry, timeout, priority, and preemption semantics;
  • observability and security configuration.

Rendezvous assigns one membership epoch and rank mapping. Every process must agree before communicator creation. Reusing stale addresses or allowing two epochs to write the same checkpoint namespace can corrupt a run.

The control plane should fence old workers with leases or epochs. A restarted rank is not allowed to join an existing synchronous group casually; the whole group transitions through a supported recovery protocol.

Gang scheduling and placement

Synchronous jobs need all required ranks, so gang scheduling avoids holding partial allocations that cannot progress. Large rigid gangs can wait behind fragmented free GPUs even when aggregate capacity is sufficient.

Topology-aware placement chooses nodes and rails that satisfy the communication plan. Pack latency-sensitive TP groups tightly; place DP groups to exploit network bandwidth; avoid sharing oversubscribed links with another communication-heavy job when the scheduler can see that demand.

Placement objectives include:

  • expected step time and variance;
  • queue delay and fragmentation;
  • failure-domain spread or concentration;
  • locality to data/checkpoints;
  • power, cooling, and maintenance constraints;
  • preemption and replacement availability.

Packing one job into a small failure domain improves communication but a single failure loses more of its ranks. Spreading replicas improves fault isolation but may cross slower links. Make the trade explicit.

Admission and quotas

Reserve accelerators, host memory, network injection, storage bandwidth, and checkpoint capacity. GPU count alone permits too many jobs to saturate a shared filesystem or fabric.

Tenant quotas can be expressed in accelerator time, priority-weighted queue share, or reserved pools. Backfilling short jobs improves utilization if it cannot delay reserved starts. Preemption needs a checkpoint or restart-cost model; killing a job just before its next durable point wastes more than its nominal GPU time.

Use predicted checkpoint and startup duration in scheduling. A large job that needs thirty minutes to restore should not be repeatedly preempted for brief capacity gaps.

Step-time decomposition

Measure each step as a distributed critical path:

input -> forward -> backward -> optimizer -> checkpoint/eval boundaries

Within it, separate compute kernels, exposed collectives, rank arrival skew, pipeline idle, host gaps, memory stalls, and storage. The maximum rank determines synchronous step time, but the earliest divergence often occurs before the maximum event.

Report tokens or samples per second, model FLOP utilization with a declared FLOP convention, scaling efficiency, and time-to-valid-model. FLOP utilization can look low because of sparse experts, recomputation, padding, or a mismatched numerator; define what counts.

Attribute exposed communication with a max-plus recurrence

A derived schedule for two buckets: six milliseconds of communication service expose only two milliseconds after backward. Accelerating bucket 1 cannot remove bucket 2's readiness dependency.
Open full diagram ↗

A derived schedule for two buckets: six milliseconds of communication service expose only two milliseconds after backward. Accelerating bucket 1 cannot remove bucket 2's readiness dependency.

For collective bucket k, let a_rk be rank r's local readiness time. With one serialized communication resource and aligned clocks, define a_k=max_r a_rk, s_k=max(a_k,e_(k-1)), and e_k=s_k+c_k, where c_k is the collective service time. If backward compute ends at B, the exposed tail is max(0,e_last-B) under this model.

Consider two buckets ready globally at 2 and 7 ms, each with 3 ms service, and backward ending at 8 ms. Communication finishes at 5 and 10 ms; the exposed tail is 2 ms, although total communication service is 6 ms. Making the first bucket faster does not move the second bucket's 7 ms readiness constraint. Making a late rank ready earlier can reduce the tail without changing link bandwidth.

Real implementations can pipeline chunks, overlap communicators, and contend with compute, so use this as a trace interpretation model rather than a universal NCCL timing formula. Cross-host timestamps require clock alignment or a causal reconstruction. A large duration measured from one rank's early collective entry may include arrival skew; compare per-rank readiness before labeling the interconnect slow.

Rank-synchronous observability

Useful telemetry includes:

  • global step, microbatch, pipeline slot, and membership epoch;
  • rank coordinates and host/device/link identity;
  • collective sequence number, group, type, bytes, start, and completion;
  • kernel and data-loader spans;
  • allocator and activation peak memory;
  • expert load and context/pipeline balance;
  • checkpoint stage and storage throughput;
  • hardware errors, throttling, and network counters.

Align clocks or use logical sequence IDs. Wall-clock traces from unsynchronized hosts can invert causality. Aggregate percentiles without losing per-rank maxima and identities.

Control cardinality: ranks and steps belong in traces or bounded debug logs, while durable metrics aggregate by job, stage, node class, and group. During an incident, promote sampled detail for the affected job.

Straggler diagnosis

A slow step can originate from:

  • data or CPU preprocessing on one rank;
  • a long kernel due to shape, thermal throttling, or memory fault;
  • pipeline stage imbalance;
  • expert routing skew;
  • collective transport or link errors;
  • another job contending for NIC or storage;
  • host scheduling and progress-thread delay.

Find the earliest event whose start or completion diverges. A late collective start indicates upstream skew; aligned starts with a late completion indicate communication or one rank failing to progress. Compare the slow rank with its physical neighbors and logical peers.

Do not begin by averaging. The mean rank is not on the critical path.

Hang and desynchronization debugging

For each communicator, capture a bounded flight recorder of collective sequence, operation, tensor metadata, stream, completion state, and call stack. On timeout, gather snapshots from all reachable ranks.

Look for:

  • a sequence present on some ranks but absent on another;
  • the same sequence with mismatched operation or count;
  • ranks blocked before the communicator;
  • a prior device error;
  • cyclic waits across multiple communicators;
  • stale membership or duplicate rank.

Reproduce with synchronization checks and smaller scale if timing permits, but remember that added barriers can hide races. Preserve the original flight recorder first.

Network and hardware isolation

Run layered tests:

  1. single-device kernel and memory health;
  2. pairwise device links within a node;
  3. local collectives;
  4. GPU-to-NIC and host affinity;
  5. pairwise inter-node paths by rail;
  6. collective benchmarks on the exact group;
  7. application replay with competing traffic.

Quarantine nodes or links that show repeated correctable errors, bandwidth cliffs, or timeouts. A retry that lands on the same bad path is not recovery.

Firmware, drivers, runtime, collective library, and topology discovery form a compatibility set. Canary infrastructure changes on representative distributed jobs, not only single-GPU tests.

Reproducibility and semantic identity

Record model, tokenizer, data snapshot, packing, optimizer, precision, kernels, collective library, topology, parallel plan, checkpoint manifest, and membership history. Two jobs with the same source commit can differ because container, data order, or group layout changed.

Bitwise reproducibility across rank counts is often impractical due to reduction order and random mapping. Define the promised level: exact same-plan replay, numerical tolerance, or statistical training equivalence. Deterministic modes can cost performance and still require deterministic data and kernels.

End-to-end design method

Use the plan-evaluation measurements from Pipeline Parallelism and Hybrid Plans to prune candidates before autotuning. Change one parallel axis at a time where possible; map each candidate's groups onto the actual topology and compare peak per-rank memory, exposed collectives, and recovery cost. The table below collects the evidence required for release.

Production readiness checklist

Area Required evidence
Fit Peak per-rank memory with allocator and failure reserve
Compute Local shapes, achieved kernels, recomputation cost
Communication Bytes, groups, topology paths, overlap, tail ranks
Schedule Pipeline/accumulation semantics, bubble, imbalance
Correctness Cross-rank invariants, numerical tests, deterministic contract
Recovery Atomic checkpoints, resharded restore, fault drills
Operations Placement, quotas, alerts, flight recorder, runbooks
Economics Queue plus run time, recovery-adjusted cost, useful output

Design Exercises

  1. Design topology-aware scheduling for several competing large training jobs.
  2. How do you distinguish a network slowdown from rank arrival skew?
  3. Design a flight recorder for distributed collective hangs.
  4. What should be included in distributed job semantic identity?
  5. Compare strong-scaling efficiency with time-to-valid-model as objectives.
  6. Walk through the first hour of diagnosing a 5 percent intermittent step-time regression.

Worked Solutions

1. Topology-aware scheduling

Collect each job's process-group graph, bandwidth/latency demand, gang size, duration, checkpoint/startup cost, and failure policy. Pack TP and other latency-sensitive groups into fast fabric domains, place cross-node groups across sufficient rails, and account for shared storage/NIC contention. Use gang admission, reservations, backfill that cannot delay starts, and preemption based on recoverable work. Balance communication locality against failure-domain and fragmentation cost.

2. Network versus arrival skew

Record per-rank collective enqueue/start and completion using logical sequence IDs. If one rank starts late and peers wait, inspect that rank's preceding input, kernel, pipeline, expert, or host work. If starts align but completion stretches, inspect link/NIC counters, route, contention, transport retries, and progress. Compare the same group/message size across healthy nodes and a topology-matched microbenchmark. The collective span alone cannot separate the cases.

3. Flight recorder

Maintain a bounded per-process-group ring buffer containing membership epoch, communicator ID, sequence number, operation, tensor count/dtype, stream, enqueue/completion timestamps, and call stack. On timeout or signal, persist local buffers and aggregate reachable ranks. The analyzer finds missing sequences, mismatched operations/counts, earliest uncompleted calls, prior device errors, and cycles across communicators. Keep overhead bounded and redact data values.

4. Semantic identity

Bind code/container, model architecture, tokenizer, data snapshot and order, optimizer/scheduler, precision/loss scaling, random seeds and policy, kernels and collective runtime, complete parallel layout/topology, membership epochs, and checkpoint manifest. Add training recipe and evaluation version. A source commit or weight checksum alone cannot explain user-visible or optimization behavior.

5. Scaling versus valid model

Strong-scaling efficiency measures step-speed gain as devices increase at fixed work. It can reward a fragile plan with high checkpoint cost, changed batch semantics, long queue/startup, or poor recovery. Time-to-valid-model includes queueing, data, evaluation, checkpoint pause, lost work, failures, and quality convergence. Use component scaling to diagnose efficiency, but choose plans by recovery-adjusted cost and time to the accepted artifact.

6. Regression diagnosis

Confirm version, workload, topology, and measurement changes; compare the same step and shape buckets. Split the regression into input, kernels, exposed collectives, arrival skew, pipeline idle, optimizer, and checkpoint interference. Identify affected ranks/nodes/rails and earliest divergence from synchronized traces. Check hardware throttling/errors and competing jobs, run topology-matched collectives, bisect software/configuration, and mitigate by quarantining or rollback while preserving evidence.

Diagnose the earliest divergence, not the last timeout

A synthetic three-rank trace illustrates the causal order: at t=0 all ranks begin step 200; at t=12 ms rank 1 enters data decoding for an unusually large sample; at t=18 ms ranks 0 and 2 enter collective sequence 81; at t=118 ms they report a collective timeout; rank 1 has not entered sequence 81. The timeout identifies the waiting ranks, while the earliest divergence is rank 1's input path. Increasing the collective timeout may reduce alarms while retaining the throughput defect.

If instead rank 1 entered collective 82 with a different tensor shape, investigate control-flow or bucket-order mismatch. Record rank, step, collective sequence, shape, and readiness timestamps together. Neither case follows from aggregate GPU utilization alone.

Further Study and Primary References

Final Distributed Systems Principle

Part VI now develops application architecture, then the streaming algorithms and telemetry service used to locate divergent ranks and requests. The optional streaming companion supplies additional reference material. Across these systems, outputs, state ownership, and recovery remain explicit contracts.