Skip to content

[CK] [CI] [Feature] a4w4 blockscale tuner: add --libtype backend selection - #8825

Open
demonsan wants to merge 4 commits into
mainfrom
demonsan/issue-5356-a4w4-tuner-libtype
Open

demonsan wants to merge 4 commits into
mainfrom
demonsan/issue-5356-a4w4-tuner-libtype

Conversation

@demonsan

@demonsan demonsan commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5356

Summary

Adds a --libtype axis to the a4w4 blockscale tuner (csrc/ck_gemm_a4w4_blockscale/gemm_a4w4_blockscale_tune.py), so the backends it enumerates are selected the same way as in the sibling tuners (gemm_a8w8_bpreshuffle_tune.py, ...). --libtype ck,asm,triton,flydsl (or all) picks the backends; omitting it keeps the current candidate set (ck,asm). --backends stays as an alias.

Motivation

#5356: the tuner had no --libtype, and aiter/utility/pretune.py already invokes tuners with --libtype. The tuner already had an ad-hoc --backends option with the same job under another name.

Changes

  • A4W4_LIBTYPES = ("ck", "asm", "triton", "flydsl") and DEFAULT_LIBTYPES = ("ck", "asm") are the single source of truth for what the tuner can enumerate.
  • libtype_list validates --libtype (accepts all). It rejects cktile with a message that says why (see Behavior and intent).
  • resolve_libtypes(libtype, backends) maps the two options to a backend set. --libtype and --backends are mutually exclusive, and bad values now fail in parse_args (exit 2) rather than in tune().
  • tune() skips reading and enumerating ASM kernels when asm is not selected. ASM kernelIds are unchanged (they still start after the CK ids), since they identify kernels at runtime.
  • README: documents --libtype, the --backends alias, the cktile rejection, the two defaults (bare tuner ck,asm; pretune all) and the candidate-count implication.
  • .github/scripts/split_tests.sh: registers the new test, because the aiter job lists tuning tests explicitly.
  • New op_tests/tuning_tests/test_a4w4_tuner_libtype.py (19 tests: argument handling, candidate sets with stubs, and the real Triton/FlyDSL candidate names for an M >= 32 shape checked against the runtime parsers).

Interaction with #7979 (open, same file)

#7979 adds an opus backend, changes the --backends default to ck,asm,opus, and adds opus_candidates. This PR is built so #7979 only needs to add "opus" to A4W4_LIBTYPES (and to DEFAULT_LIBTYPES if it should stay default), then use "opus" in backends as it does now. Expected textual conflicts: the --backends argument block in _setup_specific_arguments, and the backends = ... line in tune(). Whichever PR lands second needs a small rebase. If #7979 lands first, this PR changes the default test (test_default_is_ck_and_asm) and the help text to match.

Performance (if applicable)

Not applicable: no kernel changes. Tuning results are unchanged for the default invocation.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • User guide updated (csrc/ck_gemm_a4w4_blockscale/README.md)

Dependencies

  • No new third-party dependencies added

Breaking Changes

None. The default is the same set of candidates. --backends still works; it is now validated at argument parsing, so a bad value exits with a usage error instead of a ValueError from tune(). The --backends default is now None (the ck,asm default lives in DEFAULT_LIBTYPES).

PR Self-Review

Reviewed revision

b9e0a8c

Changes since 9cb2298: a merge of origin/main (0f8e5c1), fa7290b (ruff findings in the new test) and b9e0a8c (review nits: README defaults, real-candidate test, neutral sentinel). origin/main had not moved when this head was pushed.

Behavior and intent

  • New: --libtype {all,ck,asm,triton,flydsl}[,...] on the a4w4 blockscale tuner. Only the selected backends are enumerated; --libtype ck does not read the ASM kernel list.
  • Unchanged: with neither --libtype nor --backends, the tuner enumerates exactly what main does. Checked against main's tuner on a gfx950 host (see below).
  • Intent of [tune] a4w4_blockscale tuner has no --libtype axis, so CK Tile's MX GEMM can never compete #5356 is the axis, which CK Tile could later join. cktile is rejected on purpose: aiter/ops/gemm_op_a4w4.py dispatches a tuned row by kernelName prefix and csrc/ck_gemm_a4w4_blockscale uses classic CK (device_gemm_xdl_cshuffle_v3_mx), so on main a CK Tile row could not be used. The issue itself says it is not proposing to wire CK Tile in. This PR therefore adds the axis, not the CK Tile backend.
  • --libtype all means every entry of A4W4_LIBTYPES, which includes triton and flydsl. That is wider than the bare-tuner default (ck,asm).
  • Pretune behavior change. aiter/utility/pretune.py always passes --libtype to the tuner (default all). On main the a4w4 tuner rejected that, so a4w4 was not pretunable that way; with this PR pretune of this tuner enumerates ck,asm,triton,flydsl. Triton and FlyDSL add candidates only on gfx950 and for M >= 32 (N % 16 == 0, K % 256 == 0), so pretune takes longer: for (M, N, K) = (32, 1024, 4096) FlyDSL gives 246 candidates without split-K (1230 with --splitK) and Triton 5 (37), counted on mi350x8. pretune --libtype ck now means CK only (no ASM) and pretune --libtype cktile is rejected by this tuner. The README documents both defaults.

Validation and unverified scope

Run in the rocm/atom-dev:sglang-latest image on mi350x8 (gfx950), via gpu-lock docker run, with this tree's Python mounted over the image's aiter (the image's aiter is older than main; it needed a sitecustomize that sets flydsl.__version__ = "0.5.0" for the tree's version check, no package was installed):

  • python3 -m unittest op_tests.tuning_tests.test_a4w4_tuner_libtype -v (image's own aiter, only the tuner and test overlaid): 15 tests OK.
  • python3 -m pytest op_tests/tuning_tests/test_a4w4_tuner_libtype.py (this tree on the image): 15 passed. The same file run against main's tuner: 15 failed, so the test does detect the change.
  • Candidate equivalence: for one shape (M=1, N=512, K=4096) the enumerated (backend, kernelId, kernelName) lists of this tuner and main's tuner are byte-identical for default (23 candidates), ck (20), asm (3) and ck,asm (23); main was run with --backends, this PR with --libtype/no flag.
  • Every other op_tests/tuning_tests/test_*.py, one pytest process per file (as CI does), this tuner vs main's tuner: identical pass/fail counts. Several files fail with both (test_a16w16_tuned_config_lookup 8, test_a6w6_tuning 1, test_grouped_ep_fused_lookup 2, test_mixed_mxfp_tuning 9, test_tune_pipeline, test_run_config). I attribute them to the older image binaries, not to this change, but did not investigate them.
  • CI's "Check Code Style with Ruff" failed on the first push for the new test file (RUF100 unused noqa: E402, SIM117 nested with, 2x C408 dict() calls). Fixed in fa7290b without noqa. Re-run in an isolated venv with the CI tools (ruff==0.16.0, black 26.10.1 as psf/black@stable resolves to): ruff check . passes on the whole checkout (sparse checkout, so not every file is present) and black --check is clean on the two changed Python files.
  • After merging origin/main (clean, no conflicts; origin/main still has no --libtype, and [HIP] [CK] [OPUS] Add opus mxfp4 bpreshuffle nt gemm #7979 and [ASM] [Bugfix] a4w4: skip f4gemm kernels wrong at a partial N tile (full_n_tile table flag) #8847 are still open) the test was re-run on mi350x8 under gpu-lock in the rocm/atom-dev:sglang-latest image with the merged tuner and the fixed test overlaid on the image's aiter: python3 -m unittest op_tests.tuning_tests.test_a4w4_tuner_libtype -v and the CI form python3 op_tests/tuning_tests/test_a4w4_tuner_libtype.py (the __main__ entry aiter_test.sh uses by default) both give 15 tests OK. The wider results above (the other tuning_tests files and the candidate equivalence) are from the earlier head and were not repeated.
  • At b9e0a8c, on mi350x8 under gpu-lock in the same image (a copy of the image's /app/aiter-test with this tree's Python overlaid, same sitecustomize version spoof): python3 -m pytest -q op_tests/tuning_tests/test_a4w4_tuner_libtype.py gave 19 passed, and python3 op_tests/tuning_tests/test_a4w4_tuner_libtype.py (the CI form, with the copy on PYTHONPATH) gave 19 tests OK. Without the copy on PYTHONPATH the script form imports the image's older aiter and the new class fails on a missing _parse_triton_a4w4_kernel; that is an artifact of the overlay.
  • Smoke tune --libtype ck with one shape (M=32, N=512, K=4096) on mi350x8: argument parsing and task enumeration worked (Grouped 20 tasks into 1 groups, i.e. CK only, no ASM tasks). The run was killed at 650 s while still JIT-building module_gemm_a4w4_blockscale_tune, so no timing or tuned CSV row was produced.

Not verified:

  • A completed tune that produces a winner on a GPU (the smoke tune did not finish building).
  • triton and flydsl candidates on real hardware: the new test checks that the generated names parse and fit in the runtime, but no Triton or FlyDSL kernel was launched or timed, and the image's FlyDSL is 0.4.0 (spoofed to 0.5.0 for the tree's version check), so the candidate catalog may differ from CI's.
  • The test cannot run on the Windows development host (no ROCm aiter); the runs above are on mi350x8.
  • Behavior of the whole aiter CI job with the new entry in split_tests.sh: the standard test jobs were skipped on the previous head (the PR is a draft), so the test has not run in CI yet. The entry is not in .github/split-test-times/aiter.tsv or update_split_test_times.py: other tuning tests such as test_fast_tuning.py are not there either, the tsv is refreshed automatically, and unknown files get the 15 s default.

PR-specific question

The aiter-bot asked: what permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?

  • The only .github/ change is one line in .github/scripts/split_tests.sh: the new test path is added to the hard-coded list of tuning tests that the aiter job shards. No workflow file, trigger, permissions: block, secret, cache key or runner label is touched.
  • Nothing PR-controlled (title, body, branch name, label) is read or interpolated by that line. It is a literal path under $TEST_DIR.
  • The step that runs it is unchanged: .github/workflows/aiter-test.yaml triggers on pull_request (not pull_request_target), so a fork PR gets a read-only token and no secrets, and it already executes PR code for every op_tests/ file. This adds one more repo file to that set, with no new privileged path. I read the workflow's trigger and its draft gate, not every step of its fork handling.
  • The test uses no network and no subprocess. It reads repo files and a temp CSV and writes only to a temp directory; mp_tuner is stubbed.
  • The test file is not in .github/split-test-times/aiter.tsv, which is refreshed automatically, so it gets the 15 s default until then.

Changed op tests

  • op_tests/tuning_tests/test_a4w4_tuner_libtype.py (new). Covers --libtype parsing (all, invalid values, cktile message), --backends alias and conflict handling, and the candidate set tune() enumerates per libtype for one shape without a GPU (chip, CU count, mp_tuner and the ASM kernel list are stubbed): the default equals explicit ck,asm and the --backends ck,asm alias, ck and asm alone keep the same kernelIds/names as in the default set, ck does not read the ASM kernel list, and triton/flydsl are gated by the selection. TestRealPreshuffleCandidates uses the real preshuffle_candidates for (32, 1024, 4096), with and without split-K, and checks each generated name with the parsers gemm_a4w4 applies to a tuned row (_parse_triton_a4w4_kernel; FlyDSL parse_kernel_name, instance_valid, fits_shape). It launches nothing but needs Triton and FlyDSL to be importable, and skips when they are not. Invalid-value cases use no_such_backend, not opus. It is not redundant: no other test touches this tuner's arguments or its candidate list (test_fast_tuning.py and test_tuner_infra.py cover the shared base tuner only). It is registered in .github/scripts/split_tests.sh.

Add --libtype (ck, asm, triton, flydsl, all) to select which backends the
a4w4 blockscale tuner enumerates, so a single backend can be tuned without
enumerating the others. --backends stays as a mutually exclusive alias. The
default (ck,asm) enumerates the same candidates as before. cktile is
rejected because gemm_a4w4 dispatches on the kernel name and has no CK Tile
path. ASM kernel ids stay stable when ASM is not selected.

Fixes #5356

Signed-off-by: Binglue Lyu <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 8825 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@demonsan
demonsan marked this pull request as ready for review November 27, 2026 14:42
@demonsan
demonsan requested a review from a team November 27, 2026 14:42
@github-actions github-actions Bot changed the title [CK] [Feature] a4w4 blockscale tuner: add --libtype backend selection [CK] [CI] [Feature] a4w4 blockscale tuner: add --libtype backend selection Nov 27, 2026
@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision b9e0a8cc9453 · 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

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

This branch has not been deployed

No deployments
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.

[tune] a4w4_blockscale tuner has no --libtype axis, so CK Tile's MX GEMM can never compete

3 participants