Repository navigation
[FlyDSL] Glm5 2 qkv proj opt for gfx950 - #6427
Conversation
New "sk" HGEMM policy: one workgroup per N slab with the full K, fp32 partials reduced in LDS, no split-K scratch. Retune ten N=6144 K=2048 rows (M <= 32) to it: 1.08-1.27x per call on MI355X.
…M <= 8 Enable kernarg preload in gemm_a16w16_gfx950 (1.017x geomean over 363 tuned rows). Retune qkv_a_proj (N=2624 K=6144) M=1/2/4/6/8 rows to the skinny policy: 1.07-1.21x per call.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
Review decision: Request changes — do not approve yetReviewed commit: 1. [P2] Prevent 32-bit address wraparound for weights larger than 4 GiBLocation: gemm_a16w16_skinny_gfx950.py:219–223
Reproduced on gfx950 with:
The final 32 outputs should be 16384, but the kernel returns 8192. Requested change: Rebase the buffer descriptor using 64-bit workgroup offsets, or reject shapes exceeding the addressing limit. Add a boundary regression test. The currently tuned CSV shapes are unaffected, but the public 2. [P2] Restore device validation before launching with raw pointersLocation: gemm_a16w16_skinny_gfx950.py:420–441 The new skinny path bypasses the existing GEMM implementation’s device-consistency checks. It validates dtype, shape, and contiguity, but not whether A, B, and out are on the same CUDA device. The outer stream check only covers A. Intercepting Requested change: Validate that A/B/out are on the same CUDA device before conversion or launch, and add rejection tests. Validation and scopeTargeted gfx950 tests covered all 16 added skinny configurations, dynamic-shape cache reuse, representative graph replay, and AOT-to-run-only execution without obvious failures. Full CI and end-to-end performance claims were not independently verified. Both findings are in the stacked skinny implementation; no separate confirmed defect was found in the qkv tuning or kernarg-preload changes. GitHub action: Select Request changes, not Approve. This is my recommendation; I have not submitted a review on GitHub. |
Recommendation: Approve with non-blocking follow-upsRe-reviewed commit Targeted tests covered the added skinny configurations, dynamic-shape cache reuse, representative graph replay, and AOT-to-run-only execution without obvious failures. Two follow-ups remain:
These are worth tracking, but I would not block this workload-specific optimization on them. LGTM, subject to the required CI checks. Full CI and end-to-end performance gains were not independently verified. This is a recommendation only; no approval has been submitted on GitHub. |
|
Hi, @xytpai , the latest CI-status shows the changed of this pr is covered and passed. If no further CI validation is needed, would you mind helping proceed with the merge? |
Review result: Request ChangesReviewed head: I re-reviewed all eight changed files and ran tests on gfx950. The targeted GLM qkv/o_proj configurations work correctly in the tested cases. However, both previously reported skinny-kernel issues remain reproducible on the current head. 1. [P2] Guard against 32-bit weight-offset wraparoundLocation:
The currently tuned CSV shapes are unaffected, but the new public 2. [P2] Restore device validation before passing raw pointers to the kernelLocation:
For safety, the invalid-device tests intercepted the launch rather than dereferencing CPU pointers on the GPU. Validation performed
AOT limitation: The full AOT module import was blocked by the installed FlyDSL version lacking Bottom lineNo additional confirmed defect was found in the qkv tuning or kernarg-preload changes. Both findings are in the stacked skinny implementation and remain unchanged from the previously reviewed version. I recommend fixing the address-range guard and device checks before merging. Full CI and end-to-end performance claims were not independently verified. |
NOT READY FOR HUMAN REVIEWPR 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 |
The DMA voffset is a single 32-bit VGPR and the offset is cast to a signed i32, so a tensor-based descriptor wraps once n0 * k * 2 passes 2 GiB and the load reads whatever is mapped there. Fold n0 into the 64-bit base, make the voffset slab-relative, and bound the descriptor with num_records so an offset bug returns zeros instead of faulting. Also reject host tensors up front -- the launch hands the kernel raw pointers, so a CPU a/b/out was a GPU memory fault, not a Python error.
|
Hi, @coderfeli, the latest CI-status shows the changed of this pr is covered and passed. If no further validation or changed requests is needed, would you mind helping proceed with the merge? |
coderfeli
left a comment
There was a problem hiding this comment.
Use flydsl_kernel_code_cleanup and unit test skill in aiter to do a clean
Raw arith/scf/index plumbing becomes fx values and plain Python control flow: constant_vector -> fx.Vector.filled, index_cast -> fx.Int32/Int64, truncf -> .to(), cmpi + scf.IfOp -> if. The three raw boundaries that stay -- the DMA inline asm, the mfma intrinsic and the LDS buffer_ops addressing -- are the hand-scheduled parts that have no builder form, and the module docstring now says so. .ir_value() appears only where one of them needs an unwrapped operand. No functional change: 48 benchmark rows reproduce with err 0, the 7 policy rejects and the 2 GiB weight case still pass.
Upstream added a gfx1250-strict target; keep both it and the skinny policy in the kernel-name regex and the two dispatch sites.
The AOT GEMM module now replays each tuned row through the public gemm_a16w16 entry (ROCm#6956), so it no longer dispatches on a per-kernel kind. Drop the skinny registration it needed: tuned_gemm already routes a psk row into flydsl_hgemm, which the replay reaches on its own.
Conflicts: - gemm_a16w16_gfx950.py: keep the fp32 split-K workspace, the one-counter get_split_k_buffers(stream, device) and the up-front kernarg loads; take main's capture_scoped_cache, kernarg preload hints, k_stagger and b_non_temporal. - aot/flydsl/gemm.py: take main's replay-based AOT build (ROCm#6956), which launches through the runtime and so needs no HGEMM-specific arguments. - glm5/kimik3/minimax_m3_eagle tables: rows are merged one by one. Where both sides changed a row, main's row is kept: glm5 2624x6144 M=1/2/4/6/8 use the skinny kernel (ROCm#6427), and kimik3 64x20480x7168 uses the band-stream kernel (ROCm#7546). Neither uses split-K; both are exact and repeatable. - test_graph_alloc.py: call get_split_k_buffers(s, dev), which no longer takes split_k. Co-authored-by: Claude <[email protected]> Signed-off-by: Andreas Karatzas <[email protected]>
* [FlyDSL] Add skinny A16W16 policy for GLM-5.2 o_proj decode on gfx950 New "sk" HGEMM policy: one workgroup per N slab with the full K, fp32 partials reduced in LDS, no split-K scratch. Retune ten N=6144 K=2048 rows (M <= 32) to it: 1.08-1.27x per call on MI355X. * [FlyDSL] Preload A16W16 kernargs; skinny rows for GLM-5.2 qkv_a_proj M <= 8 Enable kernarg preload in gemm_a16w16_gfx950 (1.017x geomean over 363 tuned rows). Retune qkv_a_proj (N=2624 K=6144) M=1/2/4/6/8 rows to the skinny policy: 1.07-1.21x per call. * fix(flydsl): base the skinny B descriptor at the workgroup slab The DMA voffset is a single 32-bit VGPR and the offset is cast to a signed i32, so a tensor-based descriptor wraps once n0 * k * 2 passes 2 GiB and the load reads whatever is mapped there. Fold n0 into the 64-bit base, make the voffset slab-relative, and bound the descriptor with num_records so an offset bug returns zeros instead of faulting. Also reject host tensors up front -- the launch hands the kernel raw pointers, so a CPU a/b/out was a GPU memory fault, not a Python error. * refactor(flydsl): move the skinny kernel onto the typed fx API Raw arith/scf/index plumbing becomes fx values and plain Python control flow: constant_vector -> fx.Vector.filled, index_cast -> fx.Int32/Int64, truncf -> .to(), cmpi + scf.IfOp -> if. The three raw boundaries that stay -- the DMA inline asm, the mfma intrinsic and the LDS buffer_ops addressing -- are the hand-scheduled parts that have no builder form, and the module docstring now says so. .ir_value() appears only where one of them needs an unwrapped operand. No functional change: 48 benchmark rows reproduce with err 0, the 7 policy rejects and the 2 GiB weight case still pass. --------- Co-authored-by: Yutao Xu <[email protected]>
[FlyDSL] Preload A16W16 kernargs; skinny rows for GLM-5.2 qkv_a_proj M <= 8
Stacked on the o_proj PR #6426 (
glm52-o-proj-decode), which adds theskpolicy. Numbers are against that branch.Motivation
gemm_a16w16_gfx950loads its kernel arguments withs_loadat every wave start; other FlyDSL kernels alreadypreload them into SGPRs through
AITER_FLYDSL_KERNARG_PRELOAD.combine (the issue in [Issue]: gfx950 FlyDSL BF16 GEMM (
gemm_a16w16) reduces split-K / slice-K partial sums in BF16: ~6% of outputs deviate ≥2 ULP from an FP32-accumulation reference at small M #5976): 28-30% of outputs land more than one bf16 ulp from fp32, and they change run torun. The skinny policy is faster there and reduces once, in fp32.
Technical Details
gemm_a16w16_gfx950.compile_hints: kernarg preload from the existing env settings(
AITER_FLYDSL_KERNARG_PRELOAD=0disables it). Applies to every gfx950 FlyDSL A16W16 launch.glm5_bf16_tuned_gemm.csv(M=1/2/4/8 from the [HIP] [FlyDSL] Refactor gfx950 A16W16 GEMM with centralized policy selection and tuning #5145 retune, M=6 from [FlyDSL] Tune the GLM-5.2 decode shapes for gfx950 #5328) move toskkernelspicked by a sweep; M=3/5/7 reach them through padding. Above M=8 split-K stays faster, so those rows are
unchanged.
Test Plan
op_tests/test_flydsl_hgemm.pywith qkvskcases (eager and graph replay, fp32 reference); collision guard;AOT.
identical calls) at M=1/3/6/8.
method, 3 rounds per side, per-row minimum.
separate processes (ABBA over 4 processes), since the preload is code.
Test Result
Decode step (bf16 GEMMs only), medians:
Noise: same-table control -0.26% to +0.16%; across processes the two base runs agree within 0.03-0.96%. With
the base PR, against main: TP8 conc=1 -12.4%, conc=2 -7.2%, conc=3-5 -4.8% to -5.7%, conc=6-10 -1.1% to -2.0%;
TP4 -0.9% to +0.2%.
Per call, qkv_a_proj (cold weights): M=1-8 1.07-1.21x.
Numerics at M=1/3/6/8, split-K rows -> skinny rows: mean error 2.6e-3 -> 1.1e-3; outputs more than one bf16 ulp
from fp32 28-30% -> at most 0.01%; outputs equal to the fp32 result rounded to bf16 about 45% -> 99.95-100%;
distinct outputs over 20 identical calls 20 -> 1.
Kernarg preload over 363 rows: 1.017x geomean, median 1.014x, 5th percentile 0.993x; no group (M <= 256,
M > 256, bias, split-K) is slower.
All tests pass: 16
skcases error ratio 0, collision guard 22 OK, AOT 5 + 6 ok. Only the five keys change: the897 shared FlyDSL kernel names parse identically and the 5783 other AOT jobs are identical.
Submission Checklist