# Mission 9.3: Which model for the team laptop with 16 GB?

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-9-3

Belongs to [Chapter 9: Number formats and quantization](https://llm.yoga/en/09-quantisierung.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Jonas**, Development team lead:

> “We have a MacBook Air with 16 GB as our team laptop. We want a local model on it that helps with programming and reads long files, something like 32,000 tokens of context. I’d like the biggest one that works.”

Before a team sets up a laptop for local AI, they ask you which model fits on it. The answer depends on the memory and on the length of the context, that is, the amount of text in tokens (word pieces) the model keeps in view at once. qwen3 is a family of openly available models; the number gives the size in billions of parameters, the learned numbers. Q4_K_M and Q8_0 are levels of quantization: these numbers are stored with about 4 or 8 bits instead of 16. Three colleagues have made suggestions; the file sizes are from the library of Ollama, the program that runs the models. Decide before you calculate.

**Question 1 (decision):** Which suggestion do you recommend to Jonas?

- A) qwen3:14b in Q4_K_M (9.3 GB)
- B) qwen3:8b in Q8_0 (8.9 GB)
- C) qwen3:8b in Q4_K_M (5.2 GB)

## What’s behind it

On a Mac with 16 GB, not all 16 GB belong to the model. macOS, the browser and other apps need their share. Metal, Apple’s graphics interface, reports a recommended working set for the GPU, which performs most of the model computation. Apple doesn’t give a fixed percentage for this. For 8 and 16 GB the course cautiously calculates with about two thirds; on 16 GB that leaves about 10.5 GB for the model.

Three things have to fit in there: the weights, the KV cache and a buffer. The weights are fixed. The **KV cache** is a cache: for every token in the context, the model stores values so it doesn’t have to recompute what it has already read. So it grows with the context. For qwen3:8b it’s 144 KiB per token, so at 32,768 tokens about 4.8 GB, almost as much as the model itself.

That leads to the rules of thumb from chapter 10: on 16 GB, an 8B model is a reasonable starting point; suitable configurations can support 16,000 tokens or more. Models of 12B to 14B leave substantially less room for context. If you need more context, you can quantize the KV cache itself: Ollama can store it with 8 instead of 16 bits (format q8_0), which roughly halves it.

And Q8_0 instead of Q4_K_M? The qwen3:8b file then grows from 5.2 to 8.9 GB. That can fit on 16 GB with a short context. Closing apps frees some memory, but actual usage still needs to be checked.

If the GPU budget is insufficient, Ollama can execute parts on the CPU. This can substantially reduce generation speed.

### In more detail: the math for 32,768 tokens

Weights: 8.2 × 4.89 ÷ 8 = 5.0 GB. KV cache per token: 2 × 36 layers × 8 KV heads × 128 × 2 bytes = 147,456 bytes (144 KiB). Times 32,768 tokens: 4.8 GB. Overhead: 10 percent plus 0.5 GB, so 1.5 GB. Total 11.3 GB, more than the 10.5 GB. With the cache in q8_0 (simplified to 1 byte instead of 2, without scale overhead) it’s 2.4 GB of cache and 8.7 GB in total: it fits.

In Ollama you set the cache format at server startup with `OLLAMA_KV_CACHE_TYPE=q8_0`. This requires a supported backend with Flash Attention. Whether a model sits entirely on the GPU is shown by `ollama ps` in the PROCESSOR column.

## Try it

**Memory calculator with context**

**Task:** Jonas wants 32,768 tokens of context. Get qwen3:8b in Q4_K_M on 16 GB to “Should fit” without changing the model or the level. For comparison, also try qwen3:14b via “custom values” (14 billion, 40 layers, 8 KV heads, 128).

The calculator needs JavaScript. Result for the case: qwen3:8b in Q4_K_M with 32,768 tokens needs about 11.3 GB with the KV cache in f16 (just over the 10.5 GB), and about 8.7 GB with the cache in q8_0 (fits).

## Check

**Question 2 (check question):** Why does the course count on only about 10.5 GB for the model with 16 GB?

- A) Because memory must remain for the system and other apps.
- B) Because Ollama always uses only two thirds of the memory.
- C) Because just over 5 GB are permanently reserved for the context window.

**Question 3 (check question):** After an update, Ollama shows on the team laptop that the model runs 35 percent on the CPU and 65 percent on the GPU. What does that mean?

- A) All good, the work is nicely split between the two.
- B) Part runs on the CPU, which can slow generation down.
- C) The update is broken; Ollama should be reinstalled.

## Done

**What you can do now**

- You can explain why the course cautiously budgets about 10.5 GB for the model on 16 GB and uses 8B as a starting point.
- You’ve seen in the calculator how the KV cache grows with the context and how much you save by storing it with 8 instead of 16 bits.
- When a team wants “the biggest model that works”, you first ask how much context they need, and you include the KV cache in your math before recommending a model.

### Two cards for review

**Card 1:** True or false? “On a Mac with 16 GB, a model can use the full 16 GB.”

**Card 2:** A team wants to read files with 32,768 tokens using qwen3:8b on 16 GB. What gets tight, and what helps without changing the model?

- [Next mission: Ollama, LM Studio, llama.cpp or MLX?](https://llm.yoga/en/einsatz-10-1.md)
- [Try it on your Mac](https://llm.yoga/en/mac-9-3.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [The rule-of-thumb formula for memory](https://llm.yoga/en/09-quantisierung-3.md)
- [Which level pays off when](https://llm.yoga/en/09-quantisierung-3.md)
- [Chapter 10: Local models, table by memory size](https://llm.yoga/en/10-lokale-modelle.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is C.
- A: A 14B model, one with 14 billion parameters, only fits on 16 GB with a short context. With 32,000 tokens, about 5.4 GB of KV cache, the cache for the context, would come on top of the 9.3 GB of weights. That’s almost 15 GB even before any buffer.
- B: Q8_0 rounds more finely but uses more memory: 8.9 GB of weights leave hardly anything of the roughly 10.5 GB the course budgets for the model for 32,000 tokens.
- C, correct: An 8B model, one with 8 billion parameters, is a reasonable starting point for this comparison on 16 GB. For 32,000 tokens it still gets tight with the cache for the context; you’ll try out how to solve that in a moment.

**Question 2:** The correct answer is A.
- A, correct: Apple doesn’t give a fixed percentage. On my test Mac, the MacBook with 24 GB I measure on, Metal reported about 74 percent as the recommended GPU working set; for 8 and 16 GB the course cautiously calculates with two thirds.
- B: The two thirds are the course’s planning rule. macOS and other apps need memory; Metal’s recommendation is not a fixed fraction of physical memory.
- C: There is no fixed reserve for the context. The KV cache is part of what the model needs out of the roughly 10.5 GB, and it grows with the context length.

**Question 3:** The correct answer is B.
- A: This split can reduce speed because parts of the computation run on the CPU. It does not establish that the work is distributed efficiently.
- B, correct: Part is now computed on the CPU. If memory is the cause, possible fixes include: a shorter context, storing the KV cache with 8 bits, unloading other loaded models, closing apps or taking a smaller model.
- C: Reinstalling changes nothing about memory. The display establishes partial CPU execution. Memory pressure, for example after increasing context, is one possible cause; settings and runtime changes also need checking.

**Card 1:** **False.** macOS and other apps need memory too. For 16 GB the course cautiously budgets about two thirds, roughly 10.5 GB, for weights, KV cache and buffers. This is not a fixed hardware limit. Partial CPU execution can reduce speed.

**Card 2:** The KV cache: 144 KiB per token, about 4.8 GB at 32,768 tokens. At 8 instead of 16 bits (q8_0), the simplified calculation gives about 2.4 GB of cache and 8.7 GB in total, below the 10.5 GB planning budget. Actual quantization needs scale overhead and a supported backend with Flash Attention.
