Skip to content

[FlyDSL] [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow - #8929

Merged
zufayu merged 2 commits into
mainfrom
yifehuan/fix-gfx950-flydsl-hgemm-output-offset
Dec 2, 2026
Merged

zufayu merged 2 commits into
mainfrom
yifehuan/fix-gfx950-flydsl-hgemm-output-offset

Conversation

@yifehuan

@yifehuan yifehuan commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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 + col index wraps and the kernel faults. This is the output-addressing fix from the broader work in #6853.

Changes

  • Cast the row to fx.Int64 before multiplying by the output width. The HT epilogue shares this expression with split-K. FlyDSL converts that atomic buffer offset to 32 bits.
  • Extend the existing HGEMM test with one output larger than 2^31 elements for both tile policies. Compare samples around the boundary against a PyTorch FP32 reference, using a NaN-filled output to expose unwritten values.

Performance

MI355X, gfx950, 256 CUs, ROCm 7.2.4 image, FlyDSL 0.5.3. HIP graph replay of BF16 tgemm.mm with 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.

Workload Before After Change
Gate-up M=8192, N=67584, K=7168, HT, split-K=1 5047.1 µs 5055.9 µs +0.18%

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 from 754660965, and JIT compilation with AITER_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.mm at 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,2880 passed 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 reports hipErrorIllegalAddress.

  • 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 --check passed.

Documentation

  • No documentation change is needed. This is an internal address calculation.

Dependencies

  • No new third-party dependencies added

Breaking Changes

None.

PR Self-Review

Reviewed revision

18574b2f84259fed4da12a4cc071838a2b6727c4

Behavior 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.py adds 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.

@yifehuan
yifehuan requested a review from a team November 30, 2026 10:48
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8929 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@github-actions github-actions Bot changed the title [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow [FlyDSL] [Bugfix] Fix gfx950 FlyDSL HGEMM output offset overflow Nov 30, 2026
@aiter-bot

aiter-bot commented Nov 30, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 18574b2f8425 · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — validation answer must name a command, result, or evidence link
  • FAIL — validation answer must explicitly state what remains unverified (or say none with a reason)

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@aoli26 aoli26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zufayu
zufayu merged commit a9fb0c1 into main Dec 2, 2026
64 of 65 checks passed
@zufayu
zufayu deleted the yifehuan/fix-gfx950-flydsl-hgemm-output-offset branch December 2, 2026 06:00
AndreasKaratzas added a commit to AndreasKaratzas/aiter that referenced this pull request Dec 3, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants