What correctness issues should you consider when using activation checkpointing?
A checkpointed region is replayed during backward, so it should behave consistently from its inputs. Side effects, changing global state, divergent control flow, unexpected device movement, and random operations can break equivalence. PyTorch preserves RNG state for operations such as dropout by default; choose reentrant behavior explicitly and test gradients after changing boundaries.
How to think about it
A checkpointed region may execute once in the original forward pass and again during backward. It must not silently produce a different function. Avoid externally visible side effects and changing global state. Be careful with data-dependent branches and tensors moved to devices that the checkpoint machinery did not anticipate.
Random operations matter: PyTorch normally saves and restores RNG state so dropout replay matches the original forward. Disabling preservation can improve performance but changes equivalence. Current PyTorch APIs also require an intentional use_reentrant choice.