Repository navigation
Initial support for CMake - #75
Merged
Merged
Conversation
etra0
marked this pull request as draft
March 13, 2023 02:33
Member
|
Excellent! Why is it "Draft"? |
Contributor
Author
|
Woops, sorry, ready for review now |
etra0
marked this pull request as ready for review
March 13, 2023 17:05
ggerganov
approved these changes
Mar 13, 2023
ggerganov
added a commit
that referenced
this pull request
Mar 13, 2023
blackhole89
pushed a commit
that referenced
this pull request
Mar 15, 2023
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
phuongncn
pushed a commit
to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4
that referenced
this pull request
Apr 28, 2026
When I changed iqk_mul_mat to use type-1 dot products for type-0 legacy quants, I forgot to also change the vec_dot_type when the dot product is done via ggml as in flash attention. This commit fixes it. Co-authored-by: Iwan Kawrakow <[email protected]>
ljubomirj
pushed a commit
to ljubomirj/llama.cpp
that referenced
this pull request
May 6, 2026
ljubomirj
pushed a commit
to ljubomirj/llama.cpp
that referenced
this pull request
May 6, 2026
zhsy12345689
pushed a commit
to zhsy12345689/llama.cpp-omni
that referenced
this pull request
Jul 30, 2026
Signed-off-by: tc-mb <[email protected]>
tgrid0
pushed a commit
to tgrid0/llama.cpp
that referenced
this pull request
Oct 6, 2026
PR ggml-org#75 gated the BF16 WMMA matmul path (mmb) to LLM_ARCH_QWEN4EXP only, which fixed real prefill regressions on some models but also removed the path from models where it is a large win (e.g. Qwen3.8-27B Q8_0). Only Q8_0 and IQ4_NL have a dedicated fast decoder in mmb_dispatch_quant (the special int constants 1 and 0); every other quant falls back to the generic decode. So the benefit tracks the weight quant type, not the arch. This keeps the path opt-in for all architectures but restricts mmb_quant_type() to the quants that actually have a fast decoder, which removes the regressions PR ggml-org#75 addressed while keeping the Q8_0 wins. Strix Halo (gfx1151), pp2048, depth 0, -b 2048 -ub 2048 (llama-bench): model / quant mmb off mmb all this Gemma 4 26B Q8_0 2082 2452 2316 Qwen3.8-27B Q8_0 213 499 453 Qwen3.8-27B IQ3_S 378 301 382 Signal-3.8-27B Q4_K_XL 411 276 411
woct0rdho
pushed a commit
to woct0rdho/llama.cpp
that referenced
this pull request
Oct 17, 2026
PR ggml-org#75 gated the BF16 WMMA matmul path (mmb) to LLM_ARCH_QWEN4EXP only, which fixed real prefill regressions on some models but also removed the path from models where it is a large win (e.g. Qwen3.8-27B Q8_0). Only Q8_0 and IQ4_NL have a dedicated fast decoder in mmb_dispatch_quant (the special int constants 1 and 0); every other quant falls back to the generic decode. So the benefit tracks the weight quant type, not the arch. This keeps the path opt-in for all architectures but restricts mmb_quant_type() to the quants that actually have a fast decoder, which removes the regressions PR ggml-org#75 addressed while keeping the Q8_0 wins. Strix Halo (gfx1151), pp2048, depth 0, -b 2048 -ub 2048 (llama-bench): model / quant mmb off mmb all this Gemma 4 26B Q8_0 2082 2452 2316 Qwen3.8-27B Q8_0 213 499 453 Qwen3.8-27B IQ3_S 378 301 382 Signal-3.8-27B Q4_K_XL 411 276 411 (cherry picked from commit 4048e03)
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 21, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 22, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 22, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 22, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 22, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 22, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 22, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 24, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 25, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 25, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 25, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 25, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 25, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 25, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 25, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 26, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 26, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 26, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 27, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 27, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 27, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 27, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 27, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 27, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 28, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 28, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 28, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 28, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 28, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 29, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 29, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Oct 31, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Nov 1, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Nov 3, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Nov 5, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Nov 5, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
stew675
pushed a commit
to stew675/llama.cpp
that referenced
this pull request
Nov 7, 2026
Also adds mmf32, the F32 counterpart of MMB: the
shapes MMB cannot take -- non-quantized (F32) weights with more than 16 token columns -- currently fall
through ggml_cuda_mul_mat_cublas() to rocBLAS, which dispatches to hipBLASLt.
Two reasons to own that path:
* correctness: hipBLASLt picks its solution per process start from a heap-ordered container, so the prefill
arithmetic (and therefore the logits) changes between fresh runs -- GREEDY-PURITY.md §44, TODO ggml-org#75: 3
logit classes in 8 starts on 35B-A3B, 3 in 18 on gemma4;
* speed: the solution the heuristic lands on is the slowest in the pool for these shapes (0.13-0.19 ms vs
0.046 ms for a well-chosen one).
mmf32 is a plain SIMT tiled GEMM (RDNA has no F32 MMA form: amd_mfma_available is CDNA-only,
amd_wmma_available is f16/bf16). 32 output rows per block, a 4x8 thread sub-tile, BN=256 for m <= 64 (the
GDN ssm_alpha/ssm_beta projections) and 64 above it (the MoE routers), and the k range split into contiguous
chunks summed in increasing z -- a fixed reduction tree, no atomics, so a run is bit-stable by construction.
No approximation: an F32 FMA accumulation in a pinned order.
Scope: F32 weights only, m <= 256, 17 <= n <= 65536, 256 <= k <= 8192, ldc == m; every other mul_mat keeps the
rocBLAS call unchanged (BF16/f16 prefill -- Flash-Next -- is untouched, as is its hipBLASLt advantage; a
full-F32 model's FFN GEMMs, m >> 256, stay on rocBLAS: a recorded limitation).
Measured on gfx1201 (35B-A3B Q4_K_M, one GPU): deterministic -- one logits class in 12/12 fresh starts (6/6 at
2 GPU -sm tensor), --chunks 8 dumps byte-identical; +4.2 % pp512 / +4.1 % pp2048, decode flat (3 interleaved
llama-bench visits); kernel 0.032 ms vs 0.046 ms for the best hipBLASLt class on 32x512x2048. Correctness:
16-shape oracle NMSE ~1e-13, and 11x closer to the CPU reference than the rocBLAS path on the
test-backend-ops cases it intercepts. Purity: judged with the family-switch gate at a confident point
(in-domain corpus, base PPL 1.43) at 0.014646 / 98.045 % against a same-kernel control of 0.018100 / 97.808 %.
Default-on for RDNA4 (GGML_CUDA_MMF32=0 disables; opt-in on RDNA3/RDNA3_5 until those boxes run the same
determinism + bench pair). GGML_CUDA_MMF32_LOG prints the resolved plans (diagnostic only).
Amended (r132): the per-arch dispatch is keyed to the device the kernel runs on, not the primary. mmb_enabled,
mmb_cfg, mmb_cfg_dump_once, mmb_dense_flag, mmb_wtype_mask and mmb_dense_tmask read
ggml_cuda_info().devices[ggml_cuda_get_device()].cc, and mmb_cfg() takes one magic static per architecture class
(mmb_arch_defaults() only discriminates RDNA4 and RDNA3_0, so every cc that reaches the fallback shares the same
pre-S11 table). ggml_backend_cuda_graph_optimize() now selects its own context's device before it consults those
predicates, so the MMB marking half agrees with the launch path under the Meta backend, where the pass is
forwarded per child from meta graph_compute and the current device is still the previously computed one.
Reported in PR ggml-org#218 (@slavap): on a mixed-arch box (gfx1100 primary + gfx1030 secondary) the policy froze at the
primary's, so the RDNA2 card ran RDNA3-tuned MMB kernels -- byte-exact zero output-projection logits (PPL ==
vocab) or garbled tail layers, depending on where the output projection sat. On a single-arch box this is
bit-for-bit the previous behaviour (validated here on 3x gfx1201: 12/12 same-seed configs byte-identical,
prefill-logit KLD 0.000000 on both recorded points, no GPU faults).
Co-authored-by: Slava P. <[email protected]>
Fold (r134, issue ggml-org#224): the width probe's n_ctx is now the prefill length plus the decode
width instead of a fixed 4096, and a purity run must pass P >= 4096. The RDNA4 band's
64-column block (query widths 5..8) is only reachable above the launcher's KV-length gate
(K->ne[1] >= 4096), and K->ne[1] is the context's used length, so the P=256 default never
reached that block: the probe reported PASS on every arm while widths 5..8 ran a geometry
that was not bit-identical to widths 1..4. At P=4096 the r126 geometry fails it
(width_purity=FAIL, worst maxdiff 0.199764 on q8_0 K/V, row-0 hash split between W=4 and
W=5), and the shipped band geometry passes with maxdiff 0.
Amended (r171): the MMB stand-down predicates are gone (TODO ggml-org#115). The two type-only helpers this
block carried -- ggml_cuda_mmb_dense_will_take() / _routed_will_take() -- answered a weight-TYPE
question while the dispatch asks a SHAPE question, so a fusion that stood down for MMB stood down for
shapes MMB does not claim at all (T < mmb_min_t(), n_used > 64, a K that is not a whole super-block
count, a non-contiguous dst, ...) and handed the pair to another fusion instead. Worse, it disagreed
with this block's BF16-activation marking, which can leave a preempted reader's F32 buffer unwritten.
The fusion sites now ask ggml_cuda_mmb_supported_mm() / _supported_mmid(), the predicates
ggml_cuda_mul_mat() / _mul_mat_id() themselves dispatch on, and both are null-safe now so a matcher can
probe an arbitrary node pair. This block's HC16 marking also keeps a ROUTED activation's F32 output
(marking the bf16 copy instead, so the MMB reader still finds it): the gate+up MUL_MAT_ID pair reading
it can be served by a mmq fusion rather than by two individual MMB muls. Inert on the measured arms:
gfx1201 byte-identical (27B Q8_0, 35B-A3B Q4_K_M at 1 and 3 GPU, LFM2 Q6_K; prefill-logit KLD
0.000000 / top-p 100.000 % on 27B and 35B-A3B), gfx1151 identical on every arm (LFM2 Q6_K and
35B-A3B Q4_K_M; the pair and the triple produce the same greedy text).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the draft to support llama.cpp being built by CMake. Most of the things were copied from whisper.cpp's CMake so it should be pretty identical.
This currently builds on my M1 Air with the same perf as using the makefile, but it currently doesn't builds on windows because of #74. Doing the revert of said commit makes it compile on Windows as well.This currently works both on my M1 Air and on my Windows 10 machine.