Repository navigation
[Triton/Gluon] [Bugfix] Fix gfx1250 gemm_a16w16 dropping output rows past 2**31 bytes - #6629
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
|
@k50112113 Could you help review this PR? It is a follow-up to #6032 that fixes an overflow when the buffer exceeds 2GB (when the image is large enough). |
There was a problem hiding this comment.
🔵 Needs a closer look
The reported gfx1250 correctness and performance results need final human confirmation because independent GPU validation was unavailable.
0 open findings
What changed in this PR
Fixes missing output rows in gfx1250 Gluon A16W16 GEMM when output exceeds 2 GiB, including large Wan2.2 workloads.
Changes:
- Rebase the output pointer with 64-bit arithmetic and use block-local store offsets.
- Add a NaN-filled regression test that checks rows around the size boundary and output ends.
| File | Description |
|---|---|
| op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py | Adds large-output regression coverage. |
| aiter/ops/triton/_gluon_kernels/gfx1250/gemm/basic/gemm_a16w16.py | Rebases output stores to avoid offset overflow. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Motivation
What goes wrong
On gfx1250,
_gemm_a16w16_bandwidth_bound_kernelwrites C withbuffer_store(acc, c_ptr, offs_c), whereoffs_c = stride_cm * offs_cm + stride_cn * offs_cnis measured from the start of C.buffer_storeoffsets are 32-bit, so once a row starts past 2**31 bytes of C the store is dropped. The kernel returns without error, and every row from2**31 // (N * 2)on keeps whatever was in that memory before.Where it shows up
Any bf16/fp16 GEMM whose output is larger than 2 GiB and that dispatches to the bandwidth_bound gluon kernel, which is what the gfx1250 configs select for large M (including the Wan2.2 configs from #6032). Wan2.2-T2V-A14B at 1280x720x193 frames hits it on the FFN up-projection (M=90000, N=13824, K=5120, 2.49 GB output): rows 77672..89999 are never written. Through SGLang's tgemm route (
SGLANG_USE_ROCM_AITER_TGEMM=1) the generated video ends in noise, or is fully black when the stale memory holds NaN. The compute_bound kernel stores C through a TDM descriptor and is not affected (verified with a forced compute_bound config on the same >2 GiB shapes).How to fix
Move C's base pointer to this block's (M, N) offset in int64 before
buffer_store, so the 32-bit offsets stay within one block. This is the same rebasing the kernel already does for the A and B descriptors.Modifications
aiter/ops/triton/_gluon_kernels/gfx1250/gemm/basic/gemm_a16w16.py: in_gemm_a16w16_bandwidth_bound_kernel, computec_base = c_ptr + (pid_m * BLOCK_M).to(int64) * stride_cm + (pid_n * BLOCK_N).to(int64) * stride_cnand store with block-local offsets. The store mask is unchanged.op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py: addtest_gemm_a16_w16_large_output(gluon only). It fills the output with NaN, runs the Wan2.2 FFN shape (M=90000, N=13824, K=5120), and checks the first rows, the rows around the 2**31-byte boundary, and the last rows againstF.linear.Accuracy Tests
Kernel-level check on gfx1250 (MI450). Before each call, the cached output block is filled with NaN. bad rows = rows with max abs error > 10% of the reference row max, or any NaN. The reference is
F.linearin fp32.Unit tests:
test_gemm_a16w16.py -k gluon(existing)test_gemm_a16_w16_large_output(new)End to end: Wan2.2-T2V-A14B in SGLang, 1280x720, 193 frames, 8 steps, 2 GPUs with CFG parallel,
SGLANG_USE_ROCM_AITER_TGEMM=1, eager. The comparison is against the same run withSGLANG_USE_ROCM_AITER_TGEMM=0(F.linear).Benchmarking and Profiling
gfx1250 (MI450), bf16, the bandwidth_bound kernel selected by the shipped gluon config, mean of 5 runs:
Shapes whose output fits in 2 GiB are unchanged. On the >2 GiB shapes, the "before" time skipped storing the dropped rows, so the small increase is the cost of writing the full output. End to end (Wan2.2 run above, warm kernel cache): 167.8 s before, 169.1 s after.
Checklist