TorchTitan replaced selective activation checkpointing’s aten-level policies with torch_remat, which lets developers mark meaningful model-code regions for recomputation or retention. This avoids SAC’s TorchDispatchMode overhead and makes policies easier to understand and tune. Region boundaries are chosen by balancing recomputation cost against memory released: cheap operations that retain large tensors are good candidates to recompute, while costly operations with little memory benefit are better retained. A key complication is that distributed layers include collectives, whose placement changes which tensor layouts must remain in memory. TorchTitan therefore made previously implicit gathers, reduce-scatters, and MoE transitions explicit, so collectives could also be assigned regions.
Replay must preserve forward behavior. The integration skips auxiliary-loss counter updates during recomputation and keeps nondeterministic router top-k decisions fixed by retaining the routing region. Another challenge is that torch_remat lacks checkpointing’s early-stop optimization, which would otherwise skip trailing operations after all backward-needed tensors are produced. Replaying those operations can force extra inputs to be retained, making recomputation use more memory than saving. Marking trailing residual additions as always-saved regions avoids this: with every region saved, activation memory fell from 8.18 to 7.93 GiB on Qwen3 MoE and from 9.11 to 8.67 GiB on DeepSeek-V3 16B, using FSDP4 and EP4. Named regions also support comparing policies by peak memory and step time to identify Pareto-efficient configurations.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.