Q4_K_M and Q8_0 on CPU

Meta Llama-4-Maverick is a 128-expert MoE with around 17B active parameters per token.

On EPYC 9175F with 768GB DDR5, I compared Q4_K_M at roughly 290GB with Q8_0 at 426GB on the same tasks. The LLM integration choice balances batch throughput with coding quality.

I measured Llama-4-Maverick-17B-128E-Instruct through llama.cpp, using CPU and RAM rather than fitting it into GPU VRAM.

EPYC Zen 5 / Turin provides 12-channel DDR5 and large L3 for sparse-model CPU inference, including trillion-scale model proposals.

Objective

  1. Compare Q4_K_M and Q8_0 Prefill/Decode speeds on identical hardware
  2. Quantify TTFT (Time To First Token) difference
  3. Evaluate output quality difference on practical tasks
  4. Establish selection criteria for batch processing vs aider workflows

Test Environment

ItemSpecification
CPUAMD EPYC 9175F (Zen 5, 16C, L3 512MB)
MemoryDDR5-6400 768GB (12ch)
GPUNot used (CPU inference)
OSUbuntu 24.04 LTS
Runtimellama.cpp server (Podman rootless)
Threads14
Context16,384

Fourteen threads on 16 cores leave OS and network IO headroom while considering bandwidth saturation.

Model Specifications

ItemQ4_K_MQ8_0
ArchitectureLlama-4-Maverick (MoE, 128E)Same
Model Size~290GB~426GB
Quantization4-bit mixed8-bit

Results

Speed Comparison

MetricQ4_K_MQ8_0Delta
PP(tok/s)65-6850-52Q4 ~30% faster
TG(tok/s)21-2415-16Q4 ~40% faster
TTFT (800-1000tok)12-17s16-20sQ4 3-5s faster

Q4_K_M Measurements

Prompt(tok)PP time(s)PP(tok/s)Gen(tok)TG(tok/s)
81912.068.416523.7
1,10116.865.481421.3

Q8_0 Measurements

Prompt(tok)PP time(s)PP(tok/s)Gen(tok)TG(tok/s)
81915.652.410416.6
1,00019.750.891615.2

Memory Behavior

  • Q4_K_M: mmap + page cache loads only needed portions. Prompt cache ~180-380 MiB per entry
  • Q8_0: Hundreds of GB in buff/cache. RSS appears small (normal mmap behavior)
  • MoE (128E): only active experts are frequently accessed; unused pages stay cold

mmap and page cache load weights. Hundreds of GB can appear in free buff/cache while RSS remains small; this is normal for llama.cpp.

128E accesses active experts repeatedly, while unused pages stay cold.

Analysis

Speed Gap Explained

Q4_K_M is roughly 68% of Q8_0 size (290GB versus 426GB). Smaller weights reduce per-token memory reads.

TG differs by 40% versus a 32% size gap. The interpretation is that random decode access amplifies cache misses and memory latency.

Quality Difference in Practice

Q8_0 felt better at:

  • Retaining long conversation context
  • Avoiding destructive aider edits
  • Producing output I could rely on

The difference was smaller for scaffolding and summaries. Q4_K_M rarely made critical mistakes in aider code or document scaffolds here. Complex repository work and long output showed more difference. This was a qualitative judgment, not a scored quality test.

Why Q8_0 Is Viable on 768GB RAM

With 768GB, Q8_0 at 426GB plus KV and page cache can fit. This choice depends on the available capacity.

Selection Criteria by Use Case

My use-case choices:

  • High-throughput oneshot generation, Dagster/dbt batch: Q4_K_M. 40% speed difference compounds over volume
  • Aider workflows, complex repo operations, long-form: Q8_0. Reduced destructive edit risk outweighs speed loss
  • Daily on/off operation: Q4_K_M. Faster startup
  • Always-on resident: Q8_0. Quality stability pays off over long sessions
  • Local knowledge processing: Both work for structuring/distilling sensitive internal data locally

Q8_0 reached 15-16 tok/s in this 128E CPU setup.

I favor Q8_0 for quality-sensitive work and Q4_K_M for high-turnover tasks.

Reproduction Steps

Q4_K_M

  podman run --rm -it \
  -p 8081:8080 --shm-size 16g --cap-add=SYS_NICE \
  -v "$MO":/models:ro,Z $IMG \
  --host 0.0.0.0 --port 8080 \
  -m /models/Llama-4-Maverick-17B-128E-Instruct-Q4_K_M.gguf \
  --jinja -c 16384 \
  --threads 14 --threads-batch 14 \
  -b 1024 -ub 256 \
  --parallel 1 --flash-attn on
  

Q8_0

Use the same command with the Q8_0 file.

Technical Notes

MoE mmap Behavior

Repeated topics reuse experts and warm mmap page cache. Frequent topic changes tend to increase page faults.

Prompt Cache

Both support LCP similarity prompt caching. Fixed System Prompts shorten TTFT on later requests.