My main local GPU is a consumer 16 GiB Radeon RX 6900 XT (gfx1030, Navi 21). Until now I kept most AMD routes on Mesa RADV (Vulkan0) because stock upstream llama.cpp (ee46715 on ROCm 7.2) lost to RADV on 18 out of 18 single-token decode (tg128) tests by -6% to -14%.
When I audited libggml-hip.so and ran rocprofv3 traces, five big bottlenecks popped out:
Upstream routed RDNA 2 MMVQ onto a single-warp fallback (nwarps = 1), capping Wave32 residency at 16/32 waves per CU.
3,470 of 7,632 compiled HSACO kernels (45.5%) were spilling to private scratch (273 in FlashAttention and 1,299 in MMQ/MMQ-few alone).
Small-batch quantized-KV FlashAttention (B = 1..8) was converting KV tiles through FP16 staging buffers, thrashing Infinity Cache.
nsm = 40 (WGPs) instead of 80 physical CUs left 40–80% of CUs idle around pp=64.
Unfused Qwen3.5 hybrid Gated-DeltaNet / SSM_CONV ops and standalone quantize_q8_1 launches burned 31% of wall time in AQL dispatch gaps.
What's in the Patch Stack (14 atomic MIT patches, ggml/src/ggml-cuda/ only) Everything is strictly gated to RDNA 2 (gfx1030, zero core/model/server edits, non-RDNA2 HIP/CUDA/Vulkan/CPU untouched):
Multi-warp Wave32 MMVQ & DPP: Decoupled MMVQ_PARAMETERS_RDNA2 (2–4 warps) + native Wave32 v_permlanex16_b32 / v_pk_max_f16.
Zero-scratch Wave32 flash_attn_ext_rdna2: Eliminated all 273/273 FA spills; stages raw Q8_0/Q4_0/Q4_1/F16 KV directly in LDS (0 B FP16 staging) and uses lossless v_dot8_u32_u4 for Q4_0/Q4_1 KV (-32.2% FA active time vs q8_0 at d=16384).
Zero-spill MMQ + bit-parallel IQ + 80-CU guard: Eliminated all 1,299 MMQ/MMQ-few spills, added v_xad_u32+v_perm_b32 IQ2/IQ3 sign unpackers (helpful for fitting 27B + 16K ctx inside 16 GiB), and kept J=32 when J=64 would under-fill 80 CUs.
Qwen3.5 GDN/SSM fusions + inline Q8_1 epilogues: Thin mmvf routing (pp=16..64 +10.1%..+34.7%), fused GDN gate/beta + SSM_CONV -> SiLU -> Q/K L2 norm, and inline Q8_1 quantization inside RMSNorm / GLU (-75.2% decode quantize_q8_1 dispatches, -34.6% AQL gaps, -309 to -752 MiB peak server VRAM).
Selected Benchmarks (RX 6900 XT, ROCm 7.2, llama-bench -r 3 -fa 1) Format: Stock HIP -> Patched HIP (vs Stock HIP | vs Mesa RADV)
Workload KV 9B UD-Q4_K_XL 9B UD-IQ3_XXS 27B UD-IQ3_XXS tg=128 (d=0) q8_0 65.92 -> 70.25 (+6.6% | 0.962x) 83.91 -> 94.11 (+12.2% | 0.982x) 30.69 -> 32.81 (+6.9% | 0.982x) tg=128 (d=16384) q4_0 62.99 -> 68.05 (+8.0% | 1.006x) 80.51 -> 88.77 (+10.2% | 1.019x) 29.16 -> 30.81 (+5.7% | 0.993x) pp=4 (d=8192) q8_0 192.10 -> 229.13 (+19.3% | 1.684x) 220.06 -> 281.68 (+28.0% | 2.147x) 78.75 -> 104.92 (+33.2% | 1.596x) pp=8 (d=8192) q8_0 283.26 -> 347.39 (+22.6% | 1.824x) 310.91 -> 459.77 (+47.9% | 2.227x) 105.65 -> 161.14 (+52.5% | 1.795x) pp=8 (d=16384) q4_0 270.75 -> 340.85 (+25.9% | 1.511x) 305.74 -> 442.56 (+44.8% | 2.177x) 101.62 -> 152.38 (+49.9% | 1.788x) pp=512 (d=0) q8_0 1634.35 -> 1656.87 (+1.4% | 1.031x) 1951.65 -> 2004.62 (+2.7% | 1.401x) 585.44 -> 604.19 (+3.2% | 1.427x) On single-request llama-server (draft-mtp, cache_prompt: false):
27B UD-IQ3_XXS (n=3, short_temp07 70/256): 43.71 -> 56.92 tg tok/s (1.302x vs stock HIP, 1.276x vs RADV; wall 6.03s -> 4.67s, +29.0%).
27B UD-IQ3_XXS (n=3, ctx4k_greedy 6,775/192): 44.25 -> 55.56 tg tok/s (1.256x vs stock HIP; wall 16.92s -> 15.62s vs RADV 21.57s, 1.38x faster than RADV).
9B UD-IQ3_XXS (n=2, ctx4k_greedy 6,775/192): 105.70 -> 123.66 tg tok/s (1.170x vs stock HIP; wall 5.78s -> 5.36s vs RADV 7.17s).
Honest Caveats & What Didn't Work Failed ablations kept out: Non-temporal MALL weight loads (-10% to -22% decode), Gate+Up fusion above B = 1 (-30% to -37% pp=8), and v_dot8 inside MMVQ/MMQ (-13% to -17.5% pp=16..32 because v_dot8 shares the same 1 op/cycle SIMD32 rate as v_dot4 on RDNA 2 and only wins when O(1) prologue packing amortizes over long KV tiles).
Greedy divergence (DIFF!): test-backend-ops (7/7) passed 100% and 6-chunk WikiText-2 KLD hit Mean KLD = 0.000000, but multi-warp reduction reordering still nudges borderline greedy tokens and can swing draft acceptance on individual single-shot runs (one 9B IQ3_XXS short greedy row dipped to 0.984x tg on a -10.6 pp acceptance swing).
Pure q8_0 decode vs RADV: Patched HIP ties or beats RADV on 9B q4_0 decode (1.000x–1.019x), while pure q8_0 tg128 still sits 1–4% behind RADV (0.953x–0.989x) — traded against HIP's 1.34x–2.28x verify and 1.03x–1.44x prefill lead.
Hardware tested: Physically validated on an RX 6900 XT (gfx1030). gfx1031 (6700 XT) / gfx1032 (6600 XT) share the same Wave32 / v_dot4 / v_dot8 ISA, so feedback from anyone testing on those cards would be awesome.
MIT Repo (14 patches, spill auditor, fail-closed A/B harness, AGENT_ADOPT_PROMPT.md): https://github.com/s1mply-parad0x1cal/llama-cpp-navi21-optimizations
Full write-up (ad-free, with ablations and comparison to llama-navi21-furnace / llama-cpp-rdna-boosts): https://nocthoughts.com/2026/12/04/navi21-gfx1030-rocm-hip-optimizations-for-llama-cpp.html