Repository navigation
[FlyDSL] [gfx1250] Compute GEMM: fused MXFP8 epilogue; untuned prefill-sized batched mxfp8_32 runs the compute kernel - #7673
Conversation
d33ce97 to
374fb97
Compare
|
Updated the #7178 merge to its current head ( |
374fb97 to
4c1fabc
Compare
|
Rebased: #7659's current head (76b2f26) + a merge of #7178's current head (803a3cd, no conflicts) + the same single commit on top, which applied cleanly (its only overlap is Checked (no GPU): py_compile / black / ruff on the changed files, modules import from the branch tree, |
4c1fabc to
d430716
Compare
|
Rebased onto the current #7659 head
|
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
… runs it The 256x256 compute kernel can now quantize its C tile to group-32 MXFP8 in the epilogue (fuse_quant_out), the way the generic batched kernel already does for the fused wo_a entry: values are rounded to the output dtype, the group amax is one cross-lane max between lanes l and l^16, the e4m3 tile goes out through LDS as one TDM store and the e8m0 scale row by row. The codes match quantize_fp8 of the bf16 output. Default constexprs keep the existing kernels unchanged. The dense mxfp8_32 runner forwards y_scale_out to it (compute kernels with split_k 1 and no persistent tiles only), and the batched runner passes y_scale_out through its compute path instead of rejecting it; only compute kernels without the epilogue (split-K, persistent tiles, preshuffled A) still raise. Without a kernel name, a batched mxfp8_32 call with M above the decode range (1024 rows) now runs the compute kernel (256x256x128, two buffers, 1x4 cluster) when N and K fit it; decode-sized M and calls with a tuned kernel name keep their current kernels. This covers the prefill wo_a GEMM, bf16 and fused-quant entries alike, between the decode rows and the tuned prefill row. op_tests/test_flydsl_batched_gemm.py adds two prefill-sized M to the gfx1250-strict fused-quant defaults so both entries go through the compute kernel there; the full-suite defaults already reach it at M 4096 and 16384. Co-Authored-By: Claude Opus 5.5 <[email protected]>
d430716 to
677187d
Compare
|
Rebased onto main
|
#7659 (and #7178 before it) is merged, so this PR is now one commit on main (
gfx1250 compute GEMM: fused MXFP8 epilogue; untuned prefill-sized bmm runs it).Summary
gemm_a8w8_256x256_gfx1250.py: newfuse_quant_outconstexpr. The compute kernel quantizes its C tile to group-32 MXFP8 in the epilogue and writes e4m3 C plus a row-major e8m0 scale, the same contract as the fused epilogue of the generic batched kernel ([FlyDSL] [gfx1250] flydsl batched mxfp8 GEMM: optional fused mxfp8 quant epilogue #7178).mxfp8_bpreshuffle_gemm_gfx1250.py: the dense mxfp8_32 runner takesy_scale_outand launches the fused variant (compute kernels with split_k 1 and no persistent tiles; anything else raises).batched_gemm_a8w8_gfx1250.py:y_scale_out. Since [FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning #7659, main rejects every fused call on a compute kernel name; that check now rejects only compute kernels without the epilogue (split-K, persistent tiles, preshuffled A), with the same error;t256x256x128, two buffers, 1x4 cluster) when N and K fit it. Decode-sized M and calls that pass a tuned kernel name are unchanged.op_tests/test_flydsl_batched_gemm.py: two prefill-sized M in the gfx1250-strict fused-quant defaults, so both entries go through the compute kernel there. The full-suite defaults already include prefill-sized M.Motivation
#7659 lets tuned rows name the compute kernel for batched 32x32 GEMMs, and tunes the DSv4.1 Flash O-A (wo_a) prefill row. Two gaps remain for wo_a:
batched_gemm_a8w8_mxscale_bpreshuffle_fused_quant, [FlyDSL] [gfx1250] flydsl batched mxfp8 GEMM: optional fused mxfp8 quant epilogue #7178) can only run the generic batched kernel: the compute kernel has no quant epilogue, and the runner's compute branch refusesy_scale_out. So prefill wo_a either loses the compute kernel or loses the fused quant.Changes
landl^16(a 32-column group is two adjacent 16x16 tiles of one wave), andemit_mx_e8m0_scale/emit_cvt_scalef32_pk8_fp8_f32produce the codes. So the output matchesquantize_fp8of the bf16 output. The e4m3 tile goes out through LDS as one TDM store; the scale is written row by row. The scale pointer reusesarg_out, which the non-split-K path does not use, so the launch arguments stay the same.const_exprbranch next to the persistent C-relocation path. With the defaultfuse_quant_out=Falsethe kernels compile as before.pick_bmm_mx32_compute_kernel_name(b, m, n, k)returns the compute name only for M above 1024 and shapes the kernel takes (N a multiple of the cluster's N, K a whole number of K-pairs). cluster_m is 1, so every M-tile count fits. No persistent tiles, so the fused epilogue can use the same config. A tuned row still wins: the runner only asks when no kernel name is given.Merge order
Validation
python3 op_tests/test_flydsl_batched_gemm.pypasses. The explicit compute kernel cases (including [FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning #7659'stest_compute_operand_guards) pass, and the fused quant epilogue is bit-exact againstquantize_fp8of the bf16 output for every default shape, including the M that take the new compute route ("fused quant epilogue ALL BIT-EXACT").op_tests/test_bmm_a8w8_fused_quant_supported.pypasses.PR Self-Review
Reviewed revision
677187d
Behavior and intent
b5b4bf978plus one commit; the commit is the same patch as on the previous head (rebased after [FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning #7659 merged).ValueErrorfor any fused call on a compute kernel name; untuned prefill-sized M ran the generic batched heuristic tile.y_scale_outand write e4m3 C plus the e8m0 scale, matchingquantize_fp8of the bf16 output; split-K, persistent or preshuffled-A compute kernels still raise the sameValueError. Without a kernel name, M above 1024 on shapes the kernel takes runs the compute kernel for both the bf16 and the fused entry.Validation and unverified scope
python3 op_tests/test_flydsl_batched_gemm.pyexits 0. The explicit compute kernel cases andtest_compute_operand_guardspass; every fused-quant shape reports 0 scale and 0 fp8 mismatches againstquantize_fp8of the unfused bf16 output, including M 4096 and 16384, which take the new untuned compute route.pick_bmm_mx32_compute_kernel_namereturns None for decode M and for N/K the kernel cannot take, and the compute name otherwise; a fused call runs on the split_k 1 non-persistent compute kernel and raisesValueErroron the persistent and split-K ones; untuned M above 1024 routes to the compute kernel for both entries.python -m pytest op_tests/test_bmm_a8w8_fused_quant_supported.py: 2 passed.PR-specific question
Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
y_scale_outis given; the batched runner checks the compute kernel name (split_k 1, no persistent tiles, row-major A) and the dense runner checks it again together with a 1-byte Out with unit column stride, a row stride divisible by 32 and an exactly sized, contiguous, 8-byte-aligned e8m0 scale buffer, so unsupported inputs raise before launch. Auto-routing needs no kernel name, M above 1024, N a multiple of the 1x4 cluster's N, K a multiple of the K tile and at least 512 and a whole number of K pairs; otherwise the previous heuristic runs.Changed op tests
op_tests/test_flydsl_batched_gemm.py: the gfx1250-strict fused-quant default shapes add M = 1025 and 2048 (N and K of DSv4.1 wo_a), so on that arch the bf16 reference and the fused entry both take the new compute route and must stay bit-identical toquantize_fp8. The module docstring says so, and thetest_compute_operand_guardsdocstring now names why its persistent compute case has no epilogue (the test itself is [FlyDSL] [gfx1250] mxfp8 compute GEMM: 32x32 scale + bmm, DSv4.1 Flash tuning #7659's and unchanged). Not redundant: before this PR the gfx1250-strict defaults stopped at decode-sized M, so the compute fused epilogue was not reached there.🤖 Generated with Claude Code