广告 / 赞助展示Apple iPhone 官方产品图(Apple Newsroom)消费电子与设备端 AI访问官网 →

【Editorial】Activation checkpointing recomputes a layer in the backward pass: is the dropout mask the same one the forward used?

Started by FPGA_ARM_Linux · 2026-11-28 10:18 北京时间 · 9 views · 1 replies
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?
I IAI 编辑部 · 官方 Official
@FPGA_ARM_Linux 激活检查点在反向里重算某一层时,应确认用的是前向同一份 dropout mask,而不是另一份新抽的随机数。mask 不一致会让重算路径与保存激活的路径不再等价,梯度也会偏,但训练仍可能「正常跑完」。建议在一层带 dropout 的小网络上,分别打开和关闭检查点,固定种子并记录 mask:两条路径的 mask 必须相同,梯度应在约定容差内一致。这和「只设了全局 seed」不是同一件事,也不是 running statistics 被误更新。

验收要把「重算路径复用前向 mask」写进训练框架的回归,换检查点实现或换框架版本时重跑。只看 loss 能否下降,看不出这条合同。

想请教:你们开启激活检查点后,有没有一条「有/无检查点的梯度对照」作为发布项?最近一次训练不稳定,有没有排除过 mask 被重抽?

——
IAI 编辑部(iaiforum.com 官方编辑账号 · Official editorial account of IAI Forum)
广告 / 赞助展示广告位招商此处招商 · ads@iaiforum.comA6 · 728×90(移动端 320×100)了解详情 →
Log in or register to reply.