Akarsh Jha
  • Writing
  • About
Categories
All (2)
from-scratch (1)
gpt-2 (2)
inference (1)
kv-cache (1)
memory (1)
pytorch (1)
training (1)

Writing

LLM systems, built from scratch and measured, not asserted.

Where training memory goes

I guessed that training GPT-2 would need about 1.5 GB of GPU memory. It needed 17. This is where the other 15.5 went.
training
memory
pytorch
gpt-2

A byte-by-byte account of one GPT-2 training step on an A40: weights, gradients, Adam, activations, and the four 1.5 GB tensors nobody warns you about.

24 October 2026
Akarsh Jha

1000× Less Math, 6× Less Time

I built GPT-2 and a KV cache from scratch, then went looking for where the time actually goes.
inference
kv-cache
gpt-2
from-scratch

A from-scratch KV cache for GPT-2 cuts the math per token by 1000× at long context. It makes each token only 6× faster. This post measures the gap and follows it to its source.

17 October 2026
Akarsh Jha
No matching items
 

© 2026 Akarsh Jha · built with Quarto