Repository navigation
[Config] Add gfx950 DeepSeek-V4.1 MXFP8 GEMM rows for N = 12800, 6400 and 3200 (K = 6144) - #8159
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
|
@yzhou103 this is a config-only pull request from a fork: one CSV file, 204 new rows, no code and no change to an existing row. Seven workflow runs wait for approval ( |
|
@demonsan (cc @yifehuan) could you approve the workflow runs on this one? It only adds rows to one tuned-config CSV (204 gfx950 rows for the DeepSeek-V4.1 shard GEMMs, N = 12800 / 6400 / 3200 at K = 6144), no code change. The runs are waiting on "Approve and run workflows" since it is a fork PR. Thanks! |
c46c197 to
92609b2
Compare
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
… and 3200 (K = 6144) Add 204 gfx950 rows (cu_num 256, w_scale_block 32x32) for N = 12800, 6400 and 3200 at K = 6144 to aiter/configs/model_configs/dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv, at the 68 M values the table already uses. These N are N = 25600 / P for P = 2, 4 and 8: the per-rank shards, in vLLM under tensor parallel without sequence parallelism, of the N = 25600, K = 6144 weight the table already tunes. They had no row. A direct gemm_a8w8_blockscale_bpreshuffle call ran the FlyDSL batched-GEMM heuristic, and vLLM kept its own Triton GEMM for these layers, because it routes a 32x32 layer to AITER only when rows exist at M = 1 and M = 8192. Rows only. No existing row changes. Signed-off-by: Saptarshi Majumder <[email protected]>
92609b2 to
8f4ae39
Compare
|
@yifehuan this one is config-only as well: 204 new gfx950 rows for the DeepSeek-V4.1 shard GEMMs (N = 12800 / 6400 / 3200 at K = 6144), and no existing row is changed. Could you approve the workflows so that CI can run? Thanks! |
Measured again on main 82b6b4f (after ROCm#8296 reworked the FlyDSL MXFP8 kernels, with FlyDSL 0.5.3) on an MI355X and an MI350X. The 186 rows from M = 48 keep their gain on both. Of the 18 rows for M up to 32, nine no longer reach 1.03x over the kernel the heuristic picks on both devices, one of them (N = 6400, M = 16) is slower on both. Those nine now name that kernel, with the values the tuner profiled for it, as the rows for M = 32 at N = 12800 and 3200 already do. The rows stay because vLLM routes these layers to AITER only when a row exists at M = 1 and at M = 8192. Signed-off-by: Saptarshi Majumder <[email protected]>
|
@yifehuan @demonsan an update, because
The description has the new tables for both devices. One thing I have not done is a tuner run on current |
|
@demonsan thanks for the review, and @yifehuan thanks for starting the workflows. The one red shard of the Aiter Test (Standard Tests 8/1) did not fail in a test: its runner dropped out at 17:59 UTC ("The self-hosted runner lost communication with the server"), in the same minute as shards of other pull requests, so there is no log for it. The other seven shards, Checks, Triton Test and OPUS Test passed. Could one of you re-run the failed job? Nothing needs to change in the branch. |
Summary
Adds 204 gfx950 rows to
aiter/configs/model_configs/dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv:N = 12800, 6400 and 3200 at K = 6144,
w_scale_block32x32, cu_num 256, at the68 M values the table already uses for its other gfx950 shapes. Rows only. No
code changes and no existing row changes.
Motivation
The table tunes N = 25600, K = 6144 (68 rows). Closed PR #6994 and open PR
#8052 describe that shape as the DeepSeek-V4.1 Engram WKV projection. The table
has no row for N = 12800, 6400 or 3200 at that K. These are N = 25600 / P for
P = 2, 4 and 8: the shards of that weight in vLLM under tensor parallel without
sequence parallelism. Its ROCm Engram layer gives every rank a 1 / P slice of
each key and of the value (
RocmEngram._create_wkvinvllm/models/deepseek_v41/amd/engram.py, vLLM main 52fae19fb). With sequenceparallelism vLLM does not shard this layer and N stays 25600. This is another
sharding than the one of #8052 (a key shard plus the whole value, N = 10240 at
P = 4), so the two sets of rows serve different callers.
Without rows, two things happen today:
gemm_a8w8_blockscale_bpreshufflecall with one of these N finds norow at any M.
get_mxscale_bpreshuffle_configreports "untuned" and theFlyDSL batched GEMM runs with its heuristic kernel.
(
VLLM_ROCM_USE_AITER=1; off by default), on gfx950, with bf16 as defaultdtype and batch-invariant mode off, it sends a 32x32 block-scaled MXFP8 layer
to AITER only when rows exist for its (N, K) at M = 1 and at M = 8192
(
is_mxfp8_block32_bpreshuffle_gemm_tunedinvllm/_aiter_ops.py), andotherwise keeps its own Triton GEMM.
With the rows:
1.04x to 2.17x on an MI350X and 1.03x to 2.37x on an MI355X (gfx950, 256 CUs), geometric
mean over all 204 shapes 1.43x and 1.50x. At the other 11 shapes the row names the
kernel that main already runs, so nothing changes there (see Validation).
build with these rows moves these layers from its Triton GEMM to AITER's
FlyDSL kernels at every M, decode sizes included. Timed through vLLM's own operator, AITER with these rows against vLLM's Triton GEMM is 1.11x to 2.18x at M = 1 to 16 and 1.19x to 2.40x at M = 512 to 16384 on an MI350X, and 1.16x to 2.67x and 1.18x to 2.57x on an MI355X (above 1.00x: the rows are faster), see Performance.
Changes
(N, K, M) order: N = 3200 before the (4096, 1280) rows, N = 6400 before the
(8192, 1280) rows, N = 12800 before the (16384, 1280) rows.
kernelId=bmm) rows.scales and N in {12800, 6400, 3200} change. Before, no M had a row. After,
every M from 1 up resolves to a row through the existing padded-M walk,
except N = 3200 above M = 32768, which stays on the heuristic.
(see Motivation).
M = 1, 2, 4, 8, 16 and was not merged; main has none of them. Open PR [Config] gfx950 DSv4.1-Flash MXFP8 GEMM rows for the rank-sharded Engram WKV (N=10240, K=6144) #8052
(draft) adds nine rows for N = 10240, K = 6144 to this file and inserts them
at the line where this PR inserts its N = 12800 group, so the PR that merges
second needs a rebase; no key is shared. Open PR [FlyDSL][gfx950] Tune DSV4.1 MXFP8 Q-a+KV prefill at four M points #8024 edits other rows of
this file (N = 1792, K = 5120) and adds 8-wave tiles. If another PR lands
rows for the same keys first, this PR will drop its copies.
Performance (if applicable)
Direct call
aiter.gemm_a8w8_blockscale_bpreshuffle(x, w, x_scale, w_scale, bf16)with a 32x32 e8m0 weight scale and a 1x32 e8m0 activation scale, on synthetic
random data (no model checkpoint). Before = main
82b6b4f19. After = main plusthis table. One process per variant per round, 4 rounds in the order main, rows /
rows, main / main, rows / rows, main. Each process captures 10 calls in a CUDA
graph and takes the median of 11 replays. The ratio is the median of the 4
per-round ratios. Software: torch 2.13.0+rocm10.0.0, FlyDSL 0.5.3, main's
aiterand
csrclaid over the AITER of the imagevllm/vllm-openai-rocm:v0.33.0.Measured on 24 November on an MI350X and on an MI355X; each GPU was idle before
and after its run by the driver's busy and memory counters. The benchmark script
times only the public operator; it is not part of this PR and is available on
request.
Of the 204 shapes, 11 are below 1.03x on both devices: M = 2, 16 and 32 at N = 12800, M = 1, 2, 4, 8, 16 and 32 at N = 6400, and M = 16 and 32 at N = 3200. Their rows name the kernel that main's heuristic picks, so both variants run the same kernel there (0.98x to 1.01x on the MI350X, 1.00x to 1.02x on the MI355X; see Validation). The other 193 shapes are 1.04x to 2.17x on the MI350X and 1.03x to 2.37x on the MI355X, and none of them is slower than main in any of the four rounds on either device.
Calls at M values that have no row of their own, same method, 29 M values per
N. 86 of the 87 pad to a neighbour row. One (M = 40000 at N = 3200) is above
the grid, has no row and is main against main:
On the MI350X 5 of the 86 are below 1.00x: 5 are served by a row that names main's kernel (0.992x to 0.999x, the same kernel in both variants). On the MI355X 4 of the 86 are below 1.00x: 3 are served by a row that names main's kernel (0.994x to 0.999x, the same kernel in both variants) and M = 5000 at N = 3200 on the M = 8192 row (0.954x, 117.6 us against 123.1 us). M = 5000 at N = 3200 is 1.058x on the MI350X. On the MI355X the 8-wave kernel of that row takes as long at M = 5000 as at M = 6145 (123.1 us and 123.8 us), where the heuristic's kernel grows with M (117.6 us and 162.0 us).
All 204 tuned shapes and all 87 off-grid shapes, both devices
Tuned M (one row each); times in us:
M without a row of their own ("row M" is the row that served the call); times in us:
Through vLLM's operator: before = vLLM main 52fae19fb with main's table, which runs its Triton GEMM; after = the same with this table, which runs the rows. Same timing method.
The rows for M up to 32 are what keeps this route open. With those 18 rows left out of the table the same measurement on the MI355X gives 1.00x and 1.00x over the 39 shapes of each operator: vLLM's check finds no row at M = 1 and runs its Triton GEMM in both variants.
Testing
Tuned on an MI350X (gfx950, 256 CUs); the A/B ran on an MI350X and on an
MI355X. The rows are gfx950 rows with cu_num 256.
python3 -m unittest op_tests.tuning_tests.test_csv_validation op_tests.tuning_tests.test_config_shape_collision:52 tests OK on this head and on main.
Documentation
Tuned-config rows only. The table format and the lookup are unchanged.
Dependencies
Breaking Changes
No existing key changes. One limit is new for direct callers. The M = 8192 rows of N = 12800 and of N = 6400 are 8-wave kernels, and through the existing padded-M rule they also serve larger M. 8-wave kernels refuse M * N * 2 >= 2^31 with a ValueError, so a direct call with M >= 83887 at N = 12800 (M >= 167773 at N = 6400) now raises, where main ran the heuristic kernel. Calls through vLLM cannot reach that size: vLLM splits a call into chunks of at most 2^31 bytes, 83886 rows at N = 12800. The table has the same property today for N = 25600 (M >= 41944).
PR Self-Review
Reviewed revision
faf3e7f
Behavior and intent
Configuration only. For gfx950 with 256 CUs, a 2-D
gemm_a8w8_blockscale_bpreshufflecall with 32x32 e8m0 weight scales, K = 6144and N = 12800, 6400 or 3200 found no tuned row at any M and ran the FlyDSL
batched GEMM with its heuristic kernel. These N are N = 25600 / P for P = 2, 4
and 8, the per-rank shards of the N = 25600 weight that the table already tunes
(vLLM's sharding under tensor parallel without sequence parallelism). With the
204 rows the lookup returns a measured mxpsh, 8-wave or batched-GEMM kernel for
every M (exact M or the existing padded-M walk), except N = 3200 above
M = 32768, which keeps the heuristic. No dispatch code changes. One effect
outside AITER is intended and stated: with AITER enabled, vLLM keeps its own
Triton GEMM for a 32x32 layer unless rows exist at M = 1 and M = 8192, so these
rows also move vLLM's layers with these shapes to AITER.
Validation and unverified scope
Main
82b6b4f19was merged on 24 November. Since the earlier base main had changed this table in three commits (#7827, #7868, #8296) without touching these keys, #8296 had reworked the FlyDSL MXFP8 kernels that the rows name, and main had moved from FlyDSL 0.5.0 to 0.5.3. So all 204 rows were measured again on current main, on an MI350X and on an MI355X. The 186 rows from M = 48 kept their gain on both devices. Of the 18 rows for M up to 32, nine no longer reached 1.03x over the heuristic's kernel on both devices; the worst, M = 16 at N = 6400, was 0.87x on the MI355X and 0.97x on the MI350X. Those nine rows now name the kernel that main's heuristic picks, with the values the tuner profiled for that kernel, and the table in Performance is the measurement of the table as it is in this revision. The rows are kept because vLLM's check needs a row at M = 1, and because a row at M = 16 or 32 keeps the M below it off the M = 48 row.Tuned with
python3 csrc/gemm_a8w8_mxfp8_bpreshuffle/gemm_a8w8_mxfp8_bpreshuffle_tune.py --mxscale_table -i <M,N,K,w_scale_block shape list> -o <scratch csv> -o2 <profile csv> --timeout 14400on an MI350X (gfx950, 256 CUs), default
--errRatio 0.05,AITER main
7c2fa4daePython sources and configs on an amd-aiter 0.1.25 install, FlyDSL 0.5.0, torch 2.12.0+rocm10.0.0. 617,082 candidates were timed (594,818 mxpsh, 2,448 8-wave, 19,816 batched-GEMM). The 204 rows have errRatio atmost 0.0012. The rows were tuned at main
7c2fa4dae; the A/B and the checks below ran at main82b6b4f19. TheOPUS kernels that #6696 added in between are tuner candidates for 128x128 scale
blocks only, so they do not compete for these 32x32 rows.
One thing differs from the stock tuner. For an (N, K) with no rows of its own,
--mxscale_tabletakes batched-GEMM candidates only from the heuristic pick andits split-K neighbours, so that family would be 2 or 3 kernels per shape. We ran
the tuner with a local 16-line change, not part of this PR, that makes it also
time the
kernelId=bmmkernel names of the table's other (N, K) with the sameblock at M/2 to 2M, as the tuner's 1x32 mode does with its
pool, and, for M up to 32, the kernel names of the 10 rows in the closed PR
#6994. The heuristic kernel stays a candidate for every shape, so no row can
be slower than main in the tuner's own timing.
Twelve rows are not the tuner's winner: the nine of 24 November named above, and three from the first selection. The tuner gives every timed call another
copy of the weight; the A/B in Performance replays one weight. At M = 32 for
N = 12800 and for N = 3200 and at M = 64 for N = 6400 the tuner's winner, a
kernel with non-temporal weight loads, was 1.10x, 1.03x and 1.09x faster than
the heuristic kernel in the tuner's timing, and in two replay A/B runs it was
0.93x to 0.97x, 0.92x to 0.94x and 0.99x to 1.00x against main. For these three
shapes seven candidates were timed both ways (the tuner's first three, the
heuristic kernel and the fastest candidates without non-temporal loads), and
the row holds the candidate whose smaller gain of the two is the largest. At
the two M = 32 shapes that is the heuristic kernel itself: the row keeps
M = 17 to 32 on it, where these M would otherwise pad to the M = 48 row. At
M = 64 for N = 6400 it is
flydsl_mxpsh_32x64x512_F8_F8_B16_w4_x4_sk1_pf(1.04x in the tuner's timing; 1.07x on the MI350X and 1.06x on the MI355X
in the A/B above). The other 192 rows are the tuner's winners of 18 November.
Checks:
87 off-grid shapes, 4 rounds each (the reducer refuses a run that lacks a
shape or a round). For every record of the "rows" variant the lookup returned
the kernel of the row that an offline replay of the lookup expects; the
dispatcher passes that name to the backend (
aiter/ops/gemm_op_a8w8.py,_gemm_mxscale_bpreshuffle). Every "main" record found no row, so it ran thebatched-GEMM heuristic. Relative error against the dequantised float
reference: 1.67e-03 for main and 1.67e-03 for the rows variant, on both
devices.
line of main's file is in this head's file byte for byte and in the same
order, and this is the only file the PR touches. For the three new groups
the padded-M lookup was replayed for M = 1 to 40000 on main's table (no row
at any M) and on this table (a row at every M, except N = 3200 above
M = 32768).
python3 -m unittest op_tests.tuning_tests.test_csv_validation op_tests.tuning_tests.test_config_shape_collision:52 tests OK on this head and on main.
GPU_ARCHS=gfx950 python -m aiter.aot.flydsl.gemm --csvona table with the 204 new rows: 204 ok, 0 failed, 0 refused by the runtime; the size bisect inside the rows' M ranges compiled 347 sizes, 0 failed. Run on both devices.
f2f9edcac:is_mxfp8_block32_bpreshuffle_gemm_tunedmakes the same check andengram.pyis unchanged.Not run / unverified: end-to-end serving and accuracy; a tuner run on current
main (the rows were tuned before #8296, so the A/B shows that they are not
slower than main, not that they are the best kernels main has now); M above 40000 except M = 83000 to 84000 at N = 12800, see Breaking Changes;
gfx942 and gfx1250 (no rows for them here).
PR-specific question
Keys consumed: gfx950, cu_num 256, w_scale_block 32x32, K = 6144, N in {12800,
6400, 3200}, M in the 68-value grid. Four readers use them. (1) 2-D
gemm_a8w8_blockscale_bpreshufflecalls with e8m0 scales, throughget_mxscale_bpreshuffle_config. (2) vLLM's routing checkis_mxfp8_block32_bpreshuffle_gemm_tuned, which calls the same function atM = 1 and M = 8192 and, when both return a row, runs a layer of that (N, K) on
AITER and no longer on its Triton GEMM. (3) The AOT replay
aiter/aot/flydsl/gemm.py, which compiles the kernels the rows name. (4) Thetuner, which in
--mxscale_tablemode readskernelId=bmmrows of the same Nand K as seeds. The lookup key contains N and K unpadded, so a row can only
serve calls with its own N and K; these three (N, K) had no row before, so no
call that used a row changes. Evidence: the other rows of the file are
unchanged byte for byte (merge check), the rows of every other group of the
table family are identical in main and head, and the lookup replay for the
three new groups is named above. Within the new (N, K), M values without a row
of their own pad to a neighbour: 2049 to 4096 use the M = 4096 row; for
N = 12800 and 6400 most M above 4096 use the M = 8192 row; for N = 3200, M
above 8192 uses the next power of two and M above 32768 keeps the heuristic.
The off-grid A/B times 29 such M per N.
Changed op tests
None.