Lesson 8: Choosing for Your Machine
Lesson 8: Choosing for Your Machine
Time to make it personal. Here's the exact procedure I'd run to pick a local LLM โ using Qwen3.8-27B as the running example.
Step 1 โ Inventory your hardware
- GPU VRAM (the king): 8, 12, 16, 24, 32, 48 GBโฆ
- System RAM: matters for CPU offload and for CPU-only inference.
- Apple Silicon unified memory: Macs share one pool โ treat it like VRAM.
- CPU/GPU vendor: NVIDIA (everything works), AMD (ROCm โ GGUF fine, some formats less), Apple (MLX/Metal), Intel (GGUF, slower).
Step 2 โ Budget memory: file + context + overhead
VRAM needed โ model file + KV cache + ~1-2 GB overhead. Rule of thumb: multiply the file size by 1.15-1.35 for a safe context budget. Qwen3.8-27B's hybrid architecture (Gated DeltaNet linear attention) keeps its KV cache unusually small, but long contexts and thinking-mode outputs still eat memory. Bigger context = more KV, always.
Context window: the silent VRAM eater
The context window is the maximum number of tokens the model can see at once โ Qwen3.8-27B ships with 262,144 tokens natively, extensible to ~1M. But context is not free: every token of history must be stored in the KV cache (the key/value activations attention needs), and that cache lives in VRAM for the whole session.
The math: KV โ 2 (K and V) ร attention layers ร KV heads ร head dim ร 2 bytes, per token. Qwen3.8-27B is a hybrid โ only 16 of its 64 layers use classic attention (the rest are linear-attention DeltaNet layers with a fixed-size state, no growing cache). That works out to ~64 KB per token, about 4ร cheaper than a same-size pure transformer:
| Context (tokens) | Qwen3.8-27B KV (hybrid) | Pure transformer, same size | Feels like |
|---|---|---|---|
| 8K | 0.5 GB | 2.1 GB | Chat, documents |
| 32K | 2.1 GB | 8.4 GB | Long code, big docs |
| 128K | 8.4 GB | 33.6 GB | Book-length context |
| 262K | 16.8 GB | 67 GB | Native max |
What this means when choosing:
- Match context to your longest real task โ not the model's maximum. Paying KV for 128K you never use is wasted VRAM that could have bought a higher quant.
- Cap it in your runtime: set
num_ctxin Ollama or-cin llama.cpp to what you actually need โ many tools default to 4K-8K context even when the model supports more, which is often exactly right. - Context is a dial you trade against quant: same GPU, same model โ want 128K context? Drop Q4_K_M to Q4_K_S or an IQ quant to free the 6-8 GB. Want max quality? Trim context instead.
- Thinking mode and agents burn context fast: reasoning tokens count against the same budget; Qwen recommends a 262K reasoning allowance inside the 1M window for agentic work. Long-horizon tasks are the #1 reason to buy more context.
- Native beats extended: models can stretch beyond native context via RoPE scaling (YaRN/NTK โ the
-1Mvariants), but quality degrades as you stretch. Prefer a model whose native context covers the task. - KV can be quantized too: llama.cpp can store the cache at 8-bit or 4-bit (
-ctk q8_0 -ctv q4_0), roughly halving or quartering the numbers above for a small quality cost โ handy when context is the bottleneck.
Step 3 โ Pick the biggest model that fits, then the quant
| Your hardware | Qwen3.8-27B recommendation | Or step up/down |
|---|---|---|
| 8 GB GPU | No โ too small for 27B | Qwen3-8B at Q4_K_M (~5 GB), or 27B IQ1/IQ2 (miserable) |
| 12 GB GPU | IQ2_S / IQ2_XXS (8.4 / 7.3 GB) | Or a 14B at Q4_K_M for reliability |
| 16 GB GPU | IQ3_XXS (10.9) or UD-Q4_K_S (15.4) | Or 14B at Q5/Q6 |
| 24 GB GPU | UD-Q4_K_M (16.5) โ the sweet spot | UD-Q5_K_M (19.8) with modest context |
| 32 GB GPU | UD-Q5_K_M or UD-Q6_K (22.0) | Q8_0 (29) if you value near-lossless |
| 48 GB+ | Q8_0 (29) + huge context | Or a 70B-class at Q3/Q4 |
| Mac 16 GB unified | No โ 27B won't fit at 4-bit | Qwen3-8B MLX 4-bit |
| Mac 32 GB unified | MLX 4-bit (fits with room) | MLX 8-bit for quality |
| Mac 64 GB unified | MLX 8-bit, comfortably | Qwen3-32B-class at 4-bit |
| CPU-only, 16 GB RAM | No | 7-9B at Q4 (slow but works) |
| CPU-only, 32+ GB RAM | Q4_K_M (16.5) โ expect single-digit tok/s | IQ3 for speed, or accept the wait |
Step 4 โ Pick the ecosystem (this decides the format)
| Tool | Format | Good for |
|---|---|---|
| Ollama | GGUF | Easiest possible start; one command to run |
| LM Studio | GGUF, MLX, AWQ | GUI, per-model settings, local server |
| llama.cpp | GGUF | Power users, scripting, MTP support |
| ExLlamaV3 | EXL3 | Maximum single-GPU speed |
| vLLM / TGI | AWQ, GPTQ, FP8, NVFP4, QAT | Serving many users / high throughput |
| mlx_lm | MLX | Apple Silicon |
| transformers + bitsandbytes | nf4/fp4 on the fly | Scripts, fine-tuning (QLoRA) |
Step 5 โ Test before you commit
Run the same short prompt suite on the candidate: one math question, one coding task, one instruction-following task, one creative task. Watch for: gibberish or repetition (too-low quant), refusal loops (wrong fine-tune), slow token rates (too big), and context truncation (too small). Then ask: would a comfortably-fitting smaller model have felt better? โ that's the question that ends most upgrade loops.
🧠 Knowledge Check
1. A 24 GB GPU running Qwen3.8-27B should pick:
2. VRAM needed โ model file + โฆ
3. You find a 27B Q4 model 'feels dumb'. Next step:
4. The KV cache (context memory) for a 27B hybrid model at 32K context is roughly:
5. You want 128K context on a 24 GB GPU with a 27B. The smart move: