Repository navigation
[CK] [JIT] feat(cktile a8w8-bpreshuffle): add rowcol_wp_v2 as a selectable kernel type - #5280
Conversation
…l type
The cktile a8w8-bpreshuffle family has exactly one device composition today:
FlatmmKernel + FlatmmPipelineAGmemBGmemCRegV1. This adds a second one, and the
plumbing that lets the tuner choose between them per shape and a tuned CSV row
route to it at serving time.
kernelInstance gains `sPipeline` ("flatmm_v1" | "rowcol_wp_v2"). The tile
geometry stays the axis it always was; the new field selects what consumes it.
It is part of the kernel name, so a tuned row that picks the non-default
pipeline is self-describing and round-trips through build_tune_dict()'s
kernelName lookup. The name is only extended for non-default pipelines, and the
rowcol candidates live in their own table that is BlockPerCu-expanded and
appended after the flatmm table, so every existing flatmm_v1 name AND kernelId
is unchanged -- already-tuned CSVs keep resolving.
rowcol_wp_v2 is ck_tile::QuantGemmKernel in QuantType::RowColQuant mode driving
WeightPreshufflePipelineAGmemBGmemCRegV2. ptpc is CK's RowColQuant: the kernel
views the aq window with strides (1, 0) and the bq window with (0, 1), so the
per-token (M,) and per-channel (N,) scale vectors AITER already passes are
consumed natively -- no replication, and B stays in the same
shuffle_weight(16, 16) layout flatmm_v1 uses. Host-side inputs are therefore
identical for the two pipelines; only the device composition differs.
One bridge is needed for now: QuantGemmKernel detects a preshuffled B by SFINAE
on GemmPipeline::PreshuffleB, which the weight-preshuffle pipeline does not
expose (the detection then silently defaults to false and the kernel reads
shuffled B as plain). KtWp2RowcolPipeline adds the alias; it can be dropped once
ROCm/composable_kernel#3772 lands in the pinned CK.
Measured on MI350X (gfx950, 256 CU), fp8 ptpc, six GLM-5.2 shapes swept with the
a8w8-bpreshuffle tuner --libtype cktile against the full 303-candidate space.
All 1754 measurements report errRatio 0.0000.
M N K best rowcol rank best flatmm winner
1 2688 6144 (no candidate) -- 11.0080us flatmm_v1
64 2688 6144 12.6396us 5/283 11.3251us flatmm_v1
256 2688 6144 19.1900us 10/303 17.5901us flatmm_v1
1024 2688 6144 41.2261us 35/303 35.4906us flatmm_v1
2048 6144 12288 158.6612us 1/303 175.9431us rowcol_wp_v2 +9.8%
16384 6144 12288 1165.8424us 1/303 1258.5691us rowcol_wp_v2 +7.4%
So it is a genuine per-shape winner on the large-M (prefill-shaped) GEMMs and
flatmm_v1 stays the winner at small M -- which is what the tuner is for. Across
all 184 matched (tile, BlockPerCu) pairs the median delta is -0.9%: the
advantage is not uniform, it is concentrated in wide-N tiles (128x128x256
+10.6..+24.6%, 256x192x128 +13..+18%) and grows with M (median -2.9% at M=64,
+3.9% at M=2048).
The quant route is instantiated with the pads clamped false, so codegen emits a
single body plus a divisibility TORCH_CHECK for it, and the tuner only offers a
non-default-pipeline instance for tile-divisible shapes. One consequence: M=1
has no rowcol candidate at all, since no MTile divides 1.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5f50c601b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ROCm/composable_kernel is now a read-only mirror; the PreshuffleB fix this wrapper waits on lives at ROCm/rocm-libraries#11721. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Correcting the performance claim in the description — it overstates this PR, and the correction matters for how you'd want to review it. The table said rowcol_wp_v2 wins 2 of 6 shapes. That was measured with
So on these shapes rowcol_wp_v2 would never be dispatched: it wins 0 of 6, not 2 of 6. A What I think is still true, stated without the inflation: at M=2048 it lands 5th out of 1624 valid candidates, ~3.1% off the champion, on a route that could not be expressed at all before this PR. It is a credible candidate rather than a winner, and it costs nothing when it loses — the tuner simply does not select it. The reason to carry it is that If the project's bar is "a new kernel type must win a shape today", this does not clear it on the shapes I measured, and I would rather you know that from me than find it in review. All correctness claims are unaffected: 1754 measurements at |
|
The real CI failure on The replacement fork workflows now require maintainer approval: Checks, Aiter Test, and OPUS Test. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d875cb2b19
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
The padded-K follow-up is pushed and its thread is resolved. @codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@amd-ruitang3 Could you take a look and let the CICD workflow run? Thanks! |
Adds
rowcol_wp_v2as a selectable kernel type in the cktilea8w8_bpreshufflefamily: CK'sQuantGemmKernelin RowColQuant mode driving the plain weight-preshuffle pipeline (WP2). Per-token × per-channel scales are exactly what this op already carries, so the tuner gains a genuinely different kernel to choose between per shape.Why
a8w8_bpreshufflealready hands the kernel ashuffle_weight(16,16)-preshuffled B and native(M,)/(N,)ptpc scales — which is precisely RowColQuant's contract. Until now thecktilelibtype meant exactly one thing (FlatmmPipelineAGmemBGmemCRegV1), so a better pipeline could not be nominated by the tuner even where it wins.Results (gfx950 / MI350X)
Correctness:
errRatio 0.0000on every one of 1754 measurements, including all 44 rowcol candidates.Performance, measured against the full candidate space (single tune,
--libtype all, 2804 candidates — not a cktile-only comparison):ck a8w8_bpreshuffle_256x256x192x128flydsl_bpreshuffle_8w_256x256x128On the shapes measured here, rowcol_wp_v2 is not selected. A
ckorflydslkernel wins every one. Within the CK-Tile family it beats flatmm at large M (+9.8% / +7.4%), but that is a comparison against its own family's twin, not against the dispatched kernel, and it is not the basis for merging this.The case for it is coverage:
sPipelineis a new axis, so future improvements to the weight-preshuffle pipeline reach this op without new plumbing.Padding safety
rowcol_wp_v2is instantiated without M or K padding and therefore requires exact tile divisibility. Serving lookup entries now carrysupports_m_paddingandsupports_k_paddingmetadata:This prevents arbitrary shapes such as M=2000, or an activation K smaller than its padded weight K, from selecting a rowcol winner that would reject the real input shape.
Compatibility
Verified
op_tests/test_gemm_codegen.py: 40 passed;Note on the CK bridge
KtWp2RowcolPipelineexists only becauseWeightPreshufflePipelineAGmemBGmemCRegV2does not exposePreshuffleB, andQuantGemmKerneldetects preshuffle by SFINAE on that member — defaulting to false when absent, which silently makes it read preshuffled weights as a plain B. The upstream CK fix is ROCm/rocm-libraries#11721; the wrapper can be removed once the pinned CK contains it.