Pipeline weight-version consistency
Distinguish matching local forward/backward weights from synchronous global-update semantics and delayed-gradient algorithms.
On this page
The question for today
What you’ll understand
- Attach parameter versions to stage and microbatch executions.
- Explain what PipeDream weight stashing guarantees and what it does not.
- Compare stale and current gradients on a two-stage scalar model.
Two training schedules can use identical devices and a 1F1B pattern while implementing different optimization algorithms. A synchronous flush keeps one intended parameter version through accumulation; an asynchronous pipeline can update while older microbatches remain in flight. Weight stashing repairs a particular local forward/backward mismatch, but does not by itself recover ordinary synchronous SGD. This lesson separates GPipe and Megatron’s flush semantics from the original PipeDream SOSP 2019 algorithm.
Version state belongs to a particular computation
A backward derivative must use the parameter values and forward state required by the forward computation it differentiates. If a stage overwrites its weights before that backward, reading the latest values can produce an invalid mixture. Track a version identifier when the stage executes each forward, retain or reconstruct the required version, and use it for the matching backward. Saved activations alone do not protect against a changed parameter multiplying an upstream gradient. The required values depend on the derivative, not on whether tensor shapes still match.
Original PipeDream stashes weight versions so that a microbatch’s forward and backward at a stage use the corresponding local version. It can keep the pipeline moving while updates occur, but microbatches can encounter versions from different stages and updates can apply delayed gradients. A local consistency guarantee therefore differs from asserting that the entire gradient was evaluated at one current global parameter vector. The paper’s optional vertical synchronization aligns versions across stages, but still applies delayed gradients and does not become GPipe-style accumulation. Version stashing consumes memory and needs retirement rules after every dependent backward and any checkpointed recomputation finish.
State the optimizer semantics being preserved
In a synchronous flush, all microbatch contributions for the intended update use the fixed parameter vector, are normalized correctly, and complete any required cross-replica reductions before the optimizer advances. That can match the chosen synchronous reference subject to random-state, batch-dependent-operation, and arithmetic assumptions. An asynchronous update can instead apply a gradient evaluated using older or stage-specific versions to newer parameters. Such an algorithm can be useful, but its convergence and quality must be evaluated as that algorithm rather than inferred from a throughput improvement.
The distinction also matters when recovering a checkpoint. A synchronous checkpoint at a drained update boundary can record one consistent optimizer state and data position. An in-flight asynchronous checkpoint may need weight-version tables, pending microbatch states, and update order to resume its exact semantics. Dropping those details can silently change the algorithm even if every parameter tensor reloads successfully. Record the schedule, version policy, and optimizer boundary in experiment metadata so an apparent numerical regression can be traced to its actual execution contract.
Use a tiny derivative as a version oracle
Choose a two-stage scalar model with an analytically known gradient, then deliberately change a parameter between forward and backward. Compare three cases: a valid fixed-version backward, an invalid mixed-version derivative, and a valid but stale gradient applied to newer state. These have different meanings even when a training loss happens to decrease in all three. Extend the test to checkpoint replay, which must use its matching parameter version as well as its matching random-state behavior.
The queue lab offers only an analogy for outstanding older work. Reset, set arrival rate to 3 and service rate to 3, predict backlog at one second, then Step twice: four units remain. Compare a fresh Reset with both arrival rate at 0 and service rate at 4 before two Steps: zero remain. The instrument contains no weights, version identifiers, derivatives, or optimizer updates. A drained fluid queue cannot certify that a real checkpoint or gradient is version-consistent.
Work it through
Stashing fixes one mismatch but not staleness
A two-stage scalar model is y = w₂w₁x with loss one half y squared, x = 1, w₁ = 2, and w₂ = 3 at forward time. Suppose w₂ becomes 4 before backward. Compare the required old gradient with a mixed-version derivative and the current-vector gradient.
The original forward gives y = 6. Its correct derivatives are dL/dw₁ = y × w₂ = 18 and dL/dw₂ = y × w₁ = 12.
Using the saved old y = 6 but the new w₂ = 4 would give upstream derivative 24, which does not differentiate the original forward. Retaining the matching old weight restores 18.
At the genuinely current vector (2,4), y = 8 and the gradients are (32,16). Applying the valid old gradient (18,12) there is still a delayed-gradient update, not ordinary current-gradient SGD.
Local version matching repairs derivative consistency; it does not turn an asynchronous delayed update into a synchronous one.
The living notebook
Explore the model
Interactive lab · queue
Outstanding work without parameter versions
Reset, set λ = 3 and μ = 3, predict Q at one second, then Step twice: Q = 4. Compare a fresh Reset with both λ = 0 and μ = 4 before two Steps: Q = 0. This fluid model has no weights or gradients and cannot verify version consistency.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. 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 forIn-flight work may outlive an update, so real implementations need version-aware state rather than backlog counts alone.
Pause & reason
Check your understanding
Your turn
Try it yourself
Use y = w₂w₁ with loss one half y squared. Forward uses (w₁,w₂) = (1,5), then w₂ becomes 6. Find the old correct gradient and the current-vector gradient. Explain why using old weights for backward is necessary but insufficient for current-gradient SGD.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The derivatives are y times the other weight at the vector being differentiated.
Compare with the solution
At (1,5), y = 5 and the gradient is (25,5). At (1,6), y = 6 and it is (36,6). Stashing the old version ensures the old forward is differentiated consistently, but applying (25,5) to the newer vector still uses a delayed gradient. Synchronous equivalence requires the intended common version and update boundary, not merely matching local version labels.
Keep the idea
Take it with you
- Forward state and the parameter version used to differentiate it must match.
- Local weight stashing does not imply synchronous current-vector SGD.
- Checkpoints and recomputation must preserve the schedule’s explicit version semantics.
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.