Repository navigation
Commit 0662b18
[rocm-libraries] ROCm/rocm-libraries#11721 (commit d8dab35)
=?UTF-8?q?feat(ck=5Ftile):=20make=20weight-preshuffled=20?=
=?UTF-8?q?B=20usable=20with=20RowCol=20(per-token=20=C3=97=20per-channel)?=
=?UTF-8?q?=20scales=20(#11721)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
ISSUE ID : #3766
Replaces my #3770, which I withdrew because its evidence was vacuous —
the `-preshuffleb` flag was not part of the rowcol LUT key, so both arms
of that "before/after" ran the same non-preshuffle kernel. This PR fixes
that (among other things) and the test now genuinely toggles.
Two commits: the first is #3769 (the rowcol BQ-extent fix), included
because the enablement cannot be evaluated without it — rowcol fails its
own verification until `BQN = N`. If #3769 merges first this rebases
cleanly.
## The defect
`WeightPreshufflePipelineAGmemBGmemCRegV2` never announced
`PreshuffleB`. `QuantGemmKernel` detects a preshuffled B by SFINAE on
`GemmPipeline::PreshuffleB` (`gemm_quant_kernel.hpp:104-106`) and
**defaults to false when the member is absent** — so pairing the quant
kernel with the weight-preshuffle pipeline made it read preshuffled
weights as a plain B. No error, just wrong numbers.
Measured by removing the announcement again on an otherwise-identical
build (gfx950):
| | result |
|---|---|
| rowcol + preshuffleb, **without** the announcement | **fail — 39.47%
wrong, max err 386.78** |
| rowcol + preshuffleb, **with** it | correct |
| rowcol, preshuffleb=0 (control) | correct in both builds |
## Making the combination reachable
- rowcol routes to the weight-preshuffle pipeline when `PreshuffleB` is
set (it was pinned to `GemmPipelineAgBgCrCompV3` unconditionally);
- new `GemmConfigPreshuffleB_RowCol_Prefill`;
- `-preshuffleb` joins the rowcol LUT key — without it the flag selected
the same kernel either way, so the configuration could not be tested at
all;
- `RowColQuant` leaves the `PreshuffleB` rejection list.
## Results in this example (gfx950 / MI350X, fp8, verification on)
| shape | preshuffleb=0 | preshuffleb=1 |
|---|---|---|
| 512³ | correct | correct |
| 1024×2688×6144 | 0.1014 ms, 333 TF | **0.0471 ms, 718 TF** |
| 2048×6144×12288 | 0.7211 ms, 429 TF | **0.2102 ms, 1471 TF** |
**Caveat**: the two arms differ in tile shape as well (the existing
rowcol config is decode-shaped 16×64, the new one prefill-shaped
128×128), so read these as *the new preshuffled config vs the only
rowcol config the example had at these shapes*, not as preshuffle in
isolation.
## Independent measurement, stated carefully
Driving this same composition through AITER's tuner on MI350X — 1754
measurements across 6 GLM-shaped GEMMs, full candidate space (259 flatmm
tiles + 44 rowcol tiles), **errRatio 0.0000 on every one**:
| shape (M,N,K) | best rowcol | best flatmm | winner |
|---|---|---|---|
| 1, 2688, 6144 | — (no divisible tile) | 11.008 µs | flatmm |
| 64, 2688, 6144 | 12.640 µs (rank 5) | 11.325 µs | flatmm, −11.6% |
| 256, 2688, 6144 | 19.190 µs (rank 10) | 17.590 µs | flatmm, −9.1% |
| 1024, 2688, 6144 | 41.226 µs (rank 35) | 35.491 µs | flatmm, −16.2% |
| **2048, 6144, 12288** | **158.661 µs (rank 1)** | 175.943 µs |
**rowcol, +9.8%** |
| **16384, 6144, 12288** | **1165.842 µs (rank 1)** | 1258.569 µs |
**rowcol, +7.4%** |
So it is a genuine per-shape winner on large-M / prefill-shaped GEMMs
and **not** a global replacement; across 184 matched (tile, BlockPerCu)
pairs the median is −0.9%, with the advantage concentrated in wide-N
tiles and growing with M. Also note **M=1 cannot dispatch to this
route** — no MTile divides 1 and it is instantiated unpadded; that needs
`kPadM` wired through separately.
(Earlier revisions of this description quoted "+8-11% over flatmm" from
a restricted candidate set; the table above supersedes it. See the
comments for the full correction history.)
Per-token × per-channel scales on preshuffled weights is the standard
shape for FP8 LLM inference with online activation quantization, so
having it reachable — and not silently mis-typed as plain B — matters
beyond this example.
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent cea77f7 commit 0662b18
7 files changed
Lines changed: 121 additions & 11 deletions
File tree
- example/ck_tile/38_block_scale_gemm
- include/ck_tile/ops/gemm/pipeline
- test/ck_tile/gemm_block_scale
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
29 | 45 | | |
30 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
219 | 244 | | |
220 | 245 | | |
221 | 246 | | |
| |||
Lines changed: 21 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
198 | 206 | | |
199 | 207 | | |
200 | 208 | | |
201 | | - | |
| 209 | + | |
202 | 210 | | |
203 | 211 | | |
204 | 212 | | |
| |||
494 | 502 | | |
495 | 503 | | |
496 | 504 | | |
497 | | - | |
498 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
499 | 514 | | |
500 | | - | |
501 | | - | |
| 515 | + | |
| 516 | + | |
502 | 517 | | |
503 | 518 | | |
504 | 519 | | |
| |||
992 | 1007 | | |
993 | 1008 | | |
994 | 1009 | | |
995 | | - | |
996 | 1010 | | |
997 | 1011 | | |
998 | 1012 | | |
999 | 1013 | | |
1000 | | - | |
| 1014 | + | |
1001 | 1015 | | |
1002 | 1016 | | |
1003 | 1017 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
| |||
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1626 | 1626 | | |
1627 | 1627 | | |
1628 | 1628 | | |
| 1629 | + | |
1629 | 1630 | | |
1630 | 1631 | | |
1631 | | - | |
| 1632 | + | |
| 1633 | + | |
1632 | 1634 | | |
1633 | 1635 | | |
1634 | 1636 | | |
| |||
1676 | 1678 | | |
1677 | 1679 | | |
1678 | 1680 | | |
1679 | | - | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
1680 | 1690 | | |
1681 | 1691 | | |
1682 | 1692 | | |
| |||
2127 | 2137 | | |
2128 | 2138 | | |
2129 | 2139 | | |
2130 | | - | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
2131 | 2144 | | |
2132 | 2145 | | |
2133 | 2146 | | |
| |||
2155 | 2168 | | |
2156 | 2169 | | |
2157 | 2170 | | |
2158 | | - | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
2159 | 2175 | | |
2160 | 2176 | | |
2161 | 2177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
30 | 56 | | |
31 | 57 | | |
32 | 58 | | |
| |||


0 commit comments