Retrieved article excerpt
Open article · Retrieved 2026-10-14T15:37:59.885320+00:00
## Repository navigation
# cuda, hip: GDN chunked kernel - #29353
#29353
Merged
[am17an](https://github.com/am17an) merged 8 commits into
[ggml-org:master](https://github.com/ggml-org/llama.cpp/tree/master)ggml-org/llama.cpp:masterfrom
[am17an:aman/gdn-mma-prefill](https://github.com/am17an/llama.cpp/tree/aman/gdn-mma-prefill)am17an/llama.cpp:aman/gdn-mma-prefillCopy head branch name to clipboard
Oct 14, 2026
Merged
## [cuda, hip: GDN chunked kernel](https://github.com/ggml-org/llama.cpp/pull/29353#top)#29353 [am17an](https://github.com/am17an) merged 8 commits into [ggml-org:master](https://github.com/ggml-org/llama.cpp/tree/master)ggml-org/llama.cpp:masterfrom [am17an:aman/gdn-mma-prefill](https://github.com/am17an/llama.cpp/tree/aman/gdn-mma-prefill)am17an/llama.cpp:aman/gdn-mma-prefillCopy head branch name to clipboard
## Conversation
[@am17an](https://github.com/am17an)
### @am17an **[am17an](https://github.com/am17an)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issue-5564081221) • edited Loading Uh oh! There was an error while loading. [Please reload this page](https://github.com/ggml-org/llama.cpp/pull/29353).
Copy link
Copy Markdown
Contributor
upstreaming a kernel developed in downstream [QVAC fabric](https://github.com/tetherto/qvac-fabric-llm.cpp). Credits also to [@lukdmine](https://github.com/lukdmine) for initial idea for the kernel.
## Performance
All rows use `-b 2048 -ub 2048 -fa 1`, full GPU offload and F16 KV cache. Retested on 2026-10-13 against master [296538a](https://github.com/ggml-org/llama.cpp/commit/296538adea19ff397100bf8e7d71f302d2d2bb35) (includes [#30087](https://github.com/ggml-org/llama.cpp/pull/30087)). TL;DR 3-6% better PP on dense 27B, 11-21% on 35B-A3B on RTX 4090/5090/PRO 6000, 3-6% on Spark.
Details 👇
| Performance on | Model | Prompt tokens | master tok/s | pr tok/s | Change |
| --- | --- | --- | --- | --- | --- |
| RTX PRO 6000 Blackwell | Qwen3.5-35B-A3B-Q8\_0 | 2048 | 13,653.58 | 16,459.56 | +20.6% |
| RTX PRO 6000 Blackwell | Qwen3.5-35B-A3B-Q8\_0 | 4096 | 14,090.26 | 16,595.47 | +17.8% |
| RTX PRO 6000 Blackwell | Qwen3.8-27B-Q8\_0 | 2048 | 4,470.39 | 4,757.20 | +6.4% |
| RTX PRO 6000 Blackwell | Qwen3.8-27B-Q8\_0 | 4096 | 4,442.45 | 4,699.08 | +5.8% |
| Spark GB10 | Qwen3.6-35B-A3B-UD-Q4\_K\_M | 2048 | 3,271.18 | 3,406.68 | +4.1% |
| Spark GB10 | Qwen3.6-35B-A3B-UD-Q4\_K\_M | 4096 | 3,254.79 | 3,366.88 | +3.4% |
| Spark GB10 | Qwen3.8-27B-UD-Q8\_K\_L | 2048 | 942.84 | 984.86 | +4.5% |
| Spark GB10 | Qwen3.8-27B-UD-Q8\_K\_L | 4096 | 928.16 | 973.34 | +4.9% |
| Spark GB10 | Qwen3.8-Flash-Next-UD-IQ4\_XS (`-lzm on`) | 2048 | 1,044.71 | 1,104.31 | +5.7% |
| Spark GB10 | Qwen3.8-Flash-Next-UD-IQ4\_XS (`-lzm on`) | 4096 | 1,068.70 | 1,124.01 | +5.2% |
| RTX 5090 | Qwen3.5-35B-A3B-Q4\_K\_S | 2048 | 12,477.32 | 14,524.81 | +16.4% |
| RTX 5090 | Qwen3.5-35B-A3B-Q4\_K\_S | 4096 | 12,978.57 | 15,298.00 | +17.9% |
| RTX 5090 | Qwen3.8-27B-Q4\_K\_M | 2048 | 4,095.61 | 4,320.75 | +5.5% |
| RTX 5090 | Qwen3.8-27B-Q4\_K\_M | 4096 | 4,114.11 | 4,353.09 | +5.8% |
| RTX 4090 | Qwen3.5-35B-A3B-Q4\_K\_S | 2048 | 10,872.34 | 12,044.25 | +10.8% |
| RTX 4090 | Qwen3.5-35B-A3B-Q4\_K\_S | 4096 | 11,187.34 | 12,428.05 | +11.1% |
| RTX 4090 | Qwen3.8-27B-Q4\_K\_M | 2048 | 3,336.69 | 3,438.65 | +3.1% |
| RTX 4090 | Qwen3.8-27B-Q4\_K\_M | 4096 | 3,340.90 | 3,446.88 | +3.2% |
| RTX 3090 | Qwen3.5-35B-A3B-Q4\_K\_S | 2048 | 5,672.07 | 6,061.59 | +6.9% |
| RTX 3090 | Qwen3.5-35B-A3B-Q4\_K\_S | 4096 | 5,505.49 | 5,683.79 | +3.2% |
| RTX 3090 | Qwen3.8-27B-Q4\_K\_M | 2048 | 1,400.46 | 1,412.40 | +0.9% |
| RTX 3090 | Qwen3.8-27B-Q4\_K\_M | 4096 | 1,337.41 | 1,367.46 | +2.2% |
Strix Halo (Radeon 8060S) was not retested this round. On the previous master it was +6.75% (pp2048) and +6.98% (pp4096) on Qwen3.8-27B-UD-Q8\_K\_L.
The RTX 3090 reported thermal throttling during these measurements, so its numbers should be read with that limitation.
## Correctness
`llama-perplexity --kl-divergence` on wikitext-2
- Matched scored-token perplexity: master 5.777325, pr 5.781777.
- Perplexity difference: +0.004451 +/- 0.010372; the difference is smaller than the reported uncertainty in this short comparison.
- Mean KL divergence: 0.000463 +/- 0.000029; median 0.000196; maximum 0.011380.
- Top-token agreement: 98.824% +/- 0.338%.
## Requirements
- I have read and agree with the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md)
- AI usage disclosure: YES, paired with Codex.
[@gianni-cor](https://github.com/gianni-cor) [@amangupta-tether](https://github.com/amangupta-tether) [@am17an](https://github.com/am17an)
`cuda, hip: GDN chunked kernel`
…
`7e1113f`
```
Ported-from: tetherto#257
Source-commit: 53f0027
Co-authored-by: Aman Gupta <[email protected]>
```
[@am17an](https://github.com/am17an)
[am17an](https://github.com/am17an)
requested review from
a team and
[ggerganov](https://github.com/ggerganov)
as [code owners](https://github.com/ggml-org/llama.cpp/blob/4c5957c2779c7806919e37b0c2a07b1fe6ee7945/CODEOWNERS#L62)
[September 24, 2026 06:23](https://github.com/ggml-org/llama.cpp/pull/29353#event-31733396801)
[@github-actions](https://github.com/apps/github-actions)
[github-actions](https://github.com/apps/github-actions)
Bot
added
[testing](https://github.com/ggml-org/llama.cpp/issues?q=state%3Aopen%20label%3Atesting)
Everything test related
[ggml](https://github.com/ggml-org/llama.cpp/issues?q=state%3Aopen%20label%3Aggml)
changes relating to the ggml tensor library for machine learning
[CUDA](https://github.com/ggml-org/llama.cpp/issues?q=state%3Aopen%20label%3ACUDA)
Related to the CUDA backend
labels
[Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#event-31733633791)
[@am17an](https://github.com/am17an)
`fix older builds`
`43c3f76`
[@DanoPTT](https://github.com/DanoPTT)
### **[DanoPTT](https://github.com/DanoPTT)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issuecomment-5809739056)
Copy link
Copy Markdown
| |
| --- |
| I noticed the kernel only activates when `K == 1` (`ggml_get_op_params_i32(dst, 0) == 1`). With MTP/EAGLE3/DFlash speculation, `n_rs_seq = draft.n_max`, so `K = n_max + 1` even during prefill ([src/models/delta-net-base.cpp#L564](https://github.com/ggml-org/llama.cpp/blob/f830688e91214cccfa25ed0a2b9a708ee5a855c3/src/models/delta-net-base.cpp#L564)), which means the kernel won't be used there. Is that an intentional limitation, or is `K > 1` planned? |
[@am17an](https://github.com/am17an)
### **[am17an](https://github.com/am17an)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issuecomment-5809764048)
Copy link
Copy Markdown
Contributor
Author
| |
| --- |
| it is a prefill kernel. So it won't be activated while drafting (i.e. when K > 1) |
[@DanoPTT](https://github.com/DanoPTT)
### **[DanoPTT](https://github.com/DanoPTT)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issuecomment-5810000974)
Copy link
Copy Markdown
| |
| --- |
| I mean prefill with speculation enabled. `K` is set for the context, not per ubatch (line 564), so with `--spec-type draft-mtp` enabled, `K > 1` even for prefill on the target context. |
[@am17an](https://github.com/am17an)
### **[am17an](https://github.com/am17an)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issuecomment-5810233610)
Copy link
Copy Markdown
Contributor
Author
| |
| --- |
| Yes that's correct - prefill with speculation enabled would not use this kernel for now. It would require some changes from the llama.cpp side to use it for prefill, perhaps something like `llama_set_rs_snapshots` |
[IMbackK](https://github.com/IMbackK)
**[IMbackK](https://github.com/IMbackK)**
previously requested changes
[Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#pullrequestreview-5302950079)
[View reviewed changes](https://github.com/ggml-org/llama.cpp/pull/29353/files/43c3f76c0e1fc84a9a989e93e6036720f8600344)
Comment thread
[ggml/src/ggml-cuda/gated-delta-net-mma.cu](https://github.com/ggml-org/llama.cpp/pull/29353/files/43c3f76c0e1fc84a9a989e93e6036720f8600344#diff-96601b74ec60ee22f558b1207e6792250ed47504b43b2375da45d8816bb8ea6e)
Outdated
Show resolved
Hide resolved
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/ggml-org/llama.cpp/pull/29353).
Comment thread
[ggml/src/ggml-cuda/gated-delta-net-mma.cu](https://github.com/ggml-org/llama.cpp/pull/29353/files/43c3f76c0e1fc84a9a989e93e6036720f8600344#diff-96601b74ec60ee22f558b1207e6792250ed47504b43b2375da45d8816bb8ea6e)
Outdated
Show resolved
Hide resolved
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/ggml-org/llama.cpp/pull/29353).
Comment thread
[ggml/src/ggml-cuda/gated-delta-net-mma.cu](https://github.com/ggml-org/llama.cpp/pull/29353/files/43c3f76c0e1fc84a9a989e93e6036720f8600344#diff-96601b74ec60ee22f558b1207e6792250ed47504b43b2375da45d8816bb8ea6e)
Show resolved
Hide resolved
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/ggml-org/llama.cpp/pull/29353).
[@IMbackK](https://github.com/IMbackK)
### **[IMbackK](https://github.com/IMbackK)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issuecomment-5814095711) • edited Loading Uh oh! There was an error while loading. [Please reload this page](https://github.com/ggml-org/llama.cpp/pull/29353).
Copy link
Copy Markdown
Contributor
| |
| --- |
| Also, would be pretty easy to port this to rdna4's wmma regsiter layout and wave64 for mfma, might not perform better but might as well support everything in the kernel since its minimal effort, do you want to do it or shall i do a followup? |
[@am17an](https://github.com/am17an)
### **[am17an](https://github.com/am17an)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issuecomment-5814125099)
Copy link
Copy Markdown
Contributor
Author
| |
| --- |
| [@IMbackK](https://github.com/IMbackK) I don't have RDNA4 hardware. You can do it in a follow-up. |
[@DanoPTT](https://github.com/DanoPTT)
### **[DanoPTT](https://github.com/DanoPTT)** commented [Sep 24, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#issuecomment-5815013115)
Copy link
Copy Markdown
| |
| --- |
| When required, I can check it on gfx1201/RDNA (R9700, Windows 11, ROCm 10.0.0/HIP) |
[am17an](https://github.com/am17an)
added 2 commits
[September 24, 2026 23:22](https://github.com/ggml-org/llama.cpp/pull/29353#commits-pushed-9962e80)
[@am17an](https://github.com/am17an)
`review fixes`
`9962e80`
[@am17an](https://github.com/am17an)
`cuda: enable GDN MMA on tested Ampere and Ada GPUs`
…
`377e111`
```
Enable SM86 and SM89 after RTX 3090 and RTX 4090 correctness and prefill benchmarks. Keep other untested architectures on the existing fallback.
Assisted-by: Codex
```
[JohannesGaessler](https://github.com/JohannesGaessler)
**[JohannesGaessler](https://github.com/JohannesGaessler)**
reviewed
[Sep 25, 2026](https://github.com/ggml-org/llama.cpp/pull/29353#pullrequestreview-5319199767)
[View reviewed changes](https://github.com/ggml-org/llama.cpp/pull/29353/files/377e111e8ce466652b9c4a6ef5e62521d588bf91)
### @JohannesGaessler **[JohannesGaessler](https://github.com/JohannesGaessler)** left a comment
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment.
### Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. [Learn more](https://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment).
I currently still consider the swizzling code in `mma.cuh` to be unstable. If you intend to use it in this PR I would ask that we delay merging it until I've taken another