Skip to content

[HIP] [FlyDSL] [CI] Add tunable HGEMM K-stagger and B streaming loads - #7546

Merged
coderfeli merged 6 commits into
ROCm:mainfrom
xytpai:feat/flydsl-hgemm-k-stagger
Nov 7, 2026
Merged

coderfeli merged 6 commits into
ROCm:mainfrom
xytpai:feat/flydsl-hgemm-k-stagger

Conversation

@xytpai

@xytpai xytpai commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Improve gfx950 BF16 decode HGEMM performance with:

  • Tunable K-stagger and B non-temporal loads for the existing FT/HTI kernels, default off.
  • A band-stream (bs) decode policy with staged LDS DMA and a 64-column aligned main panel plus an XCD-grouped strip.
  • Restored skinny tuning coverage and wider small-M N-panel candidates.
  • 21 updated existing Kimi-K3 tuned rows, including padded-M dispatch.
  • Legacy-name compatibility and strided-input normalization on the selected launch stream.

No new documentation, report files or custom benchmark script. Tests extend the existing AITER test files. Existing copyright, license notices and brief source attribution are preserved in the source.

Performance

Speedup = PR-before AITER time / updated AITER time.

Baseline: e1763addecdb2ea25be0c9d0af2a96fb3f62cf80.
Measured implementation: 0525143b64ec2c535a86df297a1941818fa5444d; subsequent source edits are comments/docstrings only (executable ASTs verified unchanged); the latest commit changes CI image acquisition only.

Hardware/software: gfx950 with 256 CUs, BF16 inputs/output, Torch 2.10.0 / ROCm 7.2.4, FlyDSL 0.4.2. Both versions run the real gemm_a16w16_out tuned dispatch with preallocated outputs. Each graph rotates through at least 512 MiB of weights. Compilation/reference checks are outside timing; no profiler or clock changes. Independent processes run in base/head/head/base order, five readings per shape per process, using the median of ten samples per arm.

These are complete operator-dispatch improvements, including the tuned policy selection—not an attribution of the entire gain to K-stagger alone.

M N K Speedup over PR-before AITER
8 18432 1536 1.23x
16 18432 1536 1.24x
32 18432 1536 1.27x
48 18432 1536 1.28x
64 18432 1536 1.27x
96 18432 1536 1.28x
112 18432 1536 1.33x
128 18432 1536 1.34x
8 20480 7168 1.14x
16 20480 7168 1.15x
32 20480 7168 1.08x
48 20480 7168 1.15x
64 20480 7168 1.23x
96 20480 7168 1.40x
112 20480 7168 1.39x
128 20480 7168 1.40x

Range: 1.08x–1.40x. Geometric mean across these 16 points: 1.26x.

The standalone K-stagger prototype, before integration, also showed 1.042x / 1.035x at M=16/32, N=18432, K=1536 with the existing tuned tiles unchanged; independent repeats confirmed the benefit. Other shapes can regress with stagger, so the generic default remains off.

Performance claims cover the listed workload and measurement mode only; no end-to-end model speedup is asserted.

Testing and compatibility

  • Full existing op_tests/test_flydsl_hgemm.py completed, including FT/HTI memory-option boundaries, split/slice-K, exact K-coverage checks, output guards, band-stream M tiers, changed-input Graph replay, real tuned dispatch and skinny checks.
  • 42 host/configuration tests passed, including the real family-wide CSV collision guard.
  • All 2963 baseline FlyDSL HGEMM CSV rows passed legacy-name parsing checks.
  • 2737/2737 old gfx950 configurations executed with their original kernelName/M/N/K/dtype/bias and passed base/head/reference, Graph and guard checks. Original tuner tolerances were retained.
  • 1454/1454 non-split-K rows were bitwise identical; 788/788 paired FT/HTI configurations had byte-identical device machine code.
  • 256/256 M=1..128 replacement-row dispatch cases, and 8/8 strided/transposed input cases, passed.
  • 3000 additional concurrent-copy stress launches passed.
  • Strided-input compatibility was restored: the public bs branch performs necessary contiguous copies on the launch stream, matching the old FT wrapper's behavior.
  • Black, Ruff and git diff --check passed locally.
  • gfx1250 GPU execution was not run. Its 226 old rows have parsing/host-routing coverage and unchanged backend source, but still need hardware CI.
  • Full AOT cache generation and end-to-end model accuracy/performance are unverified. Remote CI status should be read from the current checks.

The GPU inventory/codegen audit ran at 0f673f4; 0525143 changed only the new bs branch's normalization and tests, leaving legacy FT/HTI/sk kernel code unchanged. The later source cleanup is comment/docstring-only, and the latest CI-only change leaves kernel code and tests unchanged.

Run the shipped tests:

export PYTHONPATH=$PWD
python op_tests/test_flydsl_hgemm.py
python -m unittest \
  op_tests.tuning_tests.test_config_shape_collision \
  op_tests.tuning_tests.test_a16w16_tuned_config_lookup -v

CI image-pull failure and fix

The Python 3.12 wheel job failed before the build container started: the
Docker Hub manifest request returned 429 Too Many Requests, and docker run
exited 125. The same failure reproduced on a failed-jobs rerun. The test gate
then failed because the required wheel was unavailable; downstream GPU tests
were skipped, not passed.

The CI-only fix reuses an already-present build image, otherwise calls the
repository's existing pull-retry helper with five attempts and 60-second
delays. The build then uses --pull=never so there is no second implicit
registry request. The image tag, fork-secret restrictions, compilation
failure propagation and test gate remain unchanged. Persistent pull failure
still fails the job.

Local workflow-step simulations passed: cached image (zero pulls), transient
429 (recovery on attempt three), persistent failure (five attempts, no build),
and genuine build failure (original exit code propagated, no build retry).
YAML parsing and shell syntax checks passed. The new wheel job actually retried
all five pulls and received HTTP 429 every time; compilation and downstream GPU
tests have still not started. CI remains blocked by sustained Docker Hub
throttling
, not fixed by the retry mitigation.

The runner needs the approved build image preloaded, an approved registry
cache/mirror, or a securely authenticated image pull outside untrusted PR execution
before retrying the wheel job. Fork secrets must not be exposed and the test gate
must not be bypassed.

Failed pull job: https://github.com/ROCm/aiter/actions/runs/42170667921/job/127738002339

PR Self-Review

Reviewed revision

8998457c21069e57b1eb02c6f89f94044ffd9e21

Behavior and intent

Add optional memory-side tuning to general HGEMM and a constrained streaming decode policy, restore missing candidate coverage, and activate validated configurations through 21 existing tuned rows. Preserve legacy names and old FT/HTI/sk defaults. The band policy uses BF16 inputs/output with FP32 accumulation and no cross-workgroup reduction; it is not a universal replacement for generic HGEMM.

Validation and unverified scope

The performance table is a fresh AITER-before/after measurement using the actual tuned dispatch, separate baseline/head trees and ABBA process order. Correctness and compatibility coverage is listed above: 2737 old gfx950 configurations, 256 replacement-row M cases, 8 strided cases, 42 host/configuration tests and 3000 stress launches. Source cleanup edits have unchanged executable ASTs; host/configuration tests were rerun. The latest CI image-acquisition change passed the four simulated success/failure cases described below. Other-GPU runtime, full AOT generation and model-level results are not claimed.

PR-specific question

Which architecture, dtype and shape boundaries select the changed path, and what invariant prevents unsupported inputs from reaching it?

Generic non-default memory options require gfx950 FT/HTI or a validated bs configuration; they are rejected on gfx1250/skinny. Existing generic DMA, shape and K-tail validation remains.

The bs policy requires a 256-CU gfx950 device, 1 <= M <= 128, (N,K)=(18432,1536) or (20480,7168), BF16 two-dimensional A/B on the same CUDA device, no bias, BF16 output, split_k=k_waves=1, group_m=0 and a supported tile/stage/wave tier. Public input normalization precedes launch on the selected stream. The band wrapper checks actual dimensions, alignment and output contiguity; name parsing checks compatible architecture/dtype/configuration fields. Invalid inputs raise rather than reach the kernel.

Changed op tests

  • op_tests/test_flydsl_hgemm.py: standard AITER @benchmark candidate loop with run_perftest, checkAllclose, us/TFLOPS/TB/s/err and markdown summaries. New cases cover K-wrap/split/HTI boundaries, band-stream M tiers, guards and changed-input graphs. Actual tuned/preallocated-output and strided-input checks verify behavior that direct arithmetic tests cannot establish.
  • op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py: verifies missing-candidate fixes, band boundaries, all persisted-name defaults/round-trips, parameter forwarding, gfx1250 host routing, and bs normalization/stream forwarding. These host catalog/API invariants are distinct from GPU arithmetic tests.

Dependencies and documentation

No new third-party dependency or documentation file. Uses existing AITER launch utilities and the pinned FlyDSL version.

@xytpai
xytpai requested a review from a team November 6, 2026 04:11
@github-actions

github-actions Bot commented Nov 6, 2026

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:windows Windows JIT op smoke test on the gfx1201 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 7546 --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.

@github-actions github-actions Bot changed the title [FlyDSL] Add tunable HGEMM K-stagger and B streaming loads [HIP] [FlyDSL] Add tunable HGEMM K-stagger and B streaming loads Nov 6, 2026
@aiter-bot

aiter-bot commented Nov 6, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 9efe7875863a · 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 permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
  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 — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • 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.

@xytpai xytpai added the ci:atom label Nov 6, 2026
coderfeli
coderfeli previously approved these changes Nov 6, 2026
@github-actions github-actions Bot changed the title [HIP] [FlyDSL] Add tunable HGEMM K-stagger and B streaming loads [HIP] [FlyDSL] [CI] Add tunable HGEMM K-stagger and B streaming loads Nov 6, 2026
@github-actions github-actions Bot added the CI label Nov 6, 2026
@coderfeli
coderfeli merged commit bdba803 into ROCm:main Nov 7, 2026
AndreasKaratzas added a commit to AndreasKaratzas/aiter that referenced this pull request Nov 8, 2026
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]>
ruanjm pushed a commit that referenced this pull request Nov 10, 2026
…#7546)

* [FlyDSL] Add tunable HGEMM K-stagger and B streaming loads

* [FlyDSL] Close Kimi decode gap with band-stream dispatch and retuning

* [FlyDSL] Preserve strided HGEMM inputs and audit legacy config compatibility

* [FlyDSL] Focus HGEMM reporting on measured AITER speedups

* [CI] Retry transient build-image pulls before wheel compilation
yifehuan pushed a commit that referenced this pull request Dec 2, 2026
…ws on gfx950 (#8915)

The rows of 6016 x 7168 and of 6288 x 7168 at 1, 2, 4, 8, 16 and 32 rows
name the same tile with _bnt. They are older than the option (#5145,
#6019 and #5903; the option is #7546), so the tuner never raced it for
them. A decode step reads the weights of every layer once, and the tuner
measures that: run_perftest gives every timed launch its own copy of the
tensors.

MI355X, one GPU, FlyDSL 0.5.3, the tuner's method (10 warm-up and 101
timed eager launches), 3 runs per kernel, the two kernels alternate,
median, microseconds, row today -> _bnt:
   1 x 6016 x 7168   16.31 -> 15.40
   2 x 6016 x 7168   16.39 -> 15.53
   4 x 6016 x 7168   16.46 -> 15.70
   8 x 6016 x 7168   16.62 -> 16.02
  16 x 6016 x 7168   17.93 -> 17.20
  32 x 6016 x 7168   18.30 -> 16.93
   1 x 6288 x 7168   16.78 -> 15.63
   2 x 6288 x 7168   16.96 -> 15.57
   4 x 6288 x 7168   17.00 -> 15.68
   8 x 6288 x 7168   17.33 -> 16.27
  16 x 6288 x 7168   18.34 -> 17.46
  32 x 6288 x 7168   20.41 -> 19.68
That is 3.6 % to 8.2 % less time per launch. The six rows of 6016 x 7168
and the row of 32 x 6288 x 7168 were measured on main b4d0133. The
other five rows were measured in a second session, on main 8b6b4b4
with those seven rows changed. solidx is the index of the new name in
the tuner catalog; us, err_ratio, tflops and bw are the _bnt
measurements.

tgemm.mm selects these rows for 1 to 32 rows of both shapes. A caller
that launches one weight tensor back to back while it fits the
last-level cache can get slower. Measured with one weight tensor: +7.7 %
for 32 x 6288 x 7168, +11.5 % and +12.8 % for 16 x 6016 x 7168, -3.9 %
and -2.8 % for 32 x 6016 x 7168. The other nine rows were not measured
in that state.

Signed-off-by: Jin Pan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants