Repository navigation
[SM100] Use the K=64 MXF8F6F4 MMA in the dense 1D1D kernel on CC 10.7 - #133
Merged
Merged
Conversation
On sm_107f, `kind::mxf8f6f4` with descriptor bit 31 set issues K=64 per instruction and reads two per-32 UE8M0 scale factors. Enable it in the dense 1D1D kernel for e4m3 x e4m3, K-major, per-32-scaled, non-k-grouped GEMMs, except when swap-AB makes UMMA_N smaller than 192. Other architectures compile the existing K=32 path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Match `__CUDA_ARCH__ == 1070` (the JIT builds `sm_107a` only for CC 10.7), drop the `not kIsMXF4` term implied by e4m3 x e4m3, and drop the swap-AB `BLOCK_M >= 192` clause: re-measured at swap-AB BLOCK_M 48-160, wide K is -0.4..-3.0% or within +0.5%, and the earlier +17.6% was run-to-run noise. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace `kUseWideK` with `kIsMXF8KMajor` (e4m3 x e4m3, per-32 scales, K-major on both sides), decide the wide K once in `UMMA_K`, and derive `instr_desc.k_size_` from it. `UMMA_K` and the descriptor are unchanged for every instantiation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Removed redundant definition of kIsSM107 in the CUDA architecture check.
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.
Summary
On CC 10.7 (
sm_107a),kind::mxf8f6f4with instruction-descriptor bit 31 (k_size_) set issues K=64 per MMA and reads two per-32 UE8M0 scale factors.cute::UMMA::make_instr_desc_block_scaledhas no K argument and always leaves the bit at 0, which means K=32. This PR sets the bit in the dense 1D1D kernel.sm100_fp8_fp4_gemm_1d1d.cuh:kIsMXF8KMajor(next tokIsMXF4) marks e4m3 × e4m3 GEMMs that are K-major with per-32 scales on both sides.UMMA_Kis 64 for those when compiling for__CUDA_ARCH__ == 1070(the JIT buildssm_107aonly for CC 10.7) and the GEMM is not k-grouped.instr_desc.k_size_is set fromUMMA_K == 64on the MXF8F6F4 path. The existing per-32 scale-factor id arithmetic already gives ids 0 and 2 for a K=64 step, which is what the wide MMA reads.not kIsMXF4in thek_size_expression).Motivation
DeepSeek-V4.1-Flash's dense attention projections (wqkv_a, wq_b, wo_a, wo_b, indexer q_b) run through this kernel with MXFP8 × MXFP8 operands. At prefill-sized M the tensor pipe is the limit, and K=64 does more work per issued MMA.
Validation
Setup:
sm_107a, CUDA 13.4, this branch's header on the 0.2.5.post2 package. MXFP8 inputs use per-32 scale jitter of 2^[-4, 4].Accuracy: relative error against an fp32 reference changes by at most 1.7e-9 on every shape below (bf16 last-bit differences only).
Timing: the base and PR arms alternate 8 times per row, each in a fresh process (ABAB/BABA, CUDA graph, kineto median of 5 rounds). Δ is the median of the 8 per-pair deltas, and the range is the min..max over those pairs.
Swap-AB with a small BLOCK_M. Rows that run swap-AB with BLOCK_M 48–160 were also measured one shape per process, where pairs are tight.
So wide K is not gated on UMMA_N. The wqkv_a M=4096 row in the main table (-12.4%) is noisy; -0.8% is the better estimate.
Unit tests:
tests/test_fp8_fp4.pytest_gemmandtest_m_grouped_gemm_maskedpass (run on the first commit; later commits only widen the gate and rename the flag). Their configurations (128/128 and 128/32 granularities, FP4 operands) do not take the wide-K path, so the e4m3 × e4m3 per-32 case is covered only by the A/B above.🤖 Generated with Claude Code