Consistent checkpoint-cut selection
Choose a logical update boundary and preserve its causal dependencies before asynchronous serialization begins.
On this page
The question for today
What you’ll understand
- Explain a consistent cut using causal predecessors.
- Separate a shared logical step from wall-clock coincidence.
- Identify mutable buffers and in-flight work at a proposed checkpoint boundary.
A distributed checkpoint combines observations made by different processes. Those observations must describe one meaningful computation state, even if the bytes reach storage at different times. A common directory name or timestamp cannot guarantee that. Choose a logical cut in the training execution, explain which actions belong before it, and capture everything needed to resume from that cut without inventing an update that never happened.
A cut must respect causality
In a distributed execution, events are related by local program order and communication dependencies. A consistent cut includes the causal predecessors of every included event. The classic Chandy–Lamport snapshot formulation also accounts for channel state when messages cross the chosen cut. A training system often avoids capturing arbitrary in-flight channels by selecting a coordinated update boundary where required communications and updates have completed. That is an application design choice, not evidence that arbitrary per-rank memory dumps automatically form such a snapshot.
Suppose one rank saves parameters after update 101 while another saves an indispensable optimizer shard from update 100. Both local files may be individually well formed, yet their union is not the declared post-101 state. Checkpoint generation, optimizer-update number, accumulation position, and any relevant version tags should agree according to the chosen protocol. A barrier can coordinate process arrival, but it neither invents missing state nor necessarily completes unrelated asynchronous device work. Use the documented completion dependencies for the actual streams and operations.
Define a clean boundary for the actual loop
A practical boundary might be immediately after a successful optimizer update and the associated scheduler transition, with the next logical data cursor already defined. The precise order matters. If a scaler skips the optimizer update, an attempted-step counter may advance while the successful-update counter does not. Pipeline schedules may still hold activations for other microbatches, and an input pipeline may have read ahead. Either drain or represent that work under the contract. Calling every boundary an epoch checkpoint hides these differences.
Capture does not require all files to finish writing simultaneously. Once every mutable source has been copied into an immutable snapshot representing the agreed cut, writers may proceed at different speeds. Until that separation exists, an optimizer mutation or buffer update can race a slow copy and produce a mixture. Persistent buffers updated during forward execution deserve particular attention: model parameters being unchanged during backward does not prove every state-dictionary entry is unchanged. Identify writes to each category rather than assuming one global safe window.
Validate the chosen cut before optimizing its capture
Draw a short timeline showing update completion, scaler and scheduler actions, cursor advancement, staging, and the first subsequent mutation. Give each saved quantity a version from that timeline. Then inject a delay in one contributor and ask whether the version check fails or the protocol waits safely. A writer finishing late is harmless when it reads immutable captured state. A writer silently reading a newer live tensor is a correctness failure even if its resulting checksum and filename look plausible.
The modular instrument can expose version mismatch as a counting analogy. Reset, set both m=8 and a=1, predict residue two after two additions, then Step twice. Separately Reset, set both m=8 and a=1, predict residue three after three additions, then Step three times. Combining the two observations does not make them the same logical position. This deterministic counter does not model distributed messages or validate a checkpoint cut. Its wraparound also reminds you that a small repeating residue is insufficient as a unique generation identifier.
Work it through
Locate a mixed-version snapshot
Four required state contributors report completed update numbers 120, 120, 119, and 120. Training completes one update every two seconds. The last known complete earlier checkpoint is update 116.
The reports do not describe one post-120 state: the third contributor is still at 119. Selecting the largest report or a shared directory name cannot supply its missing update-120 state.
If the protocol can safely complete and capture that contributor at 120 while preserving all other captured versions, it can finish the intended cut. Otherwise this candidate must remain uncommitted; combining arbitrary 119 and 120 tensors is not a valid repair.
Falling back to the committed checkpoint at 116 loses four completed updates relative to 120. At the stipulated two seconds per update, the nominal recomputation is eight seconds, excluding restart, loading, input replay, and other overhead.
A rejected mixed candidate is preferable to advertising a state with no valid continuation semantics. Recovery falls back to a proven complete generation.
The living notebook
Explore the model
Interactive lab · modular
Logical versions must refer to one position
Reset, set both m=8 and a=1, predict residue two, then Step twice. Separately Reset, set both m=8 and a=1, predict residue three, then Step three times. This additive counter illustrates different positions only; it does not implement distributed snapshots, messages, or a unique checkpoint-generation service.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. 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 forA shared label or repeating counter value cannot replace a protocol for a consistent logical cut.
Pause & reason
Check your understanding
Your turn
Try it yourself
A forward pass updates a persistent running-statistics buffer while parameter tensors remain unchanged. May a checkpoint copier overlap that forward pass solely because weights are immutable?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Apply the source-lifetime rule to every saved category, not only parameters.
Compare with the solution
No. The buffer has its own mutation hazard and can be captured at a different logical version. The system must copy it before the write, wait for the appropriate completion, preserve a separate immutable version, or choose another valid boundary. A safe window for model weights is not automatically safe for all persistent state.
Keep the idea
Take it with you
- Select a causal, application-defined checkpoint boundary.
- A barrier or matching timestamp alone does not complete device work or capture all state.
- Serialize immutable captured versions even when writers finish at different times.
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.