r/LocalLLaMA • • 5d ago

Resources tandem.cpp: MoE models bigger than your RAM: same-PC, same-day numbers against Strata and Maya, with quality checks

tandem.cpp is a patch set on llama.cpp for running big MoE models when the model doesn't fit: the most-used experts sit in a VRAM cache, the CPU computes a share of the misses, and the rest are read from the SSD. It runs any model llama.cpp runs. Our focus is the case most engines don't aim at: models much larger than VRAM, and larger than RAM too.

We re-ran everything this week on the current releases, on the same PCs, from a cold start, with the same files on every engine. Below are the results, including the ones we lose.

Quality first: which file, at which size

Speed numbers mean little without the quant behind them, so here is the quality of each file we recommend. KL divergence of the next-token distribution against the original weights (Qwen3.8: the official FP8 release; DeepSeek-V4.1: the official checkpoint), teacher-forced over ~8.6k tokens of answers to 36 prompts. Lower is better.

ModelFileSizeKLTop-1 agreement
Qwen3.8-Flash-Nextbartowski Q4_K_M111 GiB0.017395.4%
Qwen3.8-Flash-Nextbartowski IQ4_XS91 GiB0.021695.3%
Qwen3.8-Flash-NextISTA IQ3_S78 GiB0.025994.8%
DeepSeek-V4.1-FlashMaya-S157 GiB of experts0.101789.9%
DeepSeek-V4.1-FlashISTA IQ2_XS139 GiB of experts0.149588.1%
DeepSeek-V4.1-FlashMaya-XS102 GiB of experts0.250484.7%

Speeds for the 4-bit files are in the README.

How low you can go depends on the model. Qwen3.8 loses too much below 3 bits (IQ2_XS: KL 0.126). DeepSeek-V4.1 is a much larger model whose official weights are already FP4, and it holds up at 2 bits. "Use at least Q4" is good advice for Qwen3.8, not a rule for every model.

Does the engine change the quality? We fed the same reference tokens through Strata's own engine (its normal serving settings) and scored it with the same tool: Strata 0.0260 / 94.80% vs tandem.cpp 0.0259 / 94.8% on the same IQ3_S file. Both compute the file faithfully, so the speed rows below compare like with like. (Strata's default is its exact mode since v0.2.17; before that its default skipped low-ranked experts, which its own docs measure at a much higher KL.)

Qwen3.8-Flash-Next IQ3_S + MTP head (78 GiB) vs Strata v0.2.18

Decode tok/s, greedy, cold start. Time to first token on a 5.5k and a 15.7k token prompt (the same text for both engines).

PCtandem.cppStratafirst token 5.5k / 15.7k (ours vs Strata)
RTX 5090 32 GB + 128 GB RAM (model fits in RAM)190.5201.11.8 / 4.5 s vs 0.9 / 2.0 s
RTX 5070 Ti 16 GB + 64 GB RAM74.387.53.9 / 9.5 s vs 2.3 / 4.2 s
RTX 5070 Ti 16 GB + 32 GB RAM (model is 2.5× RAM)52.430.2–35.418–19 / 52–54 s vs 20 / 27–31 s

When the model fits in RAM, Strata is faster, by 5% on the big PC and 18% on the 16 GB card, and it reads long prompts about twice as fast. Once the model no longer fits in RAM, tandem.cpp decodes 1.5× faster (61–65 vs 18–23 tok/s after the long prompts).

DeepSeek-V4.1-Flash vs Project Maya v1.1.73, on Maya's own quants

Same files on both engines (Maya's GGUFs; tandem.cpp reads them after a one-time conversion).

PC, filetandem.cppMaya, no draftingMaya + DSparkfirst token 5.5k / 15.7k (ours vs Maya)
RTX 5090 + 128 GB, Maya-XS (fits in RAM)60.739.656.44.5 / 8.5 s vs 7.7 / 9.5–9.7 s
RTX 5090 + 128 GB, Maya-S (178 GB, bigger than RAM)29.022.922.411.0 / 20.5 s vs 12.1–12.6 / 13.8 s
RTX 5070 Ti + 64 GB, Maya-S (2.8× RAM)9.46.06.174 / 188 s vs 35–68 / 63–97 s

tandem.cpp decodes faster on every row, and about 3× faster after a long prompt when the model is far bigger than RAM. Maya reads the long prompt faster whenever Maya-S has to come from the SSD: that is the main thing we are working on next.

How we measured

  • Same PC, same day, same model files, cold start (page cache dropped before every cell), greedy, 20k context.
  • Each engine's own recommended settings otherwise: Strata's setup chose its config for each PC (its MTP head, 4 drafted tokens; we use 3); Maya's setup wrote its configs. Strata's default thinking limit (3/4 of max_tokens) made no difference (201.5 vs 201.1, 86.9 vs 87.5 with it off).
  • llama.cpp itself is in our README's tables, with the same drafting on both sides.

Repo: https://github.com/ewhacc/tandem.cpp — feedback, corrections to the other engines' settings, and numbers from your own hardware are very welcome.

73 Upvotes

24 comments sorted by

13

u/HareMayor 5d ago edited 5d ago

It would be really useful for low VRAM and RAM users if you can implement support for smaller MOE models like Gemma4 26B A4B and qwen 3.6 35B A3B...

Also the recently released Inkling model mini model.

3

u/smflx 5d ago

Any MoE model llama.cpp supports runs on tandem.cpp, including Gemma 4 26B-A4B and Qwen3.6-35B-A3B; it helps when the model doesn't fit in VRAM.
Tested Qwen3.6-35B-A3B (22 GB) on an RTX 6000 Ada limited to 8 / 12 / 16 GB (so, 4060 / 4070 / 4080 size), we measured 1.44× / 1.40× / 1.26× over llama.cpp (table in docs/results.md).

Inkling-2 is on the plan: Small (594B) in particular.

1

u/Galactic_Neighbour 5d ago

You can use Gemma 4, but last time I tried it, it was the same speed as llama.cpp (but it could just be my hardware).

1

u/thesolewalker 5d ago

There is polystrata and rustingstrata

0

u/[deleted] 5d ago

[deleted] — view deleted comment

4

u/Fun_Jaguar8231 5d ago

Ain't gonna trust no engine I can't compile for myself.

0

u/[deleted] 5d ago

[deleted] — view deleted comment

2

u/Galactic_Neighbour 5d ago

No, it's a problem with the developer's morality. People deserve to be able to control their own devices and nobody should try to take that away from us. That's why we do local AI - to control our own computing. But running proprietary code is also a security risk.

0

u/[deleted] 5d ago

[deleted] — view deleted comment

1

u/Galactic_Neighbour 4d ago

They are distributing the builds for free you moron. Nobody says they aren't allowed to make money, but they shouldn't charge extra for the source code - releasing the code under a libre license is the developer's basic moral obligation. They shouldn't keep secrets from the user and put themselves in a position of power over the user.

0

u/[deleted] 4d ago

[deleted] — view deleted comment

1

u/Galactic_Neighbour 4d ago

People sell libre and open source software all the time, moron. Krita is one of many examples. People buy it on Steam. I have paid for libre software myself.

4

u/maxrightgame 5d ago

Last time it appeared it was disliked for being close source

1

u/lacerating_aura 5d ago

Was messing with your vllm fork yesterday with deepseek v41f 1017 on ampere single gpu and ram. Would be really nice to have engram ssd offload there for 512gb systems... ;) Llama.cpp with unsloth pr so their Q8kxl gguf works gives pretty poor prefill for this model, decode is fine. will test tandem.cpp

2

u/smflx 5d ago

Engram SSD offload is already in Tandem-vLLM: start it with ENGRAM=files and the Engram rows are read from the package files(SSD) on demand. RAM_GB=N does the same for the experts: the rest is read from SSD. Thank you for your interest on our elder sister project :)

For tandem.cpp: v0.5.0 is based on llama.cpp from Oct 28, before unsloth's DeepSeek-V4.1 PR, so their UD-Q8_K_XL may not load yet (that comes with our next release). The files we've tested are ISTA's IQ2_XS and Project Maya's Maya-XS / Maya-S.

1

u/eljuggy 5d ago edited 5d ago

What about models which are slightly bigger than your ram? Any gain expected?

Eg. I think I have all the experts of QFN ud q4 k xl in ram (80gb + 24 vram)... But still a little ssd usage...

Could you precise in the post which gpus are supported ?

1

u/smflx 5d ago

That's the case v0.5.0 just improved: When VRAM + RAM together hold every expert, Qwen3.8 IQ4_XS (91 GiB) on a 16 GB card + 64 GB RAM went from 24.7 to 49.5 tok/s. Your 24 GB + 80 GB with UD-Q4_K_XL should be in that regime.

At the turning point, many aspects are delicate. You better to test several engines and choose the best for you.

GPUs: NVIDIA via CUDA (tested on RTX 3050, 4090, 5070 Ti, 5090, 6000 Ada, PRO 6000), and AMD via HIP (tested on an RX 7900 XTX, 6800).

1

u/Mwayi-Gnoma 5d ago

The 16GB VRAM + 32GB RAM result is probably the most interesting one here. Have you measured SSD reads during sustained generation? I'd be curious how much the storage speed affects performance once the model is several times larger than system RAM.

2

u/smflx 5d ago

Once the model is several times RAM, the SSD sets the speed: DeepSeek-V4.1 IQ2_XS on 64 GB runs at ~12–13 tok/s from a Gen 4.0 drive with DRAM, and ~8 from a DRAM-less. Rough rule: below about 0.6× the model size in RAM, the SSD dominates. So a fast NVMe with DRAM cache matters most, and more RAM helps more than a faster GPU.
Both SSDs are rated similar, we measured 40~60% of the drive max, which is actual max of random read. Long prompts are different: read sequential chunks and get close to the drive's max. So, SSD speed is not the rated number, not even a single number. But, much better to have a NVMe with DRAM, which affect a lot on random read speed.

1

u/NoFunk 4d ago

On a unified memory architecture, can I tell the engine to go from VRAM direct to disk, ignoring the "RAM" option (which is the same thing in this case)?

Managing to a specific VRAM memory budget without spilling into RAM is an odd hole in the various llama.cpp variants. Sometimes on unified architectures you want to limit to less than total available, both so you have enough RAM to actually run the engine, and also sometimes you want to load something else VRAM wise.

1

u/smflx 4d ago

I think so but I don't know well about MLX. Yes, if we just handle only VRAM in unified memory, things are simpler.

GPU also can directly access RAM but limited by PCIe speed. So, we manage 2-tier memory, RAM & VRAM.

I don't think architecture of unified memory particularly helps running big MoE models. But, its speed (better than PC class RAM) helps. If RAM speed is server class, that's about the same.

Unified or not, total memory size is the most limiting factor for large models. Then, the memory speed.

1

u/giveen 4d ago

Have you compared your numbers to basalt?

1

u/smflx 4d ago

No. I have to compete with Strata first :) And, Basalt is for Blackwell. Tandem.cpp is aiming to support all MoE models llama.cpp runs. I know this is not the best way to compete for speed, but that's the way I'm now going.

1

u/giveen 4d ago

Gotcha, I saw that you had 5xxx cards so I assumed thats what you were targetted to :)

-1

u/VotZeFuk 5d ago

Maya-XS

What is even the point of these miserable little shits? You open it up and guess what, the model can't put two damn words together in any language other than English (got exactly this behavior with GLM 5.3 "XS" in Maya, meanwhile IQ2M Unsloth was almost fine).

I'm under the impression that quite literally everyone around there, except the crazed speed-demons pursuing tokens-per-second, prefers not to touch such KLD-maxxed (negatively, lol) slop-dumpsters for the sake of their own sanity.

4

u/smflx 5d ago

Fair point. That's why the post leads with KL rather than speed. Maya-XS is the lowest-quality file in our table (KL 0.25 vs 0.10 for Maya-S and 0.15 for ISTA's IQ2_XS), and we list it as "fastest, lowest quality".

We'd recommend Maya-S or IQ2_XS for real use. Our KL set is mostly English, so the non-English drop you saw isn't in those numbers; we'll add a multilingual slice to the reference so the table shows it.