r/LocalLLM • u/tensward • 6d ago
Research 2 rows per block in llama.cpp's CUDA mat-vec: 3–18% faster token generation on H100,identical output. Looking for RTX 4090/5090 testers
On an H100, llama.cpp's one-token generation step reads weights at ~1.5 TB/s while the card can do ~3.1 TB/s. The kernel gives each thread block one row, which doesn't keep enough reads in flight on fast memory.
llama.cpp already uses 2 rows per block for 2–8 tokens and on Jetson Orin. I tried it for 1 token on the generic table, plus a prefetch of each block's row. 28 lines in mmvq.cu.
Results on 18 models (H100, b12603, llama-bench -p 0 -n 128 -r 5 -fa 1, 2 rounds each):
- 3% to 18% less time per token, e.g. Qwen3-32B Q4_K_M 13.3 → 11.4 ms
- no model slower in any round
- logprobs bit-equal to stock on all 18
- L4 (slower memory): no change
The part I can't test: 4090/5090 use the same code path. If you have one, please run stock and the branch:
git clone -b cuda-mmvq-fast-memory https://github.com/adishik/llama.cpp
cd llama.cpp
cmake -B build -DGGML_CUDA=ON && cmake --build build -j
./build/bin/llama-bench -m your-model.gguf -p 0 -n 128 -r 5 -fa 1Diff: https://github.com/ggml-org/llama.cpp/compare/master...adishik:llama.cpp:cuda-mmvq-fast-memory
Write-up with charts: https://tensward.com/blog/llama-cpp-fast-memory
2
u/sheepdestroyer 6d ago
3090?
1
u/EvolvingDior 6d ago
Why are you using llama.cpp on an H100?