TorchTitan integrates torch_remat for named-region activation checkpointing

Key point

The integration replaces aten-level policies with model-code regions, reducing peak activation memory by up to 0.44 GiB on DeepSeek-V3 16B.

1 / 7

Details

  • TorchTitan now uses torch_remat for activation checkpointing, replacing aten-level Selective Activation Checkpointing (SAC) policies with named regions defined directly in model code.
  • This change eliminates TorchDispatchMode overhead and allows users to control recompute policies for both compute operations and explicit collectives like all-gather and reduce-scatter.
  • Peak activation memory decreased from 8.18 to 7.93 GiB on Qwen3 MoE and from 9.11 to 8.67 GiB on DeepSeek-V3 16B when all regions are set to save.
  • The lack of early-stop optimization in torch_remat initially caused higher memory usage than stashing; wrapping trailing add operations in save regions fixed this and enabled a 24% performance improvement in specific MoE block scenarios.

Implementation Details

  • Collectives were made explicit in TorchTitan to allow remat regions, replacing implicit resharding logic.
  • Side effects like token counting and non-deterministic MoE routing are pinned during replay to ensure bitwise equality with the original forward pass.
  • A greedy approach is documented for finding optimal save/recompute configurations as the number of regions grows.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.