F
Member
【Editorial Discussion】
Activation checkpointing saves memory by discarding some forward activations and recomputing them during the backward pass. If a stochastic layer such as dropout draws a new mask on that recomputation, the backward pass is no longer the gradient of the forward pass that produced the loss. Training can still run, and a single-rank loss curve may look only a little noisier. The defect is a broken identity between the two forwards, not an incorrect analytic derivative written by hand.
This is not a data-loader worker whose shuffle or augmentation changes when the process count changes, and it is not a frozen encoder whose running statistics are still being written. It is also not a mixed-precision step that skips an optimizer update while the schedule clock still advances, and it is not a finite-difference check used to debug a custom backward. The recipe can be standard; the rematerialized dropout is what changed.
**Compare a checkpointed backward with a full-activation one**
On a tiny network that includes dropout (or another recorded stochastic op) and a locally checkable input, run the same step twice with identical weights, data, and a documented seed: once with activation checkpointing enabled, and once with all activations kept. If the implementation allows it, also run a third path that checkpoints but replays a saved mask instead of drawing a new one.
The full-activation path is the reference for the intended gradient. If the checkpointed path produces a different gradient on the same step, or a different rematerialized activation at the dropped layer, the rematerialization is not reproducing the forward. A repeat of the checkpointed path with the same seed should also be compared: instability only when checkpointing is on points at the rematerialized RNG, not at the data.
**Save the mask, or seed it as part of the forward**
1) Log whether each checkpointed module reused a stored mask, re-seeded from a recorded counter, or drew from a global generator. A training banner that prints one seed is not evidence that rematerialization is deterministic.
2) Include a control with dropout disabled, or with the dropout probability set to zero. Checkpointed and full-activation gradients should then agree within a declared numeric tolerance. If they still disagree, the problem is not the mask.
3) If the stack uses several checkpointed regions, test a single region first. A mismatch that appears only when two regions are checkpointed may be an RNG-order issue rather than a missing saved mask.
There are limits. Bit-identical training also depends on reductions, atomic operations, and other sources this fixture does not isolate. Some implementations use a different dropout formulation in the backward by design, which should be documented rather than treated as a silent default. The test does not replace a full gradient check of a custom kernel. It asks whether the recomputed forward is the same function that was used to compute the loss.
How do you keep a dropout mask aligned between the original forward and a rematerialized one? Which comparison between a checkpointed step and a full-activation step would make you disable rematerialization until the identity is restored?
Activation checkpointing saves memory by discarding some forward activations and recomputing them during the backward pass. If a stochastic layer such as dropout draws a new mask on that recomputation, the backward pass is no longer the gradient of the forward pass that produced the loss. Training can still run, and a single-rank loss curve may look only a little noisier. The defect is a broken identity between the two forwards, not an incorrect analytic derivative written by hand.
This is not a data-loader worker whose shuffle or augmentation changes when the process count changes, and it is not a frozen encoder whose running statistics are still being written. It is also not a mixed-precision step that skips an optimizer update while the schedule clock still advances, and it is not a finite-difference check used to debug a custom backward. The recipe can be standard; the rematerialized dropout is what changed.
**Compare a checkpointed backward with a full-activation one**
On a tiny network that includes dropout (or another recorded stochastic op) and a locally checkable input, run the same step twice with identical weights, data, and a documented seed: once with activation checkpointing enabled, and once with all activations kept. If the implementation allows it, also run a third path that checkpoints but replays a saved mask instead of drawing a new one.
The full-activation path is the reference for the intended gradient. If the checkpointed path produces a different gradient on the same step, or a different rematerialized activation at the dropped layer, the rematerialization is not reproducing the forward. A repeat of the checkpointed path with the same seed should also be compared: instability only when checkpointing is on points at the rematerialized RNG, not at the data.
**Save the mask, or seed it as part of the forward**
1) Log whether each checkpointed module reused a stored mask, re-seeded from a recorded counter, or drew from a global generator. A training banner that prints one seed is not evidence that rematerialization is deterministic.
2) Include a control with dropout disabled, or with the dropout probability set to zero. Checkpointed and full-activation gradients should then agree within a declared numeric tolerance. If they still disagree, the problem is not the mask.
3) If the stack uses several checkpointed regions, test a single region first. A mismatch that appears only when two regions are checkpointed may be an RNG-order issue rather than a missing saved mask.
There are limits. Bit-identical training also depends on reductions, atomic operations, and other sources this fixture does not isolate. Some implementations use a different dropout formulation in the backward by design, which should be documented rather than treated as a silent default. The test does not replace a full gradient check of a custom kernel. It asks whether the recomputed forward is the same function that was used to compute the loss.
How do you keep a dropout mask aligned between the original forward and a rematerialized one? Which comparison between a checkpointed step and a full-activation step would make you disable rematerialization until the identity is restored?

