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 sizeFeels like
8K0.5 GB2.1 GBChat, documents
32K2.1 GB8.4 GBLong code, big docs
128K8.4 GB33.6 GBBook-length context
262K16.8 GB67 GBNative 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_ctx in Ollama or -c in 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 -1M variants), 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.
The trade triangle: for a fixed GPU you pick two of {model size, quant level, context length} โ€” the third is determined by math. Most people should fix model size (biggest that fits), then split the remaining VRAM between quant and context according to what the task actually needs.

Step 3 โ€” Pick the biggest model that fits, then the quant

Your hardwareQwen3.8-27B recommendationOr step up/down
8 GB GPUNo โ€” too small for 27BQwen3-8B at Q4_K_M (~5 GB), or 27B IQ1/IQ2 (miserable)
12 GB GPUIQ2_S / IQ2_XXS (8.4 / 7.3 GB)Or a 14B at Q4_K_M for reliability
16 GB GPUIQ3_XXS (10.9) or UD-Q4_K_S (15.4)Or 14B at Q5/Q6
24 GB GPUUD-Q4_K_M (16.5) โ€” the sweet spotUD-Q5_K_M (19.8) with modest context
32 GB GPUUD-Q5_K_M or UD-Q6_K (22.0)Q8_0 (29) if you value near-lossless
48 GB+Q8_0 (29) + huge contextOr a 70B-class at Q3/Q4
Mac 16 GB unifiedNo โ€” 27B won't fit at 4-bitQwen3-8B MLX 4-bit
Mac 32 GB unifiedMLX 4-bit (fits with room)MLX 8-bit for quality
Mac 64 GB unifiedMLX 8-bit, comfortablyQwen3-32B-class at 4-bit
CPU-only, 16 GB RAMNo7-9B at Q4 (slow but works)
CPU-only, 32+ GB RAMQ4_K_M (16.5) โ€” expect single-digit tok/sIQ3 for speed, or accept the wait

Step 4 โ€” Pick the ecosystem (this decides the format)

ToolFormatGood for
OllamaGGUFEasiest possible start; one command to run
LM StudioGGUF, MLX, AWQGUI, per-model settings, local server
llama.cppGGUFPower users, scripting, MTP support
ExLlamaV3EXL3Maximum single-GPU speed
vLLM / TGIAWQ, GPTQ, FP8, NVFP4, QATServing many users / high throughput
mlx_lmMLXApple Silicon
transformers + bitsandbytesnf4/fp4 on the flyScripts, 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.

Golden rules recap: 1) biggest model that fits, 2) highest quant that fits, 3) Q4_K_M (or UD-Q4_K_M) is the default, 4) calibrated quants beat naive ones, 5) format follows software, 6) if it feels dumb, A/B the same model at Q6/Q8 before jumping models โ€” the quant may be the culprit, 7) context and thinking mode eat your headroom before the weights do.
Hardware? VRAM/RAM Apple/CPU? โ†’ Budget? file ร— 1.2 + ctx โ‰ค memory โ†’ Pick quant Q4_K_M default IQ/UD when tight โ†’ Test 5 prompts, A/B if in doubt

🧠 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:

Further Reading