Skip to content

llama.cpp b12191 vs tandem.cpp: expert cache

We compared llama.cpp b12191's expert cache with our tandem.cpp port on an RX 9070 XT, with Qwen3.8 Flash Next. Results, and the key: pinning memory.

A day after we ported tandem.cpp to AMD, llama.cpp merged its own expert cache. We tested both on the same RX 9070 XT with 16 GB, with the same short test. On this machine, our port was about 40% faster and the official one was steadier. Neither reached Strata, and what mattered most for both was pinning memory.

  • tandem.cpp, our port: 45.45 tok/s on average with pinned memory, over 5 runs ranging from 34.96 to 53.43.
  • llama.cpp b12191: 32.56 tok/s on average with pinned memory, over 3 runs ranging from 31.89 to 33.51.
  • Pinned memory: lifted tandem by about 30% and llama.cpp by about 36%.
  • It's a short test, with few runs, on a single machine. It doesn't measure sustained speed or answer quality.

The problem

Qwen3.8 Flash Next, in the Swift IQ3_S build we use, weighs 79 GiB, and about 47 GiB of that is experts. It doesn't fit on a 16 GB card. The idea tandem.cpp and the official cache share is to keep the experts in RAM and use free VRAM as a cache for the most used ones.

Two paths

tandem.cpp. It's a patch on top of llama.cpp, by ewhacc, that only supported NVIDIA. We ported it to AMD and wrote about it in tandem.cpp on AMD: we ported it, but it didn't win. The port is on GitHub, as experimental. Its author reports 97.3 tok/s on an RTX 4090, against 29.8 for llama.cpp without a cache. Those are the author's figures; we didn't reproduce them.

llama.cpp's official cache. On November 7, llama.cpp merged PR #30966, by Aman Gupta, which shipped in release b12191. According to its documentation:

  • `--moe-cache-mib` sets the cache size.
  • `--moe-cache-cpu-share` computes a share of the cache misses on the CPU instead of uploading them to the GPU.
  • The `moe-cache-tune.py` script starts the server 6 times and recommends the values.

A SimplyExplain video presented it as "llama.cpp Just Made Your GPU 2x Faster on Big Models". In the PR thread, a user on ROCm reported going from 8 to 16 tok/s against the previous llama.cpp version, with another model, another card and an earlier version of the PR. Those are that user's figures, not ours.

What we found testing the official one

  • It ran on ROCm with no code changes, and with MTP.
  • The tuner fails with a draft model (MTP). It reads the free memory reported by the draft, which loads later, and concludes there's no room. We fixed it in a local copy.
  • It recommended a 5,376 MiB cache and nothing computed on the CPU.

These are the tuner's 6 runs, with pinned memory. It uses its own prompt and temperature 0.8, so it isn't the same test as the results table.

Cache, MiBCPU sharetok/sHits
4,736024.671%
4,7360.523.570%
4,7360.9520.761%
5,376023.272%
5,3760.525.868%
5,3760.9523.558%

Computing misses on the CPU gave no clear gain. The documentation anticipates this: with pinned memory, the GPU uploads experts at the full speed of the link. The tuner estimates about 40.5 ms per token outside the experts, which is why changing the cache size barely moved the speed. We didn't identify what consumes that time.

Result

Same model, MTP with 3 drafts, 3,000 tokens, a 32,768 context and seed 42.

EngineExpert memoryRunsAverage, tok/sRange
llama.cpp b12191Unpinned124.01One run
tandem.cpp, our portUnpinned434.8528.73 to 40.62
llama.cpp b12191Pinned332.5631.89 to 33.51
tandem.cpp, our portPinned545.4534.96 to 53.43
  • tandem was about 40% faster than the official cache with pinned memory (45.45 against 32.56), on this machine and with this test.
  • The official one was much steadier between runs.
  • tandem's draft options (`--spec-draft-sampling probabilistic -bs`) didn't change the official one: 31.41 and 33.85 tok/s.
  • MTP did help the official one: without MTP it gave 24.26 tok/s.
  • One of tandem's five pinned runs, the 51.58 tok/s one, was done with detailed logging, which can affect speed.

A reference, not a comparison: Swift on Strata 0.2.10 gave 66.26 tok/s sustained over our 49-task battery, with a 262,144 context. It isn't the same test, so it doesn't tell us how much faster it is. Strata is still the engine we use for Flash Next on this card.

The lesson for AMD owners: pin the memory

Pinning memory keeps the experts in a region the GPU can read directly. On AMD it was what mattered most, on both engines.

1,400 KiB copy to the GPUQueuing, medianTotal speed
From unpinned memory82.1 µs17.60 GB/s
From pinned memory (`hipHostRegister`)0.7 µs25.74 GB/s

From unpinned memory, the copy blocks the thread that queues it. In tandem, that made planning take up about half the time; with pinned memory it dropped to 2-6%.

  • In llama.cpp: the documentation says experts are pinned with `-lm none`, `-lm mlock` or `-lm dio`, but not with the default mode, which maps them from the file. We used `-lm none`.
  • In tandem: pinning is the default, but on AMD it didn't work until we fixed the backend name in the port, since under ROCm it isn't "CUDA".

What this doesn't let us conclude

  • That tandem or llama.cpp is faster or slower than Strata on the same task.
  • That the official cache doubles speed on this machine: we didn't measure the same engine without a cache.
  • Anything about answer quality: we didn't run the battery.
  • Anything about sustained speed, large contexts, Vulkan or other AMD cards.
  • That the tandem port is correct in every case: its compute matched the original in a limited test.

How we measured

  • Test machine: RX 9070 XT with 16 GB, on ROCm 7.2.4; Ryzen 7 5700X with 8 cores and 16 threads; and 94 GB of RAM. One model at a time, with the CPU capped at 80% and the desktop in normal use.
  • RAM: the roughly 47 GiB of experts stay in RAM. With pinned memory, available RAM dropped to between 21.9 and 26.6 GiB during the runs.
  • Model: Swift 1.5 Qwen3.8 Flash Next GSQ-RCO abliterated IQ3_S, in the GGUF build by slider-meister-pub, based on ukisai's Swift1.5-Qwen3.8-Flash-Next.
  • MTP: ewhacc's head, with 3 drafts.
  • Test: a fixed programming prompt, 3,000 tokens, seed 42, temperature 1.0, top_p 0.9, top_k 20 and medium reasoning. Each run loads the server from scratch.
  • Each engine as its author recommends: tandem with the automatic cache, `--spec-draft-sampling probabilistic` and `-bs`; llama.cpp with what its tuner chose, `--moe-cache-mib 5376 --moe-cache-cpu-share 0`.

Frequently asked questions

Which is better on AMD, tandem or the official cache? On this machine, tandem was faster and the official one steadier. The official one is backed by the project and will be maintained; our tandem port is experimental.

Which setting gives the most speed? Pinning the experts' memory. In llama.cpp, with `-lm none`.

Does computing misses on the CPU help? On our machine it gave no clear gain, and the tuner recommended not using it.

Does it beat Strata? We can't tell from this test. As a reference, Strata sustained 66.26 tok/s in another, longer test, and it's still our engine for this model.

Sources

Keep reading

Contact

If your organization is considering local AI, ITLab can help you size the hardware and test models and engines on your real cases. Contact us.

Do you need someone to take care of your technology?

Tell us what you need to organize, protect or solve. The first conversation has no cost: we assess whether our model fits you and what the next steps would be.

Let's talk about your business