Repository navigation
cuda: thin F32 mat-muls take mmvf up to 8 columns on Ampere+ (+6% MTP decode on H200) - #380
Merged
Merged
Conversation
Collaborator
Author
|
Independent cross-check from a parallel branch that made the same change. That branch kept F32 matrices with ≤64 rows on Results on H200, 9B PQ2_0 at depth 4096:
That branch won't be opened as a separate PR. This one is the vehicle. |
3 tasks done
…columns on Ampere+ On Ampere and newer, F32 mat-muls with 4+ columns went to the tiled mul_mat_f, which tiles over output rows: a 32-row src0 (the GDN ssm_alpha/ssm_beta projections, 2 per GDN layer, i.e. 48 per verify step on Bonsai 2 9B) gets one or two blocks. mmvf is 2-5x faster there up to its batch limit. Same rule shape as the existing small-src0 F16 case. H200, F32 [4096 x m] x [4096 x n]: m=32 n=4 14.3 -> 3.1 us, n=5..8 -53..-72%; m=128/512 n=4..8 -46..-76%; n<=3 and n>=12 unchanged (other kernels). Ternary-Bonsai-2-9B PQ2_0-MTP, llama-server: MTP depth 3 +5.6..+7.0% decode, DFlash2 depth 7 +0.4..+5.8%. Not bit-exact for 4-8 columns (different reduction than mul_mat_f; greedy output diverges late in 2/4 prompts, deterministically). test-backend-ops MUL_MAT 1651/1651. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PRQc3TQpn72qBxrUn5vKqo
bri-prism
force-pushed
the
cuda/f32-thin-mmvf
branch
from
October 24, 2026 16:43
176a33a to
1625727
Compare
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.
Overview
On Ampere and newer GPUs, F32 mat-muls with 4 or more columns go to the tiled
mul_mat_f, which tiles over output rows. A thin src0 therefore gets only one or two blocks. On Bonsai 2 (Qwen3.5 GDN) the case that matters isssm_alpha/ssm_beta: F32 4096×32, two per GDN layer, so 48 per verify step on the 9B. Under MTP depth 3, nsys puts them at 8.2% of GPU time, at 17.5 µs each for 512 KB of weights.This PR routes F32 with src0 ≤ 512 rows and ≤ 8 columns (
MMVF_MAX_BATCH_SIZE) tommvf, which follows the existing small-src0 rule for F16 (+5 lines inmmvf.cu).Validation
All runs are on an H200 with CUDA 12.8 and a Release sm_90 build, at prism
73bfe6ccplus this patch.Kernel (
test-backend-ops perf, F32 [4096 × m] × [4096 × n]):* One outlier run at m=128, n=16 (outside the rule, so the same kernel as before).
End to end: Ternary-Bonsai-2-9B PQ2_0-MTP-Q8_0 on llama-server, 4 prompts × 128 greedy tokens, 2 rounds, vs stock prism:
Correctness
test-backend-ops MUL_MAT1651/1651, including new eval cases at m=32/512/513 and n=1–16.mmvfreduces in a different order thanmul_mat_f. Greedy output is deterministic and diverges late (around token 58–116) in 2 of 4 prompts. This is the same exactness class as today's switch frommmvftomul_mat_fbetween 3 and 4 columns.Requirements
🤖 Generated with Claude Code
https://claude.ai/code/session_01PRQc3TQpn72qBxrUn5vKqo