---
title: "Trading off compute for memory with activation checkpointing"
description: "A whole-graph activation checkpointing planner for torch.compile takes an absolute GB memory budget and greedily drops min-cut saves with the cheapest recompute cost per byte of peak memory freed."
url: "https://swe.quest/articles/trading-off-compute-for-memory-with-activation-checkpointing-1f2b8d13685e738d"
canonical: "https://blog.janestreet.com/trading-off-compute-for-memory-with-activation-checkpointing/"
source: "Jane Street Tech Blog"
published: "2026-09-30"
difficulty: "hard"
kind: "Case study"
reading_minutes: 9
tags: ["model-training","memory-management","compilers","performance","python"]
---

# Trading off compute for memory with activation checkpointing

A post on [Jane Street Tech Blog](https://swe.quest/sources/jane-street.md), published 2026-09-30, 9 min read, Case study. Original: [https://blog.janestreet.com/trading-off-compute-for-memory-with-activation-checkpointing/](https://blog.janestreet.com/trading-off-compute-for-memory-with-activation-checkpointing/)

## Summary

A whole-graph activation checkpointing planner for torch.compile takes an absolute GB memory budget and greedily drops min-cut saves with the cheapest recompute cost per byte of peak memory freed. Before training, a planning pass on fake tensors captures every graph, its min-cut save set and the execution order. Peak memory is simulated from tensor liveness across stacked forward and backward graphs, and recompute time is estimated from FLOP formulas. On single-graph models it beat PyTorch's memory-budget knapsack and op-level SAC policies for most budgets, avoided recompute-induced peak spikes, and still lacks support for dynamic shapes, data-dependent ops and RNG ops.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- backpropagation and autograd
- PyTorch torch.compile
- GPU memory-bound vs compute-bound kernels ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))

## Keywords

PyTorch, torch.compile, AOT Autograd, Inductor, Selective Activation Checkpointing, activation checkpointing

## Related posts

- [What the interns have wrought, special jumbo 2026 edition](https://swe.quest/articles/what-the-interns-have-wrought-special-jumbo-2026-edition-ccd1ba7feb2b1087.md): Jane Street Tech Blog · 2026-09-30 · Easy · 8 min read · Engineering culture, Machine learning, Linux, Performance engineering
  Jane Street's 2026 interns shipped projects across ML research, software engineering, Linux engineering, IT, trading desk operations and strategy.
- [Visualize and understand GPU memory in PyTorch](https://swe.quest/articles/visualize-and-understand-gpu-memory-in-pytorch-69d1cac2293ba761.md): Hugging Face · 2024-12-24 · Medium · 10 min read · Model training, Python, Memory management, Hardware, LLMs
  PyTorch's memory snapshot recorder (torch.cuda.memory.\_record\_memory\_history plus the memory\_viz web tool) makes it possible to see exactly where GPU memory goes during training: persistent parameters, activations that grow in the forward pass and shrink in backward, gradients, optimizer state and transient optimizer intermediates.
- [Make your ZeroGPU Spaces go brrr with ahead-of-time compilation](https://swe.quest/articles/make-your-zerogpu-spaces-go-brrr-with-ahead-of-time-compilation-51092e3d8eed121c.md): Hugging Face · 2025-09-02 · Medium · 13 min read · Inference & serving, Performance engineering, Compilers, Python
  PyTorch ahead-of-time compilation (torch.export plus AOTInductor) suits ZeroGPU Spaces, where each GPU task runs in a short-lived forked process and torch.compile's just-in-time caching costs tens of seconds to minutes per task.
- [GPU Memory Snapshots: Supercharging sub-second startup](https://swe.quest/articles/gpu-memory-snapshots-supercharging-sub-second-startup-14c07f765f85f384.md): Modal · 2025-07-30 · Medium · 6 min read · Serverless, Inference & serving, Hardware, Performance engineering
  Modal's GPU memory snapshots extend its gVisor-based checkpoint/restore to capture GPU state, using NVIDIA's new CUDA checkpoint API (driver branches 570/575) to lock CUDA processes, copy device memory, kernels, streams, contexts and memory mappings to host memory, then snapshot CPU and GPU state together.
- [Profiling in PyTorch (Part 1): A Beginner's Guide to torch.profiler](https://swe.quest/articles/profiling-in-pytorch-part-1-a-beginner-s-guide-to-torch-profiler-de0c791495fa22c4.md): Hugging Face · 2026-05-29 · Medium · 27 min read · Performance engineering, Machine learning, Python, Debugging
  torch.profiler produces two artifacts: a statistical table showing where time goes and a Chrome/Perfetto trace showing when CPU and GPU events happen.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
