Repository navigation
Conversation
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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
…flydsl names, neutral invalid-backend sentinel
WAITING ON AUTHORPR 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 |
Fixes #5356
Summary
Adds a
--libtypeaxis 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(orall) picks the backends; omitting it keeps the current candidate set (ck,asm).--backendsstays as an alias.Motivation
#5356: the tuner had no
--libtype, andaiter/utility/pretune.pyalready invokes tuners with--libtype. The tuner already had an ad-hoc--backendsoption with the same job under another name.Changes
A4W4_LIBTYPES = ("ck", "asm", "triton", "flydsl")andDEFAULT_LIBTYPES = ("ck", "asm")are the single source of truth for what the tuner can enumerate.libtype_listvalidates--libtype(acceptsall). It rejectscktilewith a message that says why (see Behavior and intent).resolve_libtypes(libtype, backends)maps the two options to a backend set.--libtypeand--backendsare mutually exclusive, and bad values now fail inparse_args(exit 2) rather than intune().tune()skips reading and enumerating ASM kernels whenasmis not selected. ASM kernelIds are unchanged (they still start after the CK ids), since they identify kernels at runtime.--libtype, the--backendsalias, thecktilerejection, the two defaults (bare tunerck,asm; pretuneall) and the candidate-count implication..github/scripts/split_tests.sh: registers the new test, because theaiterjob lists tuning tests explicitly.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
opusbackend, changes the--backendsdefault tock,asm,opus, and addsopus_candidates. This PR is built so #7979 only needs to add"opus"toA4W4_LIBTYPES(and toDEFAULT_LIBTYPESif it should stay default), then use"opus" in backendsas it does now. Expected textual conflicts: the--backendsargument block in_setup_specific_arguments, and thebackends = ...line intune(). 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
Documentation
csrc/ck_gemm_a4w4_blockscale/README.md)Dependencies
Breaking Changes
None. The default is the same set of candidates.
--backendsstill works; it is now validated at argument parsing, so a bad value exits with a usage error instead of aValueErrorfromtune(). The--backendsdefault is nowNone(theck,asmdefault lives inDEFAULT_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/mainhad not moved when this head was pushed.Behavior and intent
--libtype {all,ck,asm,triton,flydsl}[,...]on the a4w4 blockscale tuner. Only the selected backends are enumerated;--libtype ckdoes not read the ASM kernel list.--libtypenor--backends, the tuner enumerates exactly what main does. Checked against main's tuner on a gfx950 host (see below).cktileis rejected on purpose:aiter/ops/gemm_op_a4w4.pydispatches a tuned row by kernelName prefix andcsrc/ck_gemm_a4w4_blockscaleuses 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 allmeans every entry ofA4W4_LIBTYPES, which includestritonandflydsl. That is wider than the bare-tuner default (ck,asm).aiter/utility/pretune.pyalways passes--libtypeto the tuner (defaultall). On main the a4w4 tuner rejected that, so a4w4 was not pretunable that way; with this PR pretune of this tuner enumeratesck,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 onmi350x8.pretune --libtype cknow means CK only (no ASM) andpretune --libtype cktileis rejected by this tuner. The README documents both defaults.Validation and unverified scope
Run in the
rocm/atom-dev:sglang-latestimage onmi350x8(gfx950), viagpu-lock docker run, with this tree's Python mounted over the image'saiter(the image's aiter is older than main; it needed asitecustomizethat setsflydsl.__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.ck(20),asm(3) andck,asm(23); main was run with--backends, this PR with--libtype/no flag.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_lookup8,test_a6w6_tuning1,test_grouped_ep_fused_lookup2,test_mixed_mxfp_tuning9,test_tune_pipeline,test_run_config). I attribute them to the older image binaries, not to this change, but did not investigate them.noqa: E402, SIM117 nestedwith, 2x C408dict()calls). Fixed in fa7290b withoutnoqa. Re-run in an isolated venv with the CI tools (ruff==0.16.0, black 26.10.1 aspsf/black@stableresolves to):ruff check .passes on the whole checkout (sparse checkout, so not every file is present) andblack --checkis clean on the two changed Python files.origin/main(clean, no conflicts;origin/mainstill 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 onmi350x8undergpu-lockin therocm/atom-dev:sglang-latestimage 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 -vand the CI formpython3 op_tests/tuning_tests/test_a4w4_tuner_libtype.py(the__main__entryaiter_test.shuses by default) both give 15 tests OK. The wider results above (the othertuning_testsfiles and the candidate equivalence) are from the earlier head and were not repeated.mi350x8undergpu-lockin the same image (a copy of the image's/app/aiter-testwith this tree's Python overlaid, samesitecustomizeversion spoof):python3 -m pytest -q op_tests/tuning_tests/test_a4w4_tuner_libtype.pygave 19 passed, andpython3 op_tests/tuning_tests/test_a4w4_tuner_libtype.py(the CI form, with the copy onPYTHONPATH) gave 19 tests OK. Without the copy onPYTHONPATHthe script form imports the image's olderaiterand the new class fails on a missing_parse_triton_a4w4_kernel; that is an artifact of the overlay.--libtype ckwith one shape (M=32, N=512, K=4096) onmi350x8: 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-buildingmodule_gemm_a4w4_blockscale_tune, so no timing or tuned CSV row was produced.Not verified:
tritonandflydslcandidates 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.aiter); the runs above are onmi350x8.aiterCI job with the new entry insplit_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.tsvorupdate_split_test_times.py: other tuning tests such astest_fast_tuning.pyare 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?
.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 theaiterjob shards. No workflow file, trigger,permissions:block, secret, cache key or runner label is touched.$TEST_DIR..github/workflows/aiter-test.yamltriggers onpull_request(notpull_request_target), so a fork PR gets a read-only token and no secrets, and it already executes PR code for everyop_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.mp_tuneris stubbed..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--libtypeparsing (all, invalid values,cktilemessage),--backendsalias and conflict handling, and the candidate settune()enumerates per libtype for one shape without a GPU (chip, CU count,mp_tunerand the ASM kernel list are stubbed): the default equals explicitck,asmand the--backends ck,asmalias,ckandasmalone keep the same kernelIds/names as in the default set,ckdoes not read the ASM kernel list, andtriton/flydslare gated by the selection.TestRealPreshuffleCandidatesuses the realpreshuffle_candidatesfor (32, 1024, 4096), with and without split-K, and checks each generated name with the parsersgemm_a4w4applies to a tuned row (_parse_triton_a4w4_kernel; FlyDSLparse_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 useno_such_backend, notopus. It is not redundant: no other test touches this tuner's arguments or its candidate list (test_fast_tuning.pyandtest_tuner_infra.pycover the shared base tuner only). It is registered in.github/scripts/split_tests.sh.