Pipeline schedule verification
Validate operation identities, dependencies, versions, memory, numeric results, and bounded progress before trusting a throughput trace.
On this page
The question for today
What you’ll understand
- Define state, version, numeric, and timing oracles for a tiny schedule.
- Use operation counts as necessary checks rather than sufficient correctness proofs.
- Separate simulated schedules, measured runtimes, and fault-model coverage.
A plausible timeline can still omit a backward, swap two microbatches, reuse an activation too early, or apply an optimizer update to incomplete gradients. Verification needs several independent oracles because no utilization number detects all of those errors. This lesson combines the explicit semantics of GPipe, Megatron flush schedules, and PyTorch 2.8 pipeline interfaces. Start with a tiny deterministic model whose losses and derivatives are known before testing a large distributed implementation.
Specify the state machine before measuring speed
Identify each operation by stage, microbatch, direction, and parameter version, with separate records for communication initiation and completion. A forward requires its matching input; backward requires its matching local state and downstream gradient; an update requires the intended accumulation and reduction boundary. Buffers move through owned, in-flight, consumable, and reusable states according to actual dependencies. A stage can be locally idle yet globally correct, while an apparently busy stage can run an invalid operation. Treat legality as a prerequisite for performance interpretation.
For a simple chain without recomputation or split backward, count one forward and one backward per stage per microbatch. Count each logical boundary’s forward activation transfer and reverse gradient transfer. Those totals are necessary conservation checks, but equal totals do not prove correct matching or order. Label identities explicitly so a duplicate F0 and missing F1 cannot cancel in the aggregate. Version and lifetime assertions should fail at the first illegal transition rather than waiting for a later loss to diverge.
Use independent numeric and version oracles
Compare outputs, loss, all parameter gradients, and one optimizer update against an unsplit reference with the same objective and state. Include unequal token counts, nonmultiple microbatch sizes supported by the chosen interface, and the smallest legal microbatch count. A finite-difference or analytic scalar example offers an independent derivative check rather than another copy of the schedule implementation. Set a justified tolerance for floating-point order, and inspect stateful buffers and random behavior instead of comparing the loss alone.
The version oracle records which weights each forward and backward used, not just the final update counter. A flush schedule should satisfy its common-version boundary; an asynchronous design should satisfy its declared stashing and delayed-gradient rules. A memory oracle verifies that no send or backward reads storage after reuse. A timing oracle checks dependencies and per-device resource exclusion, then compares measured makespan with appropriate lower bounds. A trace simulator can test a stated model, but it cannot establish actual kernel costs or network progress by itself.
Test failures under an explicit progress model
Exercise missing participants, delayed transfers, shape mismatches, and deliberately corrupted operation identities in a small harness with bounded observation time. Define whether a failure should raise an error, abort the iteration, or invoke supported recovery. Passing one fault trace does not establish every interleaving safe. Record framework version, schedule configuration, stage mapping, seeds, precision, inputs, and environment so another run can reproduce the same contract. Benchmark only after all required correctness oracles pass, and keep verification overhead distinct from normal training time.
The probability lab illustrates an assumed test-input coverage model only. Reset, set trigger probability to 0.2 and trial count to 5, predict the chance of at least one trigger, then Step. Compare a fresh Reset with both probability at 0.2 and trials at 10 before Step. These are exact binomial probabilities under independent identical triggers, not schedule executions or a theorem about bugs. Correlated tests, unknown trigger rates, and incomplete assertions can invalidate a real coverage inference.
Work it through
Verify a two-stage two-microbatch fill/drain trace
Two stages process two microbatches with one-ms forwards and one-ms backwards, zero communication cost, and all-forward/all-backward order. List a legal compute trace, count logical actions and boundary messages, and identify one additional oracle.
Stage zero runs F0 at 0–1 ms and F1 at 1–2. Stage one runs F0 at 1–2 and F1 at 2–3. It then runs B1 at 3–4 and B0 at 4–5; stage zero runs B1 at 4–5 and B0 at 5–6.
There are P × M = 4 forwards and four backwards, or eight compute actions, and 2 × (P−1) × M = 4 logical boundary messages. Elapsed compute-only makespan is six milliseconds.
Check matching state and weight versions, then compare the accumulated gradient and one update with the same unsplit objective. Counts and a legal-looking timeline alone cannot detect a same-shaped tensor swapped between the two microbatches.
Identity, numeric, version, and timing checks complement each other; none is replaced by a high utilization reading.
The living notebook
Explore the model
Interactive lab · probability
Assumed trigger coverage is not schedule verification
Reset, set p = 0.2 and n = 5, predict the chance of at least one trigger, then Step: 0.67232. Compare a fresh Reset with both p = 0.2 and n = 10 before Step: approximately 0.89263. This exact binomial model does not execute pipeline schedules or prove test coverage.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forFinite tests depend on inputs and assertions, and passing them does not prove untested schedules correct.
Pause & reason
Check your understanding
Your turn
Try it yourself
For a simple three-stage chain and four microbatches under the stated counting contract, compute forward, backward, and logical boundary-message counts. Under an illustrative independent trigger model with p = 0.2 and five tests, compute the chance of at least one trigger and explain why it is not a correctness certificate.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Count operations separately from messages. The binomial complement is one minus the probability of five misses.
Compare with the solution
There are 12 forwards, 12 backwards, and 2 × 2 × 4 = 16 logical boundary messages. The illustrative trigger probability is 1 − 0.8⁵ = 0.67232. A real trigger rate can be unknown, tests can be correlated, and assertions can miss an error even when triggered. Neither these counts nor the probability proves identity matching, gradient correctness, or progress under untested failures.
Keep the idea
Take it with you
- Verify operation identities and state transitions before interpreting performance.
- Numeric, version, lifetime, timing, and progress oracles catch different failure classes.
- Toy probabilities and schedule simulations do not certify a real distributed training system.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.