r/llamacpp • • 2h ago

TRU NEROMESH WORKER — PUBLIC BETA - Put your CPU/GPU to work on the NEROMESH AI inference network

Thumbnail reddit.com
1 Upvotes

r/llamacpp • • 22h ago

Inkling 2 Mini on one RX 9070 XT: SaloQT's rdna4-amd-infer vs llama.cpp (same model, same context, same benchmark)

11 Upvotes

If you have an RDNA4 card and want to run Thinking Machines' Inkling 2 Mini, look at SaloQT/rdna4-amd-infer. I ran it against llama.cpp on the same model file, the same context size and the same benchmark.

The project

  • SaloQT/rdna4-amd-infer by SaloQT is a C11 inference engine for RDNA4 (gfx1201).

    • It has 310 hand-written GPU kernels, 217 of them for Inkling 2, all fused with no register spills.
    • It includes DSpark speculative decoding, a 4-bit global KV cache, and a VRAM expert cache that fits the full 256K context on a 16 GB card.
    • It also has vision and an OpenAI-compatible server.
  • It's built on hanw/amd.c by Han Wang, a from-scratch C11 inference engine for the same GPU with a formally verified indexing/quantization core. SaloQT credits it clearly, and the base engine is largely kept as-is. SaloQT added the Windows port, the Inkling and Saluki kernels, and the model-specific features on top.
  • Licensing: neither repo has a license file yet, so treat both as personal use only.

Setup

  • Hardware: RX 9070 XT 16 GB (RDNA4, gfx1201), i9-14900K, 32 GB DDR5, PCIe 5.0, Arch Linux with ROCm.
  • Model: AtomicChat's Inkling-2-Mini IQ3_XXS GGUF for every engine (the ie engine and my fork read a layout-converted copy of the same weights).
  • Context: 256K for every engine, each with its own memory layout for that size. The llama.cpp builds keep the experts of 9 outer blocks in system RAM; my fork adds a hot-expert VRAM cache. rdna4-amd-infer keeps all 12 outer blocks' experts in RAM behind a 64-slot VRAM cache per block.
  • Benchmark: the same script for every engine, greedy:

    • three short prompts (code, edit, prose), up to 512 tokens each, twice;
    • a 14K-token prompt, twice;
    • a 56K-token prompt.
  • Speeds: each server's own timings.
  • Safety: total VRAM capped at 15.8 GB, desktop included.

Engines

EngineBuildSpeculative decoding
llama.cppggml-org master 87f816en-gram only (master can't load any Inkling drafter)
llama.cpp + DSpark PRmaster + PR #32218 (e4b1cb5)DSpark (depth 5) + n-gram
My forkUnsloth's llama.cpp fork + 37 Inkling patches (fused kernels, banded flash attention, expert cache)DSpark + n-gram
rdna4-amd-inferSaloQT 90c7d21DSpark, 7 drafts

Stock llama.cpp needs ubatch 32 at 256K, because its Inkling attention reserves a 12.9 GB buffer at 512.

Results (IQ3_XXS, 256K context)

EngineCode / edit / prose14K prompt read, then decode56K prompt read, then decodePeak VRAM
llama.cpp23 / 22 / 23 tok/s181 tok/s, then 44146 tok/s, then 2314.6 GB
llama.cpp + DSpark PR31 / 26 / 17out of VRAM*—15.8 GB
My fork89 / 88 / 601,726, then 1061,512, then 7214.8 GB
rdna4-amd-infer146 / 153 / 1083,084, then 1342,997, then 10412.8 GB

*The PR's DSpark drafter needs extra VRAM; at this placement it went over the 15.8 GB cap during the 14K prompt.

The decode after the 14K prompt is higher than on the short prompts for the llama.cpp builds because the summary repeats text from the prompt, which n-gram drafting picks up.

Against stock llama.cpp, rdna4-amd-infer is 5–7× faster on short chats, 17–21× faster at reading long prompts, and 4.6× faster decoding after a 56K prompt, while using less VRAM.

Notes

  • The engine reads only specific quants: IQ3_XXS experts with IQ4_NL down projections. Q4_K_M and similar files still need llama.cpp.
  • SaloQT targets Windows, but it builds and runs fine on Linux with the system ROCm. Image decoding is Windows-only (WIC) out of the box.
  • One machine, greedy benchmarks, ±5–10% noise because the desktop shares the GPU.

If you have an RX 9070 / 9070 XT, try it, and give SaloQT's repo and Han Wang's amd.c a star.


r/llamacpp • • 15h ago

Hand-written CUDA kernels for every op got us 32% faster LLM decode than vLLM on an H100

Thumbnail
reddit.com
3 Upvotes

r/llamacpp • • 11h ago

Inkling 2 Mini GGUFs, various sizes for Mac GPU (vision included)

Post image
1 Upvotes

r/llamacpp • • 15h ago

We gave Qwen3.5 9B and Qwen3.6 35B A3B 12 everyday file jobs on a 12 GB GPU: 35/36 and 36/36

Post image
2 Upvotes

r/llamacpp • • 18h ago

a fast flash attention 2 kernel for volta, for FP16 keys and Q8_0 values in the KV cache. performance gains in both prefill and substantially in decode - benchmarks included with integration instructions for drop in integration with your engine

Thumbnail github.com
1 Upvotes

reposting here! it's a native llama implementation


r/llamacpp • • 22h ago

3x speedup of DFlash2 for Inkling2m on llama.cpp (50 -> 150 on code tps)

Thumbnail
github.com
1 Upvotes

r/llamacpp • • 1d ago

GLM-5.3-Flash on numallama CPU-only inference | 256 ARM Cores + 1TB RAM

1 Upvotes

r/llamacpp • • 1d ago

Inkling 2 mini on 1x3090: 125 TPS at 100k tok depth, 1700 pp/s, 401K ctx, same KLD as UD-4K XL; 3x faster than stock llama.cpp

Thumbnail
reddit.com
1 Upvotes

Updated as of today: boosted speed ~10% on decode (140+ tps) and 30-40%+ on prefill (24-2700/s) vs yesterday. No quality loss.


r/llamacpp • • 1d ago

Best llama.cpp Fork / Inference Engine for Running Inkling Small 2 Mini at Maximum Context on 16GB VRAM + 32GB RAM?

Thumbnail reddit.com
1 Upvotes

r/llamacpp • • 1d ago

I tried fitting a quantization grid myself — sort of works on small models

1 Upvotes

I'm just a regular local-model user. Independent researcher, no lab, no affiliation. I use some models locally and wanted better quantization quality, so I started poking at it.

I tried fitting the grid per tensor, from the weight distribution plus Hessian diagonals. No training, no gradients, CPU/GPU only.

Tested on SmolLM-135M and Qwen2.5-0.5B. On Qwen at 4 bits, ppl went from 22.65 to 19.23 versus a uniform grid (fp16 is 17.07). On SmolLM at 3 bits, 1580 to 52.6 — still nowhere near fp32 at 23.36 but it is massive improvement from 32 to 3 bit - model still alive. So something is there, but it needs a lot more work. The llama.cpp version is a reference kernel: slower than Q4_K_M and worse in the runtime test, so don't treat it as a drop-in upgrade.

I wrote it up and put everything online — the preprint, the paper, code with raw results, the GGUFs, and a llama.cpp fork with the Q4_LUT format:

Ask away if you want details on the fitting or the format — I'll answer what I can.


r/llamacpp • • 2d ago

Inkling 2 Mini at 256k context on a single 16 GB RX 9070 XT: 55–85 tok/s with a patched llama.cpp (ROCm), ~3× upstream on chat and ~10× on long prompts

18 Upvotes

I spent the last few days getting Thinking Machines' Inkling 2 Mini (26B total / ~5B active looped MoE, 1M context) running as fast as possible on one 16 GB AMD card. Sharing the numbers and what actually mattered, because this model behaves very differently from the usual MoEs.

Hardware: RX 9070 XT 16 GB (RDNA4, gfx1201), i9-14900K, 32 GB DDR5, PCIe 5.0, Arch + ROCm. Everything stays under ~15.2 GB of VRAM including the desktop (a full card froze my session, so every test ran under a VRAM watchdog).

Software: Unsloth's llama.cpp fork plus 26 patches (24 of my own: custom HIP kernels, scheduler and launcher changes; plus two open upstream PRs, #32215 DPP warp reductions and #30685 async input copies), DSpark speculative decoding + n-gram lookup drafting, q4_0 KV cache for both the model and the drafter.

Results (greedy, 768-token coding answer; "edit" = rewrite a file; prompt = 54k tokens)

QuantContextChatCode edit54k promptPeak VRAM
Unsloth UD-Q4_K_M256k55–57 tok/s120~1,020 tok/s15.2 GB
Unsloth UD-Q4_K_M128k621361,09415.2 GB
GSQ-RCO IQ4_XS (abenzerps)256k67136–162~1,35015.1 GB
GSQ-RCO IQ4_XS128k851711,45915.0 GB
AtomicChat IQ3_XXS256k79–83180–200~1,35515.1 GB
AtomicChat IQ3_XXS64k (all in VRAM)~90—1,68914.8 GB

Where I started: Unsloth's prebuilt at 16k context did 23 tok/s, and 10.8 tok/s with DSpark (the drafter overcommitted VRAM).

Same weights against upstream llama.cpp (built today, same flags and toolchain)

GSQ IQ4_XSupstream masterupstream + DSpark PR #32218patched
128k chat29.135.684.9
128k code edit89.688.8171
128k, 54k prompt210 tok/s2121,459
256k chat19.4—67
256k, 54k prompt125 tok/s—~1,350

Kernel-only (llama-bench, no drafting): decode +17%, prompt at 32k depth 3.8×. Upstream has to drop to ubatch 64 (128k) / 32 (256k) because its Inkling attention wants a 12.9 GB buffer at ub 512.

Quant quality (wikitext-2 KLD against UD-Q4_K_M logits)

  • GSQ-RCO IQ4_XS: KLD 0.015, same top token 95.1%. That's the best of the small quants: close to Q4_K_M and about 20% faster than it, so it's what I'd recommend for 16 GB.
  • AtomicChat IQ3_XXS: 0.024 / 93.9%
  • GSQ-RCO IQ3_XS: 0.051 / 91.0%. It hit ~100 tok/s with 256k fully in VRAM, but the quality loss was too much for me.

Things that didn't help

Vulkan (no banded attention kernels, 11–17 tok/s), F16 KV, an acceptance-driven adaptive draft length (its depth flips cost more than they save), overlapping the RAM-expert uploads with compute (needs ~0.8 GB of staging VRAM, which is worth more as expert cache), and a few upstream PRs that don't touch these quants.

Caveats

  • One machine.
  • Greedy benchmarks, with ±5–10% noise because the desktop shares the GPU.
  • Generation at temperature 1.0 is a few tok/s lower (DSpark acceptance drops).
  • DSpark for Inkling isn't in upstream master yet: PR #32218 works with Unsloth's new mainline-format drafter. Unsloth's old-format drafter only works with their fork.

I'm thinking about upstreaming the attention kernels if there's interest.


r/llamacpp • • 2d ago

I almost sold my daughter's Roblox laptop for a used 3090. Instead, I linked it to my AMD desktop over Ethernet and hit 42.99 tok/s on Qwen3.8-27B (Q4_K_M, 64k)

Post image
0 Upvotes

r/llamacpp • • 2d ago

VMAT Free: share one NVIDIA GPU between 4 VMs for CUDA, no passthrough or vGPU license

3 Upvotes

I've been building VMAT so that I could get several VMs to share one GPU at the same time, and today the the free tier is out today for Proxmox VE 9 and Linux desktops. I'd love if a people with consumer cards I don't own to try it and dish out some honest feedback.

Up to 4 VMs share one NVIDIA card and each one runs CUDA programs as if it had the card to itself. llama.cpp and PyTorch run inside the VMs. There's no passthrough, no SR-IOV and no vGPU license, and it works on stock QEMU. When a VM is idle its GPU time goes to the busy ones, or you can give each VM a fixed share.

I've debugged & tested it on Proxmox VE 9 with a rented H100 using 4 Debian VMs at once with llama.cpp ran in all four, and PyTorch 2.11 in the VMs on the host. On earlier builds with an RTX 6000 Ada, llama.cpp in a VM ran at 90 to 98% of native speed. I also ran an RTX 5090, where CUDA and PyTorch gave the same results through VMAT as native, but that was in a container with no VM.

So nobody wastes an evening: it's Linux VMs only, with Debian and Ubuntu guests on Proxmox. Free allows 4 VMs and 16 GB of GPU memory per VM. CUDA needs an NVIDIA card, and I haven't tested GeForce cards with VMs yet, or AMD. It's one GPU per host, and there's no graphics or games in this build. It's early software and it can crash.

The host side is closed. The guest side, which is the library and tools that run in our VMs is open source (BSD)@ https://github.com/b1nc0d3x/gVMAT.git

Downloads, checksums and install steps are at vmat.dev/getting-started.html. If it breaks, please get at me and let me know what card you tried as well as what happened.


r/llamacpp • • 2d ago

LexiSuite T21: Inkling-2-Mini at 135 tok/s with its draft head on one RX 7900 XTX (llama.cpp's newest build: 39), 524k context on 24 GB, and now a single USB image with the model already inside

Thumbnail
github.com
0 Upvotes

Follow up to my earlier Inkling-2-Mini posts. Testing image 21 of LexiSuite (my own Rust stack: inference engine, control panel, bootable OS image, not a wrapper around llama.cpp or Ollama) is out, and this time there is an all-in-one download: one USB image with the OS, the engine, the panel and the Inkling-2-Mini file already in the model folder. Write it to a stick, boot, open the address on the screen, load the model.

All in one image, the plain image and the model file by itself:

https://huggingface.co/Wa1k3r/Inkling-2-Mini-NVFP4exp-Q8-draft-LexiSuite-AIO-for-AMD-RDNA

Hardware for everything below: RX 7900 XTX 24 GB, i7-9700, 32 GB RAM, Vulkan. One card, whole model on the card, nothing in system RAM. 4-bit KV cache. Single runs, greedy decoding, nothing else running on the box. All measured November 23 on the published build.

The model file is 18.3 GB. It keeps the experts exactly as Thinking Machines shipped them (their own 4-bit format), the rest is 8-bit, and the model's own draft head is packed into the same file.

BENCHMARKS, LexiEngine

4,096 token prompt

2,430 tok/s prompt, 136.4 tok/s generation with the draft head (66.5 without it)

16,384 token prompt

2,332 tok/s prompt, 134.8 tok/s generation with the draft head (65.8 without it)

261,632 token prompt (262k context)

1,193 tok/s prompt, 65.5 tok/s generation with the draft head (50.3 without it)

523,264 token prompt (524k context)

764 tok/s prompt, 48.9 tok/s generation with the draft head (40.4 without it)

By kind of text, with the draft head after a 16,384 token prompt:

JSON records 159.0 tok/s

Rust code 121.3 tok/s

English prose 94.7 tok/s

Output with the draft head was identical to plain greedy decoding in every run. It only changes speed.

LLAMA.CPP GOT A LOT FASTER, SO I MEASURED IT AGAIN

In my last post llama.cpp was at 425 tok/s prompt and 25 tok/s generation on this model (build 12600, November 20). Its newest build (commit 1f8baae), same day, same card, same weights:

4,096 token prompt: 1,233 tok/s prompt, 40.4 tok/s generation

16,384 token prompt: 1,049 tok/s prompt, 39.2 tok/s generation

That is a big jump on their side in three days and the old 4x to 5x gap is gone. At 16k LexiEngine is now 2.2x on the prompt, 1.7x in plain generation and 3.4x with the draft head. I did not run llama.cpp at 262k or 524k this time.

DOES IT ACTUALLY READ THE CONTEXT

Ten facts planted through the prompt from 1% to 99% of its length, each asked back:

at 260,864 tokens: 10 of 10

at 523,264 tokens: 10 of 10

Against a reference run of the published weights the engine scores a mean KL of 0.0037 with the same top token on 98.6% of 510 positions (4-bit KV cache).

WHAT CHANGED SINCE THE LAST IMAGE

generation with the draft head at 4k: 110.7 -> 136.4 tok/s

generation with the draft head at 16k: 109.5 -> 134.8 tok/s

the draft head now helps at 524k too (48.9 vs 40.4 plain); two images ago it was a small loss there

Also in this build: the Linux entry is 7.4-rc4 (unmodified upstream tag) beside my own kernel, the experts of the last four layers can be stored in 4 bits (2.0 GB smaller, same speed, slightly lower accuracy), and repairs to the quantization tool in the panel.

THINGS YOU SHOULD KNOW BEFORE TRUSTING ANY OF THIS

Everything is single runs on one machine, with the card capped at 291 W. If you have a 7900 XTX I would genuinely like to know if you get the same numbers.

The model file is for my engine. Stock llama.cpp, Ollama and LM Studio do not load it: their converters decode the 4-bit experts and quantize them again (27.8 GB at 8 bits, which does not fit a 24 GB card), and they do not know the draft head's tensors.

It is tuned and measured on Radeon RDNA 3. I have not measured other cards on this build.

I trained a recovery adapter for the 4-bit expert file and it did not improve held out text measurably, so no adapter is published.

Not in this build: image input for Inkling, formats below 8 bits for its attention matrices, and a 1M context on 24 GB (the cache alone would be 9.85 GB).

This is a development image, not a production release. The all-in-one image is 17.6 GB to download and 23 GB when written, so it needs a 32 GB stick. The plain image is 353 MB and fits an 8 GB stick. Writing either one erases the stick.

LINKS

All-in-one image and model file: https://huggingface.co/Wa1k3r/Inkling-2-Mini-NVFP4exp-Q8-draft-LexiSuite-AIO-for-AMD-RDNA

Base model: https://huggingface.co/thinkingmachines/Inkling-2-Mini

Download and USB instructions: https://lexipanel.com/download/

Benchmarks and method: https://github.com/W61k3r/LexiSuite-Releases/wiki/Benchmarks

How the Inkling runtime works: https://github.com/W61k3r/LexiSuite-Releases/wiki/LexiEngine-Inkling-2

Release notes: https://github.com/W61k3r/LexiSuite-Releases/wiki/Release-Notes


r/llamacpp • • 2d ago

How to Install PyTorch with CUDA Support Step-by-Step Guide

Thumbnail interconnectd.com
1 Upvotes

r/llamacpp • • 2d ago

Qwen3.5:9b is running slower than expected

Thumbnail reddit.com
1 Upvotes

r/llamacpp • • 3d ago

I run Qwen3-30B-A3B on an 8 GB laptop with no GPU by streaming experts from the SSD (open source, output identical to llama.cpp)

Thumbnail
reddit.com
1 Upvotes

r/llamacpp • • 3d ago

From 17 to 31 tok/s on an RTX 4060 8GB: 3-bit experts on Inkling-2-Mini (follow-up to my 25 tok/s post)

2 Upvotes

TL;DR: Inkling-2-Mini (128 experts, 8 active) on an RTX 4060 8GB now runs at 31.1 tok/s decode and 545 tok/s prefill. The stock setup gave me 17.4 and 308. My last post got to 25.5 with lossless kernel work. This step is lossy: I requantized the expert weights to 3-bit. Quality loss is small and measured below.

Setup

\- RTX 4060 8GB (PCIe 4.0 x8), i5-14400F, 32 GB DDR5-5600

\- Unsloth UD-Q4_K_M GGUF, a custom llama.cpp build with the kernel fusions from my last post

\- llama-bench: \`-ngl 99 -fa 1 -t 8 -ub 512 -b 2048\`

Results

| | prefill 512 | prefill 2048 | decode |

|---|---|---|---|

| stock (\`--n-cpu-moe 18\`) | 308 | 315 | 17.4 |

| last post (lossless) | 447 | 429 | 25.5 |

| now (3-bit experts) | 545 | 509 | 31.1 |

That's 1.8x decode and 1.8x prefill over stock. In real long coding chats through llama-server it holds 28–29 tok/s.

What I changed

  1. Only the expert gate_up weights went to 3-bit (Q3_K). The down projections stay 4-bit because their row size (1152) isn't a multiple of 256, which K-quants and IQ-quants need. The last 4 blocks went from q5_K/q8_0 to q3_K/iq4_nl.
  2. Importance matrix: I made one from about 92k tokens of llama.cpp source code (C++, CUDA, Python, Markdown). It doesn't overlap the text I used to measure quality.
  3. File size: 15.8 GB down to 12.8 GB.
  4. Placement: the smaller experts freed enough VRAM to keep the experts of two more looped blocks on the GPU (blocks 6–15 instead of 6–13). This model runs blocks 6–17 three times per token, so every looped block moved off the CPU saves three expert reads per token. That's where most of the gain comes from:

    \`-ot "blk\\.(0|1|2|3|4|5|16|17|18|19|20|21|22|23)\\.ffn_(gate_up|down)_exps=CPU"\`

  5. VRAM peak: 7.3 GB at 8k context.

Quality, compared with the Q4 model it came from

\- KL divergence: 0.011 at 512 context, 0.008 at 2048

\- Same top token: 97.7% / 98.0%

\- Perplexity: +0.2–0.3%, about the size of the measurement noise

\- My 8-task Python test with hidden unit tests: 8/8, same as Q4. It's only a smoke test: one try per task at temperature 1.0, and it used about 9% more tokens.

So it's not lossless, but it's close.

What didn't help

\- IQ3_S on the GPU blocks: not faster, slightly worse quality, and it missed one coding task by running out of tokens.

\- IQ3 types on the CPU: 1.4–2.5x slower than Q3_K for this matrix shape, so Q3_K is the only 3-bit type that's fast on both CPU and GPU.

\- Turning the down projections to 3-bit: no 3-bit format in llama.cpp supports their 1152-wide rows. That would need a new 3-bit format, or pruning experts.

Recipe

\`llama-quantize --allow-requantize --imatrix imatrix.gguf --tensor-type-file types.txt Inkling-2-Mini-UD-Q4_K_M.gguf out.gguf Q3_K 8\`

\`types.txt\` pins every tensor to its current type, except the expert tensors listed above. It takes about 3 minutes on this CPU.

Where it stands on this box: prefill is limited by PCIe x8, because the CPU-side experts get re-uploaded to the GPU on every batch. Decode is limited by dual-channel DDR5 bandwidth for the experts that stay on the CPU. The next big step would be pruning experts for coding-only use, which I haven't tried yet.

Profiling, kernels, quantization and benchmarks done together with Claude Opus 5.5 (Claude Code). I ran everything on my machine.


r/llamacpp • • 3d ago

Inkling-2-Mini at the full 1M context on one RX 7900 XTX (Windows, ROCm): 9/9 retrieval, 37 min prefill, ~10 tok/s decode, and how it compares to llama.cpp

Thumbnail
reddit.com
1 Upvotes

r/llamacpp • • 3d ago

Hexagon NPU detection and working for llama.cpp natively in Termux.

Post image
3 Upvotes

Android using a Snapdragon 8, Gen 3. Got the Hexagon NPU enabled. OpenCL to boot, even added OpenBLAS as well as pure CPU.

The OP details how to get llama.cpp binary buiilt for Termux. There is a notable difference on prompt generation, reply generation varies on the model used.


r/llamacpp • • 3d ago

Qwen3.8-27B scored 489/500 (97.8%) on MATH-500 on my 32GB RK3588S NanoPi M6 — custom ANR W6 runtime, single-pass greedy, 14 days

Thumbnail reddit.com
1 Upvotes

r/llamacpp • • 3d ago

My custom 4-bit quantization method from scratch

1 Upvotes

I have been developing and benchmarking a custom 4-bit non-uniform weight quantization format(phi-lattice v2: 15-level golden-ratio codebook, uint8 nibble packing, fp16 per-group scales at group_size=64) across dense LLMs, an MoE model, and an embedding model. All checkpoints, standalone PyTorch/Triton loaders, and raw lm-eval JSONs are public on Hugging Face.

Below is a factual summary of what worked, what regressed, and where the current implementation still lags behind native runtimes.

1. Same-engine comparison vs llama.cpp Q4_K_M (Qwen3-4B-Instruct-2507)

To remove cross-engine variance, Q4_K_M (unsloth GGUF, 2,382 MiB) was dequantized to bf16 via the transformers GGUF loader and evaluated with the exact same lm-eval HFLM pipeline (batch_size=8, CUDA L4) as BF16, data-free v2, and v2-gecko (block-64 calibrated Hessian pass, 198 s quantization time on L4, 12.52% exact zeros):

TaskMetricBF16 Basev2 (data-free)v2-geckoQ4_K_M (llama.cpp)
MMLU (14,042)acc (group)70.63%68.06%69.02%69.40%
GSM8K (1,319)strict-match85.90%83.93%85.06%84.84%
GSM8K (1,319)flexible-extract83.85%17.59%21.83%21.08%
HellaSwag (10,042)acc_norm69.05%67.19%67.36%68.39%
IFEval (541)prompt_strict57.86%45.47%46.95%—

Observations:

  • v2-gecko vs Q4_K_M is a statistical tie across all measured tasks (every gap <= 1.6 sigma). Both improve over data-free v2 on every metric.
  • The GSM8K flexible-extract drop (83.85% -> 17.6–21.8%) occurs identically in Q4_K_M and both phi-lattice variants, indicating a 4-bit quantization artifact on this model rather than a codebook-specific issue.

2. Negative result on embedding models (why calibration hurt retrieval)

Applying the same calibrated block-Hessian pass (v2-gecko) to google/embeddinggemma-2 produced a split result:

  • STS-B test (similarity, 768d): improved slightly (0.8670 -> 0.8681).
  • SciFact nDCG@10 (retrieval, 768d): regressed (0.8398 -> 0.8316), even with mixed STS + SciFact calibration prompts.

Because retrieval degraded, v2-gecko was not promoted for embedding models.

3. Two-stream residual ("cashback") — data-free recovery to BF16 parity

Instead of calibration, storing the exact first-pass quantization error R = W_bf16 - W_v2 as a second 4-bit nibble stream (W = unpack(stream1) + unpack(stream2), same codebook, data-free) raises weight SQNR from ~19.5 dB to ~39.2 dB at ~8.5 bpw effective.

Scope note: full-model two-stream cashback (all quantized linear layers) has only been built and fully evaluated on the Gemma models (gemma-3-270m-it and embeddinggemma-2). On Qwen3-4B, cashback was applied only to the token embeddings (the 252 linear layers remain single-stream v2-gecko), and only MMLU and HellaSwag were re-run on that archive (GSM8K and IFEval were not re-evaluated).

A. Full-model two-stream (gemma-3-270m-it and embeddinggemma-2)

At 270M, single-stream 4-bit quantization causes heavy degradation. Comparing v2, Q4_K_M, and full v2 + cashback (421.9 MiB, all 126 linear layers) on unsloth/gemma-3-270m-it (same L4 lm-eval engine):

CheckpointSQNR6-text PPLHellaSwag acc_normMMLUGSM8K strictIFEval prompt_strict
BF16 reference—90.8239.29%25.08%2.43%24.21%
v2 (1-stream, ~4.5 bpw)19.48 dB161.2737.93%25.94%0.61%17.74%
Q4_K_M (~4.5 bpw)26.80 dB99.3039.12%24.88%1.36%17.56%
v2 + cashback (~8.5 bpw)39.17 dB90.5939.31%24.93%2.20%23.11%

Note: Q4_K_M (~4.5 bpw) and v2 + cashback (~8.5 bpw) sit in different size tiers; the point of the comparison is verifying that the data-free residual stream closes the quantization gap to BF16 parity. The same holds for full-model two-stream embeddinggemma-2 (217 text-tower layers, 659.5 MiB, 39.21 dB SQNR): STS-768 0.8745 vs BF16 0.8743, SciFact nDCG@10 0.8552 vs BF16 0.8569.

B. Embeddings-only cashback (Qwen3-4B-Instruct-2507)

Keeping all 252 v2-gecko linear layers byte-identical and applying two-stream cashback only to the 741.9 MiB BF16 embed_tokens (tied with lm_head):

Embedding configEmbed sizeArchive sizeSQNR vs BF166-text PPLMMLUHellaSwag acc_norm
BF16 (original gecko)741.9 MiB2,583.2 MiB—7.39569.02% +/- 0.3667.36%
1-stream 4-bit (no residual)197.1 MiB2,038.4 MiB19.68 dB7.712 (degraded)——
2-stream cashback embeds394.1 MiB2,235.5 MiB39.28 dB7.37068.92% +/- 0.3767.39%

A single 4-bit stream on embeddings measurably degrades perplexity; adding the residual stream eliminates the penalty on the measured tasks (MMLU and HellaSwag tie within 1 stderr; GSM8K/IFEval not re-run) and reduces total archive size by 348 MiB (below the 2,382 MiB Q4_K_M GGUF).

4. Scaling to 35B MoE (Qwen3.6-35B-A3B)

Packing all 80 3D routed expert banks (32.21B weights) + 2D projections (1.72B weights) in 4-bit phi-lattice v2 (keeping routers, norms, and embeddings in BF16/FP32) reduces Qwen3.6-35B-A3B from 65.39 GiB BF16 to 18.98 GiB resident (19.33 GiB peak during 512-token generation on a single 24 GB NVIDIA L4), with 19.63 dB SQNR and 13.11% exact zeros. Only the 8 active experts per token are dequantized during forward.

5. Current limitations (measured on L4)

  • Decode throughput lags llama.cpp**:** on Qwen3-4B (tg128, greedy), native llama-bench Q4_K_M reaches 85.02 tok/s (2,990 MiB VRAM). Our PyTorch unrolled_bf16 mode runs at 23.76 tok/s (8,254 MiB VRAM), eager low_vram_4bit at 1.65 tok/s (3,516 MiB VRAM), and our initial Triton LUT-GEMM kernel (phi_lut_gemm.py) at ~16.2 tok/s (136.8 GB/s). Prefill (pp512) is within 7% (4,920 vs 5,288 tok/s). The decode bottleneck is kernel/loader engineering rather than archive byte count.
  • Resident VRAM of cashback embeddings: in low_vram_4bit, cashback embeddings save 348 MiB on disk/download, but are currently unpacked into BF16 nn.Embedding at load time (~2.58 GiB resident).
  • Runtime support: PyTorch/Triton loaders only; no GGUF/llama.cpp integration.

Links (archives, loaders, raw eval JSONs)

Feedback on the evaluation methodology or Triton GEMV kernel optimization for 4-bit LUT dequantization is welcome.


r/llamacpp • • 3d ago

I built a custom Metal inference engine for Inkling 2 Mini on Apple M1/M2/M3 (284 t/s prefill @ 100k, 41.6 t/s decode, 18.6 GiB @ 256k) — open source + benchmarks

Thumbnail
reddit.com
1 Upvotes

r/llamacpp • • 4d ago

llama.cpp Vulkan fork for AMD on Windows: ~60-75% faster generation than stock with Qwen3.8-27B on an RX 9070

20 Upvotes
I've been tuning a llama.cpp Vulkan fork (based on vansh-visariya/rx7900-xtx) for AMD cards on the Windows proprietary driver. After a lot of testing on my machine, this is where it stands today.



**System**

- GPU: RX 9070 16 GB (RDNA4), core/memory overclocked, Adrenalin 26.10.1

- CPU/RAM: Ryzen 7 5800X, 32 GB

- OS: Windows 11

- Model: Qwen3.8-27B Unsloth Dynamic v3.1 UD-Q2_K_XL

- Draft: DFlash2 Q4_K_M (incoai/Qwen3.8-27B-DFlash2-GGUF)

- 112K context, q4_0 KV cache, flash attention, everything on GPU (peak ~14.4 GB VRAM)



**Results** (generation t/s at short prompt / ~32K / ~64K context, prompt processing t/s at 32K / 64K)



| Build | Generation | Prompt processing |

|---|---|---|

| Stock llama.cpp b12602, no draft | 35.3 / 33.7 / 30.7 | 774 / 515 |

| Stock llama.cpp b12602 + MTP (1 token) | 49.7 / 47.0 / 45.2 | 750 / 483 |

| Stock llama.cpp b12602 + DFlash2 | 31.9 / 42.0 / 31.7 | – |

| **This fork + DFlash2 (3 tokens)** | **77.9 / 77.6 / 80.5** | **807 / 521** |



So about +55-75% generation over the best stock setup, with prompt processing on par. Speculative decoding numbers move ±10% between runs depending on how many draft tokens get accepted.



**What makes the difference on this driver**

- Fixes for driver compiler crashes in the flash attention shaders (the same bug upstream hit and worked around by disabling the shader).

- A q4_0 KV path in the GQA attention shader.

- The draft verify attention now reads the KV cache once per 2 draft tokens instead of once per token. The Windows driver only gives 32 KB of shared memory per workgroup (Linux gives 64), so the packed path was silently skipped. This is what keeps speed up at long context.

- The mat-vec shader no longer spills registers with 6 columns.



Only tested on my RX 9070. It should also run on RX 7000 (RDNA3) on Windows, but that's untested. Reports from other cards are very welcome.



Prebuilt llama-server for Windows, launch example and details: https://github.com/Filters83/rx7900-xtx/releases/tag/win-vulkan-ae8bdc9

Source: branch `windows-amd-proprietary` on the same repo.



Disclosure: debugging and patches were done with the help of an AI coding assistant (Claude); all tests and benchmarks were run on my machine.

Hope can help ;)