Case · On-device AI · Ternary MoE · 2014 iMac

A 20B model on a 2014 iMac, 1.9× faster than llama.cpp.

Maple-Preview is DeepGrove's 20B mixture of experts with ternary weights: only about 1B weights are read per token. Its official code needs CUDA. Working with an AI coding agent, I built a runtime for the machine at hand: an Intel CPU with AVX2 and an AMD Radeon from 2014. On the same iMac it writes 1.9× faster than DeepGrove's own llama.cpp fork, and with the prompt on the old Radeon it reads 4.4× faster.

0×
writing speed vs DeepGrove's llama.cpp fork, same iMac, 3 threads (29.4–30.8 vs 15.9 t/s)
0×
reading a 2,048-token prompt on the 2014 Radeon (321 vs 74 t/s)
0.7%
largest logit gap from a plain numpy reference; same top-1 and top-5 tokens
8of 256
experts read per token: ~1B of the 20B weights
How we got here

The reasoning, step by step.

I worked with an AI coding agent. I set the direction and the checkpoints; the agent wrote the converter, the runtime and the GPU kernels, and measured. Every speed-up had to match a plain numpy reference before it counted. The dead ends stay in the picture.

Me · direction
Agent · code, kernels, numbers
03.11 Question

A 20B model that reads only 1B weights per token. Can it run here?

The official code needs CUDA. The machine at hand: a 2014 iMac, i5-4690, 16 GB DDR3, Radeon R9 M290X with 2 GB.

"Let's build the runtime ourselves."

03.11 Build

A C runtime: 2-bit ternary weights times int8 activations.

The converter streams the 40 GB BF16 checkpoint into 5.8 GB. AVX2 multiplies 32 weights per instruction. Against a numpy reference: same top-1 and top-5 tokens, logits within 0.7%.

03.11 Measure

41.5 tokens/s writing; 89 together for 64 conversations.

The output head runs on the Radeon in BF16, one pass for a whole pack of conversations.

03.11 Decision

Micro-test the card before building anything into it.

Every GPU idea had to win a small benchmark first.

03.11 Dead end

Cache the experts on the GPU

Exact, but no faster: the card needs ~0.25–0.3 ms per layer just to answer, about what the CPU takes for all 8 experts.

04.11 Dead end

12 or 16 experts per token instead of 8

More weights per token, worse answers on an extraction test. The model was trained with 8.

06.11 Build

The whole prompt on the 2014 Radeon. The CPU only picks experts.

Norms, attention, projections and experts run on the card; the CPU chooses 8 of 256 experts per token in ~1 ms per layer. An 843-token prompt: 11.8 s → 2.7 s.

06.11 Measure

The experts are bound by arithmetic, not by the bus.

They run at 35–40% of the card's peak. Decoding the 2-bit codes in registers, 1.5 instructions per weight instead of 3: 6–7% faster.

06.11 Dead end

Copy the experts into VRAM first

8.7 GB/s over PCIe, but the kernels got only 9% faster. Two other kernel layouts ran 1.4× and 2.3× slower.

06.11 Evidence

Three threads beat four.

A video-capture service holds part of one core. A spinning pool of four waits for the worker that got pushed aside.

08.11 Decision

No claims before the same machine against llama.cpp.

DeepGrove's own fork and official GGUF, the same token counts, the same background load.

08.11 Measure

1.9× faster writing, 4.4× faster reading.

Fork 7e30f3a, TQ2_0 with an FP16 head, 3 threads. Writing: 29.4–30.8 vs 15.9 t/s. A 2,048-token prompt: 321 t/s on the card vs 73.7. On the CPU both read prompts at the same speed.

08.11 Ship

Code, benchmark script and raw log, public.

MIT, like the model.

Results

Faster than DeepGrove's own fork, on the same iMac.

8 Nov 2026. deepgrove-ai/llama.cpp at 7e30f3a with the official maple-preview-TQ2_0-head-F16.gguf; this runtime v1.2. Same token counts, 3 threads. A video-capture service used ~64% of one core during both runs.

Tokens per second

Higher is better
this runtime, prompt on the GPUthis runtime, CPUllama.cpp fork, CPU
Table view
3 threadsGPU promptCPUllama.cpp
Prompt, 2,048 tokens320.773.073.7
Prompt, 512 tokens184.678.678.0
Writing, 128 tokens27.7–31.529.4–30.815.9

With 4 threads, and a text check

The fourth core is shared with the capture service, so both get slower. On the CPU, llama.cpp reads prompts faster here.
4 threadsGPU promptCPUllama.cpp
Prompt, 2,048 tokens330.144.164.0
Prompt, 512 tokens187.951.468.2
Writing, 128 tokens15.9–19.116.8–19.68.8

Same raw prompt, greedy: both begin with "Rayleigh scattering." and then part ways. llama.cpp falls into a loop, this runtime keeps writing coherent text. That is a numerical difference after a few tokens, not proof that either is more exact.

How it works

Read only what the token needs.

Each token goes through 8 of 256 experts per layer. The weights are ternary: −1, 0 or +1.

01 · weights

2 bits per weight

The BF16 checkpoint is streamed and packed: 40 GB in, 5.8 GB out, memory-mapped at run time.

02 · CPU

int8 × ternary

Activations go to int8; maddubs on AVX2 multiplies 32 weights per instruction. Attention keeps an fp16 cache.

03 · GPU prompt

Every layer on the card

The hidden state stays in VRAM. The CPU only reads the router's logits and picks the 8 experts per token, ~1 ms per layer.

04 · kernels

Decode in registers

The 2-bit codes are read over PCIe straight from the mapped shards and unpacked in registers: 1.5 instructions per weight.

Working with an AI agent

Who did what.

Me

  • Picked the model and the bet: an old iMac and an AMD card as a real engine
  • Asked for a micro-test before anything went onto the card
  • Set the bar: the same tokens as a plain numpy reference
  • Asked for the same-machine comparison before any claim
  • Chose what to publish

Agent (Claude Code)

  • Wrote the converter, the C runtime and the Metal kernels
  • Ran the microbenchmarks and the layer-by-layer checks
  • Measured every version; kept the logs and the dead ends
  • Drafted the write-ups; I edit and publish them

Honest limits

  • A speed result, on one iMac. This page does not benchmark the model's quality.
  • Writing runs on the CPU; only the prompt runs on the GPU.
  • Greedy decoding only, one process per run, no server mode yet.
  • With 4 threads and the capture service running, llama.cpp reads prompts faster on the CPU (64 vs 44 t/s on 2,048 tokens).