Repository navigation
Description
Part of #623. Depends on #625 (upstream JIT qmm rework changes the starting point) and should follow #629 (MoE prefill fix determines which GEMM path matters most).
Context
The only architecture-specialized quantized GEMM in the CUDA path is qmm_sm90, compiled solely when 90a (Hopper) is in MLX_CUDA_ARCHITECTURES (MLX_CUDA_SM90A_ENABLED gate: src/lib/mlxcel-core/build.rs:265-271; docs docs/installation.md:101-105). A GB10 build passes 121, so supports_qmm_sm90 is false and quantized prefill matmuls fall through to qmm_sm80 (Ampere-class tiles) or qmm_naive (src/lib/mlx-cpp/patches/mlx/backend/cuda/quantized/quantized.cpp:53-113). Blackwell (sm_120/121 consumer-class: no wgmma/TMA from sm_90a, but 5th-gen tensor cores incl. fp4/fp8 paths and larger shared memory) gets a two-generations-old kernel for the compute-bound phase.
Decode is not the target here: it is GEMV-shaped and bandwidth-bound (qmv/fp_qmv, plus upstream qmv_wide after #625). The payoff is prefill and batched prefill on long prompts, plus MoE grouped GEMM shapes.
Upstream is also moving here (QQMM both-sides-quantized work targets compute capability 10.0+; Hopper QMM heuristics; NAX kernels). This issue is research-then-implement: prefer upstream adoption over local kernels.
Scope
Quantify the gap and close what is real. Explicitly allowed outcome: a findings doc concluding the sm_80 path is within noise of achievable on sm_121, with profile evidence, plus an upstream issue if a kernel gap is confirmed. Otherwise: an sm_120-tuned qmm in the overlay.
Implementation plan
- Quantify (needs perf(bench): long-prompt prefill benchmark coverage and serving TTFT/decode-rate telemetry #624 long-prompt bench): prefill tok/s at 2048/8192/32768 on llama-3.1-8b-4bit and qwen2.5-7b-4bit; compute achieved TFLOPS and compare against (a) the same model's bf16 prefill (cuBLAS/cuDNN-backed, the practical ceiling) and (b) ncu-measured tensor-core utilization of the current qmm_sm80 path.
- Determine the dispatch actually taken on sm_121 post-chore(mlx): upgrade pinned MLX commit, rebase CUDA overlays, GB10 re-baseline and outlier triage #625 (upstream JIT qmm may already pick better tiles): instrument or nsys the kernel names.
- Evaluate upstream options in order:
a. current upstream qmm JIT with sm_120-appropriate tile parameters (may be a heuristics-only patch);
b. upstream QQMM path if it supports sm_120/121 (it targets cc 10.0+; verify whether 12.x consumer parts are included or Blackwell-datacenter only);
c. NAX kernel family applicability. - If a local kernel is warranted, add an sm_120 specialization beside
qmm_sm80in the overlay (patches/mlx/backend/cuda/quantized/qmm/): CUTLASS-based int4-group dequant-in-epilogue GEMM or an mma.sync 16x8x32-tile hand kernel; gate on__CUDA_ARCH__ >= 1200with runtime dispatch inquantized.cpp, and make sure the build's arch handling (sm_arch_with_suffix,build.rs:334-340) compiles it for 121 (note the known divergence: auto-detect emits121a, release workflow passes121; keep both working). - Parity: quantized-matmul unit comparisons vs
qmm_naiveoutputs across group sizes 32/64/128 and bits 4/8 on representative shapes; model-level greedy parity on llama-3.1-8b-4bit.
Acceptance criteria
- Findings doc in
docs/benchmark_results/: achieved-vs-ceiling table, kernel dispatch map on sm_121, and go/no-go rationale. This is required regardless of outcome. - If implementing: >= 25% prefill tok/s improvement at 8192-token prompts on llama-3.1-8b-4bit on GB10, no decode regression, parity green.
- If not implementing: upstream issue filed with the ncu evidence and linked in the doc; epic checklist updated.
-
cargo test --features cudapasses; both121and121aarch strings build.
Validation
cargo build --release --features cuda
ncu --set roofline ./target/release/mlxcel-bench-decode --model ./models/llama-3.1-8b-4bit --prompt-tokens 8192 --max-tokens 1
./target/release/mlxcel-bench-decode --model ./models/llama-3.1-8b-4bit --prompt-tokens 8192
References
- Arch gating:
src/lib/mlxcel-core/build.rs:250-340; dispatchpatches/mlx/backend/cuda/quantized/quantized.cpp:53-113; kernelspatches/.../qmm/. - Release arch matrix:
docs/installation.md:119-122(aarch64:90a;100;121). - Baseline gap datum: dense CUDA prefill median is 1.64x Metal M1 Ultra, but that is against a much weaker Metal GPU; the bf16-vs-4bit prefill ratio on GB10 itself is the honest ceiling comparison.
Activity
docs(cuda/quant): reconcile #637 prefill figures and MLX pin version …
perf(cuda/quant): sm_120/121 qmm CTA tile (M=128) for Blackwell prefi…
docs(server): note CUDA/Blackwell batched-decode does not amortize (#724
fix(cuda): drain cp.async before qmm_sm80 epilogue smem store (#910) (#…
perf(cuda/quant): sm_120/121 qmm CTA tile (M=128) for Blackwell prefi…
docs(server): note CUDA/Blackwell batched-decode does not amortize (l…
fix(cuda): drain cp.async before qmm_sm80 epilogue smem store (lablup…
update(cuda): drop the #637 qmm tile cap for upstream's choice
update: advance MLX pin to 5a48f9cc (#3517)