Boss lesson · Unit 01
Will it fit?
Size a model, its caches and its users against a memory budget
What you practise
- Weights as parameters × bytes, plus the KV cache for a context length and a batch
- Size a model against a memory budget and say what to cut first
Try a question from this lesson
Pick one
A 14 GB model runs fine for one short chat on a 24 GB device, then dies with "out of memory" when 30 users hold long chats. What filled the memory?
Correct answer
The KV caches of all the conversations in flight
Why
Weights are fixed and shared by every request. What grows is the KV cache: a slice of memory for every token of every active conversation. Thirty long chats can need more memory than the model itself.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
The memory bill
Three things share the memory of the device.
Weights are a fixed cost, paid once and shared by every request. The KV cache grows with every token of every conversation in flight. Working memory for the pass itself is small by comparison but never zero: leave a margin.
weights params x bytes fixed
KV cache per token in flight grows
working one pass at a time small11 more exercises in the app
- 5× type the answer
- 1× fill the blanks
- 2× multiple choice
- 1× true or false
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.