llama.cpp v1 on an Integrated GPU: Long Prompts Read About 2x Faster, and the MoE Cache Lost to Full Offload
Before/after llama.cpp 1.0 on an Intel Arc 140V (Vulkan): a 4,096-token prompt was read about 2x faster, but only with flash attention on. The MoE cache was slower than putting the whole model on the GPU. Plus a CUDA mac
Before/after llama.cpp 1.0 on an Intel Arc 140V (Vulkan): a 4,096-token prompt was read about 2x faster, but only with flash attention on. The MoE cache was slower than putting the whole model on the GPU. Plus a CUDA machine for comparison.
This is an English adaptation of an article I originally published in Japanese on Zenn: llama.cpp v1 ใๅ ่ต GPU ใง่ฉฆใใใใ้ทใๅ ฅๅใฎ่ชญใฟ่พผใฟใฏ็ด 2 ๅใMoE ใญใฃใใทใฅใฏ้ ใใชใฃใ. It includes the correction I added to the original after publication (the flash-attention re-measurement). The measurements and conclusions are mine; I used an AI tool to help translate and restructure the text, and I checked the numbers against the original.
Short version: on a handheld PC whose integrated GPU shares main memory, going from a pre-1.0 llama.cpp build to a post-1.0 one roughly doubled the speed of reading a 4,096-token prompt. Re-measuring with flash attention off made the gap almost disappear. The MoE cache sped up generation a little, but slowed prompt reading and used more memory; putting the whole model on the GPU beat every cache size I could run.
TL;DR
- Intel Arc 140V (Vulkan), dense 2B model: 4,096-token prompt processing went from 986 to 2,005 tokens/s (+103%). At 512 tokens it was +14%; generation didn't change beyond noise.
-
The 2x only appears with
-fa 1. With-fa 0the old/new difference at 4,096 tokens was +2%. In the old build, flash attention was slower than no flash attention; in the new build it's faster. -
MoE cache (
--moe-cache-mib) on the same PC, with all experts in main memory: generation +6โ15%, prompt processing โ12โ22%, 1โ2 GB more memory. Full GPU offload generated 1.4โ1.6x as fast as those setups and used the least memory. - NVIDIA RTX Spark N1X (CUDA), two MoE models fully offloaded: prompt processing +9โ26%, generation +2โ4%.
- An Ollama model file for the same model family didn't load in llama.cpp.
Scope
-
What:
llama-bench(andllama-servertimings for the MoE cache), comparing builds before and after llama.cpp 1.0.0. - On what: two PCs whose CPU and GPU share memory.
| PC | GPU | GPU memory |
|---|---|---|
| MSI Claw 8 AI+ | Intel Arc 140V (integrated), Vulkan | Shares 32 GB with the CPU; a setting caps how much the GPU may use |
| Surface Laptop Ultra | NVIDIA RTX Spark N1X, CUDA (Windows on Arm) | Shares about 128 GB with the CPU; 64 GB set aside as dedicated GPU memory |
- Not measured: a PC with separate VRAM too small for the model (the case the MoE cache seems meant for), dense models on the Surface, large or MoE models in the MSI old/new comparison.
- Every number is from one machine on one day, averaged over two or three rounds. Versions are as recorded in November 2026.
Background
llama.cpp reached 1.0.0. An English-language blog had compared it with an earlier build on an RTX 4060 Ti 8GB (Michael Leung, "llama.cpp v1 benchmark RTX 4060 Ti 8GB"). For a small model that fits entirely on the GPU, it reported prompt processing a little over 20% faster and generation about the same.
That post didn't measure the MoE cache, which the 1.0.0 release notes mention. (The cache itself isn't new in 1.0.0: the option came in v0.7.0. 1.0.0 added the CPU share and a new replacement policy.) My two PCs differ from that machine and from each other, so I wanted to see whether the same version jump would look different.
Result 1: On the MSI, a long prompt was read about 2x faster
I compared a build from before 1.0.0 (b12123) with one from after it (b12374), under the same conditions. The model was a small dense one that fits entirely on the GPU (PLaMo 3 Translate 2B, Q4_K_M, 1.80 GB), the same "dense model, fully offloaded" condition as the blog post.
llama-bench -ngl 99 -fa 1 -p 512 -n 128 -r 5
llama-bench -ngl 99 -fa 1 -p 4096 -n 0 -r 3
To limit order effects I ran old โ new โ new โ old and averaged the two rounds. Units are tokens per second.
| Old b12123 | New b12374 | Change | |
|---|---|---|---|
| Prompt, 512 tokens | 1,907 | 2,171 | +14% |
| Prompt, 4,096 tokens | 986 | 2,005 | +103% |
| Generation, 128 tokens | 51.3 | 50.0 | โ3% (within noise) |
The long prompt changed the most. In the old build, speed fell to about half as the input went from 512 to 4,096 tokens. In the new build it barely falls.
In the blog post (CUDA), the 4,096-token prompt gained 24%. Vulkan on this PC gained much more. At 512 tokens it was the other way round: less than the post's 23%.
What I found afterwards: it's flash attention
A reader's comment on X pushed me to look for the cause after publishing. Among the changes between the two builds there is one that gives Intel GPUs a dedicated computation for flash attention during prompt processing (vulkan : Intel FA kernel for prefill, PR #29357). It covers the generation of the Arc 140V (Xe2) and is used with -fa 1. The PR's own 8,192-token numbers with -fa 1 show gains of 1.2x to 3.9x on the Intel GPUs it lists.
So I re-measured with flash attention turned off (-fa 0), starting with the same old โ new โ new โ old pattern and adding a third round (new โ old), and averaged. In the first round, the very first run of each build (-fa 0, 512 tokens) was cold and a third to a half slower, so I left those two runs out. The 512-token runs were noisier in general (the old build with -fa 1 ranged from 1,517 to 1,891).
| Old b12123 | New b12374 | Change | |
|---|---|---|---|
Prompt, 4,096 tokens (-fa 0) |
1,387 | 1,412 | +2% |
Prompt, 4,096 tokens (-fa 1) |
992 | 1,921 | +94% |
Prompt, 512 tokens (-fa 0) |
1,847 | 1,931 | +5% |
Prompt, 512 tokens (-fa 1) |
1,727 | 2,066 | +20% |
With -fa 0 the difference between old and new almost vanished. The 2x showed up only with flash attention on (-fa 1 nearly reproduces the 986 and 2,005 in the first table).
In the old build, -fa 1 was slower than -fa 0 (992 vs. 1,387 at 4,096 tokens). In the new build it's faster (1,921 vs. 1,412). That fits the PR above: the slow flash-attention path in the old build appears to have been replaced by a fast one. I didn't revert the change on its own, though, so I can't say it's the only cause.
If you stay on the old build, -fa 0 was the faster choice for long prompts on this PC, though still only about 70% of the new build's -fa 1.
Result 2: The MoE cache was slower here than full offload
In an MoE model, many small expert networks sit inside the model and only a few are used for each token. When GPU memory is short, you can keep the experts in main memory and put the rest on the GPU (--n-cpu-moe). The MoE cache copies the experts that are used often into GPU memory while doing that. The official notes say it's meant for token-by-token generation, and that during prompt processing the experts in use are sent to the GPU each time.
| Option | Meaning |
|---|---|
--moe-cache-mib N |
Size of the GPU-side cache in MiB (default 0: off) |
--moe-cache-cpu-share F |
After the cache is full, the share of cache misses computed on the CPU instead of being sent to the GPU (default 0) |
The model was Gemma 4 26B-A4B Q4_0 (14.6 GB, 8 of 128 experts used, 30 layers). I put the experts of all 30 layers in main memory (--n-cpu-moe 30, with attention and the rest on the GPU) and varied the cache size. The baseline was everything on the GPU (--n-cpu-moe 0). llama-bench in this build has no MoE-cache option, so I read the timings in llama-server responses. I ran two rounds in different orders, with two runs per condition each time; the round averages differed by less than 5%. The full-GPU row is two runs from a single round at the end. Prompt and generation numbers are tokens per second.
| Condition | Prompt 512 | Prompt 4,096 | Generation 128 | Server memory |
|---|---|---|---|---|
| Experts in main memory, no cache | 346.8 | 475.7 | 18.5 | 17.35 GB |
| Same, cache 1024 MiB | 298.6 | 419.1 | 19.6 | 18.35 GB |
| Same, cache 2048 MiB | 276.6 | 369.5 | 21.3 | 19.36 GB |
| Same, cache 4096 MiB | did not start (failed to allocate buffer for MoE cache) |
|||
| Everything on the GPU | 336.1 | 498.0 | 30.0 | 17.06 GB |
With a cache, generation got 6โ15% faster, prompt processing got 12โ22% slower, and memory use went up by 1โ2 GB. Single runs within a condition varied by up to 12%, so I wouldn't read much into the 6%. The 4096 MiB cache failed to allocate and the server didn't start.
Putting everything on the GPU generated faster than any cache size (30.0 vs. 18.5โ21.3 tokens/s), and it used the least memory.
This PC's GPU uses main memory directly, so there was nothing to save by not putting the experts "on the GPU." The cache only spends extra memory for the copies and adds work. I believe the slower prompt processing is what the official notes describe: experts being sent each time.
I think the MoE cache is for PCs whose GPU has its own VRAM that can't hold the model. Both of my PCs share memory between CPU and GPU, so I haven't tried that case. What I can say here is only this: on a PC that shares memory with the GPU, with the experts of all layers kept in main memory, full offload beat the cache.
An earlier article of mine (Japanese) showed that raising the shared-GPU-memory cap on this PC and putting the same Gemma 4 26B entirely on the GPU (in Ollama then) made it faster. A feature meant as a way out when the model doesn't all fit gave the same answer here: if it fits, put all of it on the GPU.
Result 3: The Surface got faster at reading, too
On the Surface I compared the older build b12110 with b12374: the Windows CUDA build, with dedicated GPU memory at its usual 64 GB. Other servers were stopped, and I ran old โ new โ new โ old, two runs per build.
The same "small dense model, fully offloaded" isn't installed there, so I used two MoE models I have, both fully on the GPU.
| Model | Prompt 512 | Prompt 4,096 | Generation 128 |
|---|---|---|---|
| Nemotron 3.5 Bolt 74B-A9B IQ2_XXS (20.5 GiB) | 1,141 โ 1,436 (+26%) | 1,172 โ 1,434 (+22%) | 41.2 โ 42.1 (+2%) |
| Qwen3.6-35B-A3B Q6_K (26.6 GiB) | 2,411 โ 2,649 (+10%) | 2,268 โ 2,475 (+9%) | 74.9 โ 78.2 (+4%) |
Prompt processing gained 9โ26%, and generation stayed about the same. That's the same tendency as the blog post (CUDA). The long-prompt jump I saw on the MSI didn't appear.
A snag: an Ollama model file wouldn't load in llama.cpp
For the MoE test I first tried to give llama.cpp the Gemma 4 26B file I used with Ollama. Both are GGUF, so I expected it to work.
wrong number of tensors; expected 1014, got 658
It failed to start with this. The file Ollama had converted for itself didn't have the layout llama.cpp expects. Downloading the GGUF that ggml-org publishes on Hugging Face fixed it.
My test script also waited up to 5 minutes for the server to come up, so it wasted time waiting even after loading had failed. I changed it to stop as soon as a failure shows up in the log.
Where this stops
- I traced the MSI's 2x only as far as the change in flash-attention computation. I haven't reverted the changes one by one.
- The MSI old/new comparison used one dense 2B model. Whether large or MoE models gain as much isn't measured.
- I haven't tried the MoE cache on a PC with separate VRAM that can't hold the model, which is the case it should help.
-
I didn't try keeping only some layers' experts in main memory (a smaller
--n-cpu-moe). On the MSI the model fits on the GPU, so I judged there was no use for it. -
I didn't use the official tuning script (
scripts/moe-cache-tune.py), and left--moe-cache-cpu-shareat 0. I also used the default load mode (mmap); the official notes say the experts aren't pinned in host memory then, and I didn't try the modes that pin them. - No dense model on the Surface.
- Every comparison is one machine, one day, averaged over two or three rounds.
Takeaways
- On an integrated GPU that shares memory, moving to a post-1.0 llama.cpp build roughly doubled the speed of reading a 4,096-token prompt. If you compare builds, try
-fa 0as well as-fa 1: here it showed where the gain came from. - On the CUDA PC the gain was +9โ26% in prompt processing, similar to an earlier report from another machine.
- The MoE cache raised generation a little and lowered prompt speed while using more memory, on this shared-memory PC. If the model fits entirely on the GPU, that was the faster choice.
- A GGUF that Ollama created isn't necessarily loadable by llama.cpp.
About this series
This is part of my Japanese-language series on running local LLMs on an integrated GPU. Related articles:
- ๅ ่ต GPU ใฎๅ ฑๆใกใขใชใผใฎไธ้ใๅคใใใโฆ (Japanese): the shared-memory cap on this MSI
- Ollama vs. llama.cpp on the Same GGUF: The 15% Speed Gap Was the Defaults, Not the Engine (English): the Surface
- A 120B Model Ran About 4x Faster Than a 27B One: 8 Local LLMs on a Surface Laptop Ultra (English): the Surface
The original of this article: llama.cpp v1 ใๅ ่ต GPU ใง่ฉฆใใใใ้ทใๅ ฅๅใฎ่ชญใฟ่พผใฟใฏ็ด 2 ๅใMoE ใญใฃใใทใฅใฏ้ ใใชใฃใ.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.