Skip to content

[FlyDSL] GLM-5.2 o_proj opt for gfx950 - #6426

Closed
IzacharyI wants to merge 9 commits into
ROCm:mainfrom
IzacharyI:glm5_2_o_proj
Closed

IzacharyI wants to merge 9 commits into
ROCm:mainfrom
IzacharyI:glm5_2_o_proj

Conversation

@IzacharyI

Copy link
Copy Markdown
Contributor

[FlyDSL] Add skinny A16W16 policy for GLM-5.2 o_proj decode on gfx950

Motivation

At decode M a GEMM's cost is streaming its weight once. For the GLM-5.2 o_proj shape (N=6144, K=2048, TP8) the
current rows run M <= 32 at 7.6-8.5 us per call on MI355X, about 3.3 TB/s.

Technical Details

  • New kernel aiter/ops/flydsl/kernels/gemm_a16w16_skinny_gfx950.py: each workgroup owns one block_n-column
    slab of C with the full K; k_waves waves stream K through wave-private LDS rings (global->LDS DMA, no
    barrier in the K loop); the partials are summed once in fp32 in LDS. No split-K scratch, semaphore or atomic.
    bf16 only, no bias, gfx950 only; unsupported inputs raise.
  • Exposed as HGEMM policy sk on the existing kernel-name schema
    (t<block_m>x<block_n>x<block_k>x<stages>_ks1_w1x1x<k_waves>_..._psk), so tuned_gemm, flydsl_hgemm and the
    AOT pass (new hgemm_skinny kind) take it. Other policies take the same path as before.
  • Ten existing rows for this shape now use it: M=1/2/4/8/16/32 in the MiniMax-M3 table (from the [HIP] [FlyDSL] Refactor gfx950 A16W16 GEMM with centralized policy selection and tuning #5145 retune;
    same shape, so its decode changes too) and M=6/10/12/24 in the GLM-5 table (added in [FlyDSL] Tune the GLM-5.2 decode shapes for gfx950 #5328). No row is added
    or removed.

Test Plan

  • op_tests/test_flydsl_hgemm.py: new sk cases (every block_m tier, m below block_m, a slab count that is not a
    multiple of the 8 XCDs, other slab widths and K), eager and CUDA-graph replay against fp32; unsupported inputs
    must raise.
  • test_config_shape_collision, test_a16w16_tuned_config_lookup, AOT on the ten rows.
  • No impact elsewhere: merged bf16 table, FlyDSL kernel-name parsing and AOT job list against main.
  • Per-M kernel time with the tuner's method (run_perftest, rotated cold weights, device time).
  • Numerics against main's rows: error against an fp32 reference and run-to-run reproducibility (20 identical
    calls) at M=1-32.
  • Decode step, as in [FlyDSL] Tune the GLM-5.2 decode shapes for gfx950 #5328: all 298 bf16 GEMMs of one GLM-5.2 EAGLE decode step at production call counts, 8
    weight sets per shape, one CUDA graph, both tables in one process, ABBA, 6 samples per arm, medians, plus a
    same-table control.

Test Result

Decode step (bf16 GEMMs only), medians:

  TP8 conc=1    2218.4 -> 2086.5 us    -5.95%
  TP8 conc=2    2254.5 -> 2126.5 us    -5.68%
  TP8 conc=3    2344.0 -> 2230.1 us    -4.86%
  TP8 conc=4    2383.7 -> 2254.7 us    -5.41%
  TP8 conc=5    2487.0 -> 2364.7 us    -4.92%
  TP8 conc=6    2612.5 -> 2606.7 us    -0.22%
  TP8 conc=7    2664.3 -> 2657.6 us    -0.25%
  TP8 conc=10   2826.1 -> 2817.1 us    -0.32%
  TP4 conc=4/8/10/14                   -0.09% .. +0.13%

Same-table control: -0.15% to +0.40%. From conc=6 the verify M (36-60) is above the retuned rows; TP4 runs
o_proj at K=4096, which this PR does not touch.

Per call (cold weights): M=1-16 1.19-1.27x, M=17-32 1.08-1.19x, M=33-64 unchanged.

Numerics unchanged: on both the old rows and the skinny rows 99.97-100% of outputs equal the fp32 result rounded
to bf16, at most 0.01% are more than one ulp away, and outputs are bit-identical over 20 runs.

All tests pass: sk cases error ratio 0 eager and under graph replay, collision guard 22 OK, lookup tests 3
passed, AOT 10/10. Only the ten keys change: the 895 FlyDSL kernel names shared with main parse identically and
the 5778 other AOT jobs are identical. op_tests/flydsl_tests/test_gemm_a16w16.py fails at
assert out.is_contiguous() identically on main.

Submission Checklist

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.
@IzacharyI
IzacharyI requested a review from a team October 12, 2026 09:04
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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: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 6426 --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.

@IzacharyI IzacharyI changed the title [FlyDSL] Add skinny A16W16 policy for GLM-5.2 o_proj decode on gfx950 [FlyDSL] GLM-5.2 o_proj opt for gfx950 Oct 12, 2026
@zufayu
zufayu requested a review from coderfeli October 13, 2026 01:41
@zufayu
zufayu requested review from xytpai and yadaish October 15, 2026 07:17
@IzacharyI IzacharyI mentioned this pull request Oct 29, 2026
1 task done
@zufayu
zufayu removed the request for review from yadaish October 29, 2026 10:17
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 48fc5fc28717 · 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. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  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 — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_flydsl_hgemm.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

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

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.
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: 44 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.
@IzacharyI IzacharyI closed this Nov 4, 2026
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.

3 participants