AI Lab28 November 20267 min read

Local LLM MacBook test: a long prompt more than doubled the RAM, from 8.4 GB to 17.7 GB

Bar chart of peak memory for Gemma 3 12B 4-bit on a MacBook Pro M3 Pro 36 GB: 8.4 GB at 1k tokens, 9.4 GB at 5k, 10.0 GB at 9k, 11.1 GB at 17k, 13.1 GB at 33k and 17.7 GB at 65k tokens. The model found the hidden fact in all 6 prompts.
Peak memory of Gemma 3 12B (4-bit) on a MacBook Pro M3 Pro with 36 GB, by prompt length. One run per length. A tick means the model found the hidden code.

A post on X this week made me laugh. A customer at Best Buy asked if a Mac "would run a local model". The employee said he doesn't believe in AI, so he couldn't help. About 2,400 people liked it. The customer's question is a good one, though, and it deserves a real answer.

Most guides answer it with a table: 8 GB of RAM runs this model, 16 GB runs that one. Those tables look at the size of the model file. They skip the part that grows while you use it: the context. Every word of your chat, and every page you paste in, has to sit in memory too. So I measured how much.

How I tested a local LLM on my MacBook

I wrote the rules down before the first run.

The test script is about 80 lines of Python. It loads the model once, runs one warm-up prompt, then runs each length with a fresh cache.

How much RAM does a local LLM need on a Mac?

Here is every run:

Prompt lengthPeak memoryContext cache (KV)Memory above the modelFound the code?
1,334 tokens8.39 GB0.42 GB1.20 GBYes (4037)
4,565 tokens9.41 GB0.64 GB2.22 GBYes (4148)
8,574 tokens9.97 GB0.90 GB2.78 GBYes (4296)
16,584 tokens11.06 GB1.42 GB3.87 GBYes (4592)
32,609 tokens13.09 GB2.47 GB5.90 GBYes (5184)
64,798 tokens17.72 GB4.58 GB10.53 GBYes (6368)
Terminal-style output of the test script, one line per prompt length with peak memory, KV cache size, the model's answer and whether it was correct.
The raw numbers from the test script (results.csv), shown as the script printed them.

The model weights took 7.19 GB as soon as they loaded. That number never changed. Everything above it is the cost of the prompt.

Memory grew with every step. Going from about 1,300 to about 16,600 tokens added 2.7 GB. Doubling to about 32,600 tokens added 2 GB more. Doubling again to about 64,800 tokens added 4.6 GB more. At the longest prompt, the memory above the model (10.5 GB) was bigger than the model itself (7.2 GB).

So for this model, the rule of thumb is simple. Count the model file, add about 1 to 2 GB for short chats, and add more for long documents. At the long end of my runs, every extra 1,000 tokens of prompt cost about 0.14 GB.

Why does memory grow with a longer prompt?

Two things grow.

The first is the KV cache. For every token in the prompt, the model keeps a "key" and a "value" in each attention layer, so it does not have to redo that work for the next word. This is the memory of the conversation, and it grows with every token.

The second is working memory while the model reads the prompt. mlx-lm reads a long prompt in chunks, and each chunk has to look back at everything before it. That temporary space also grows with the length. In my runs it was 0.8 GB for the shortest prompt and 6 GB for the longest. At the longest prompt it was bigger than the KV cache itself (4.6 GB), which I did not expect.

This is why a "16 GB runs 12B models" table can be right and still leave you stuck. The model fits. A long chat on top of it may not, and macOS needs its own share of the same memory.

Why Gemma 3's cache stays small: the sliding window

The KV cache numbers surprised me. They were much smaller than I expected for a 12B model.

The reason is in the model design. Gemma 3 has 48 layers, but only 1 in every 6 looks at the whole prompt. The other 40 layers only look at the last 1,024 tokens: a "sliding window". The Gemma 3 technical report says Google designed it this way to cut KV cache memory at long context.

The numbers I measured match that design exactly. The 40 sliding layers use a fixed 0.34 GB, however long the prompt is. The 8 full layers add 64 KB for every token. (That is 8 layers, times a key and a value, times 8 heads of 256 numbers, at 2 bytes each.) For the 64,798-token prompt: 0.34 GB + 64,798 × 64 KB = 4.58 GB. That is the exact size I measured.

Now the comparison. If all 48 layers looked at the whole prompt, the same 65,000-token cache would need about 25.5 GB by the same math. That is my calculation, not a run, but it shows why the model design matters as much as the model size. With the sliding window, the cache was 4.58 GB.

Not every model works like this. Many models keep the full context in every layer. Before you trust a "fits in 16 GB" claim for long documents, check the model card for a sliding window, grouped-query attention, or a smaller KV cache, and test with your own longest prompt.

Can a 12B local LLM still find a fact in a long prompt?

Yes, in this test. The model gave the right code at every length, 6 out of 6, from about 1,300 to about 64,800 tokens. Each answer was just the number, as asked.

This is an easy test, to be fair. The hidden line looks different from the log lines around it, and the question names it exactly. A real document with many similar facts is harder. But it does show that the long context is usable, not just loaded.

Which MacBook do you need for a local LLM?

From this one model, here is how I would think about it. These are my estimates from the numbers above, not runs on other Macs.

Memory decides what runs. Speed depends on the chip's memory bandwidth, which is a separate question. For a related test, see how prompt caching helps a local model in long agent sessions.

Limits of this test

FAQ

Can I run a local LLM on a MacBook?

Yes. In this test, Gemma 3 12B at 4-bit ran on a MacBook Pro M3 Pro with 36 GB. The model took 7.2 GB, a short prompt peaked at 8.4 GB, and a 64,798-token prompt peaked at 17.7 GB.

How much RAM do I need for a local LLM on a Mac?

Count the model file, then add room for the context and for macOS. For Gemma 3 12B at 4-bit, peak memory was 8.4 GB for a short prompt, 13.1 GB at about 32,600 tokens and 17.7 GB at about 64,800 tokens.

Does a longer prompt use more memory in a local LLM?

Yes. The KV cache grows with every token, and so does the temporary memory used while the model reads the prompt. In this test, going from about 1,300 to about 64,800 tokens added 9.3 GB of peak memory.

Which MacBook is best for a local LLM?

Memory decides what you can run, so buy the most unified memory you can. Check the model size and your longest prompt: a 12B model at 4-bit fits on 16 GB for normal chats, but long documents need 24 GB or more.

Sources

TH

Written by Tabish Hassan, a software developer in Pakistan. 4+ years of production React and TypeScript, 75 iOS apps on the App Store. The tests on this blog run on my own Mac, with the method and limits shown.

Found a mistake or got different numbers? Email hello@tabishapps.com. Published 2026-11-28.