Chefang mha global load#4357
Open
fangche123 wants to merge 1 commit into
Open
Conversation
Ship regenerated fwd hd192/hd128 bf16 kernels (global_load_lds) and extend fmha_fwd_v3_args with s_q_tile_base so gfx950 group mode can split grid.z when Q tiles exceed 65535; gfx942 and batch paths stay single-launch.
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
fangche123
force-pushed
the
chefang_mha_global_load
branch
from
July 23, 2026 17:22
08ea4f2 to
95428a2
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support and validation utilities for very-large-sequence / very-large-KV FMHA v3 forward execution, including a host-side workaround for the 65,535 limit on grid.z in gfx950 varlen group launches.
Changes:
- Add two forward-only correctness scripts targeting extreme sizes: (>4 GiB per-batch K/V) and (very large
seqlenwith last-row checking). - Extend
fmha_fwd_v3_argswiths_q_tile_baseand initialize it on the host. - Split gfx950 varlen group-mode launches into multiple
grid.zchunks when Q-tiles exceed 65,535, passings_q_tile_baseto the kernel.
Reviewed changes
Copilot reviewed 4 out of 8 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| op_tests/test_mha_varlen_large_kv.py | New script to validate large-seqlen varlen/group FMHA v3 forward by checking only the last query rows. |
| op_tests/test_mha_fwd_large_kv.py | New script to validate >4 GiB per-batch K/V addressing correctness in FMHA v3 forward. |
| csrc/include/mha_fwd.h | Adds s_q_tile_base to the packed v3 forward kernel-arg struct. |
| csrc/cpp_itfs/mha_fwd.cu | Initializes s_q_tile_base and chunks gfx950 varlen group launches across multiple grid.z launches. |
Comments suppressed due to low confidence (1)
op_tests/test_mha_fwd_large_kv.py:115
- The 4GiB-path warning currently triggers only when both K and V are <= 4GiB, but the docstring says both must exceed 4GiB to exercise the boundary. If either one stays <=4GiB, the test won't validate that tensor's >4GiB addressing.
if k_bytes <= _4GiB and v_bytes <= _4GiB:
print("WARNING: neither K nor V exceeds 4 GiB; this will NOT exercise the "
">4GiB path. Increase -k / -n.")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+29
to
+38
| import argparse | ||
| import os | ||
|
|
||
| # hd192 default-on OPUS would bypass fmha_v3_fwd .co; this test targets asm v3. | ||
| os.environ.setdefault("AITER_DISABLE_FMHA_OPUS", "1") | ||
|
|
||
| import torch | ||
|
|
||
| import aiter | ||
| from aiter import dtypes |
Comment on lines
+21
to
+30
| import argparse | ||
| import os | ||
|
|
||
| os.environ.setdefault("AITER_DISABLE_FMHA_OPUS", "1") | ||
|
|
||
| import torch | ||
|
|
||
| import aiter | ||
| from aiter import dtypes | ||
|
|
fangche123
force-pushed
the
chefang_mha_global_load
branch
2 times, most recently
from
July 23, 2026 17:39
417f759 to
0207a01
Compare
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.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist