Repository navigation
[FlyDSL] [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow - #8929
Conversation
Signed-off-by: yifehuan <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
Signed-off-by: yifehuan <[email protected]>
Conflicts: - gemm_a16w16_gfx950.py vs ROCm#8929: keep this branch's 4-argument write_cshuffle_vec_to_global (main's out_buf/is_split_k only serve the atomic split-K store this branch removes) and use main's int64 C offset at all three C stores, including store_c_vec of the slice-K combine and split-K reducers, which main does not have. - test_flydsl_hgemm.py: add 31777x67712x512 ft k_waves=2, a C past 2^31 elements through store_c_vec. It fails with an illegal memory access when store_c_vec uses an int32 offset. - kimik3 table vs ROCm#8915: 11 of the 12 _bnt rows take main's row; the 8 without split-K/slice-K as is, 1x6016, 8x6016 and 32x6016 after re-timing under the fp32 reduction. 32x6288x7168 keeps this branch's ks4 row (tuner time tied, faster with warm weights). Co-authored-by: Claude <[email protected]> Signed-off-by: Andreas Karatzas <[email protected]>
Summary
Widen the gfx950 FlyDSL A16W16 output offset before multiplication in the full-tile and half-tile interleaved epilogues.
Motivation
The BF16 gate-up GEMM enabled by #8245 uses the same FlyDSL kernel at actual M=8192 and M=32768. With N=67584, the larger output has 2,214,592,512 elements. The signed 32-bit
row * N + colindex wraps and the kernel faults. This is the output-addressing fix from the broader work in #6853.Changes
fx.Int64before multiplying by the output width. The HT epilogue shares this expression with split-K. FlyDSL converts that atomic buffer offset to 32 bits.Performance
MI355X, gfx950, 256 CUs, ROCm 7.2.4 image, FlyDSL 0.5.3. HIP graph replay of BF16
tgemm.mmwith a preallocated output, 12 groups of 20 replays per arm in base/fix/fix/base order. Both arms use the merged #8245 config and the same JIT path.The same shape measures about 1570 TFLOP/s and 0.434 TB/s of effective operand and output traffic before and after. Its arithmetic intensity is 3618 FLOP/byte.
Testing
Unit tests added or updated
Performance benchmarks run
MI355X, FlyDSL 0.5.3. Used the main CI wheel at
cf0af5fa7, the merged [Config] [Bugfix] Add Kimi-K3.1 gfx950 TP1 BF16 GEMM rows so PP prefill stops falling back to hipBLASLt stream-K #8245 CSV from754660965, and JIT compilation withAITER_FLYDSL_AOT_CACHE=0. The kernel source in this wheel matches the PR base. The only source difference in the fix arm was this patch.BF16
tgemm.mmat N=67584 and K=7168, with M=31775, 31776, and 32768. All calls finished and all 21, 28, and 42 sampled elements matched the reference exactly.AITER_FLYDSL_AOT_CACHE=0 python op_tests/test_flydsl_hgemm.py -s 31777,67584,512 4,5120,2880passed on the fix, including both large-output tile policies and BF16 and FP32 split-K output controls. The large-output case on the unmodified kernel reportshipErrorIllegalAddress.HT split-K=2 at M=257, N=384, K=512 with BF16 inputs. The previous and simplified expressions produced bitwise-identical BF16 and FP32 outputs. All 98,688 elements per output dtype matched a PyTorch reference that sums the two K partitions with the same partial rounding.
Black 26.10.1, Ruff 0.16.0 and
git diff --checkpassed.Documentation
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
18574b2f84259fed4da12a4cc071838a2b6727c4Behavior and intent
The gfx950 non-split-K GEMM can write a contiguous output with more than 2^31 elements. Computing its element index in 64 bits keeps stores in bounds for the 32K Kimi gate-up shape.
Validation and unverified scope
The MI355X JIT tests above cover the failing public dispatch, both non-split-K epilogues, and BF16 and FP32 split-K output controls. The 8K before and after graph timings are in Performance. Full-model serving and the AOT build are outside the local verification.
PR-specific question
Before the fix, the new large-output HGEMM test faults at synchronization because its output rows cross the signed 32-bit element-offset limit. The existing smaller full-tile and interleaved cases stay below this limit. With the fix, both variants match the FP32 reference samples on either side of the limit.
Changed op tests
op_tests/test_flydsl_hgemm.pyadds both non-split-K tile policies at an output size beyond the signed 32-bit range. The test samples rows and columns near the boundary, with the same normal runtime wrapper and tile selection used by the existing test.