Module 7 · Running it: memory, speed and money

Will it fit: the memory budget of a running model

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 2 of 10 in this chapter

This chapter’s goalPredict the tokens-per-second a given model will produce on a given machine from memory bandwidth alone, say whether a model and context will fit in a stated amount of memory, choose a quantisation level and defend it with a measurement, estimate the cost of a token from a GPU’s hourly price, and explain the trade an alternative architecture is making.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
The same 24-gigabyte card, twicebf16 weights: 16.0 GBLoaded once and shared by every user on the cardFramework overhead: 0.5 GBThe runtime takes a few hundred megabytes simply toexistLeft for cache: 7.5 GB, about 57,000 tokensAt 131 KB a token: three 32,000-token conversations,and the fourth failsFour-bit weights instead: 5.0 GBSame model, about 0.6 bytes a parameter once thegroup scales are countedLeft for cache: 18.5 GB, about 140,000 tokensQuantise the cache to 8-bit as well and it is280,000: the card now serves eightThe weights are a fixed cost and the cache is the variable one, so the concurrency a card can affordis free memory after the weights load, divided by the per-token cache cost. That division is a betterguide than anything printed on a model card.
The weights are a fixed cost and the cache is the variable one, so the concurrency a card can afford is free memory after the weights load, divided by the per-token cache cost. That division is a better guide than anything printed on a model card.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

Four line items

“Will it fit?” has an answer you can compute before downloading anything. Four things occupy memory when a model runs, and you can estimate each.

Weights. Parameters times bytes per parameter. Two bytes in bf16, one in int8, and about 0.55 to 0.6 at four bits once the scales that the next lesson explains are included. An 8-billion-parameter model is 16, 8 or roughly 5 gigabytes.

The key-value cache. Module two gave the per-token formula (two, times layers, times key-value heads, times head dimension, times bytes) and the result of 131 kilobytes per token for that 8-billion model in bf16. Multiply by the context length, and again by the number of sequences being served at once.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the AI, Actually Explained exam.

Stuck on something?Ask Anjali, your AI tutor

How to cite: Addaly (2026) ‘Will it fit: the memory budget of a running model’, in How a Language Model Actually Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/how-llms-work/will-it-fit (Accessed: 29 November 2026).