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.

GradientNeedsCost
grad_ab, the weight, held anywaynothing extra
grad_ba, an activation that could be freed after this matmul128 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.

Predict

The weight b is frozen. Which input can the forward skip saving for backward?

Pick an answer above to see the rest
Predict

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