27/31
Part 6 of 6 · What interviewers ask nextLearn and do
Memory: forward keeps its inputs alive
FLOPs are half the cost. Memory is the other half.
| Gradient | Needs | Cost |
|---|---|---|
grad_a | b, the weight, held anyway | nothing extra |
grad_b | a, an activation that could be freed after this matmul | 128 MiB for one (8, 2048, 4096) bf16 |
a is an activation, an intermediate result that could otherwise be freed. Activations are where training memory goes, because every linear layer in every block saves one like it.
The weight b is frozen. Which input can the forward skip saving for backward?
Pick an answer above to see the rest
Save each block's input only, and rerun the block during backward. What does a training step cost now?
Pick an answer above to see the rest