Skip to content

[FlyDSL] [gfx1250] Fix the dropped K tail and the bias column offset in the grouped MoE TDM GEMM - #6663

Merged
yhl-amd merged 7 commits into
mainfrom
wjx/moe_k_tail_oob
Oct 23, 2026
Merged

yhl-amd merged 7 commits into
mainfrom
wjx/moe_k_tail_oob

Conversation

@lalala-sh

Copy link
Copy Markdown
Contributor

The gfx1250 grouped a8w4/a4w4 MoE TDM GEMM (grouped_gemm_gfx1250_a8w4) had two silent correctness bugs:

  • Dropped K tail. The kernel ran K // tile_k k-tiles, so a K that tile_k does not divide lost its last partial tile. DeepSeek-V4.1-Flash at TP4 (inter_dim=640, default tile_k=256) lost 128 of 640 in GEMM2; the MoE output was off by rel_l2 ≈ 0.44 against the same weights zero-padded to 768. V4-Pro at TP8 (inter_dim=384) lost a third of K.
  • Bias read at the tile-local column. The epilogue loaded bias[expert, col] with col relative to the workgroup's N tile, so every N tile past the first added the first tile's bias. GEMM1 has 2*inter_dim columns and GEMM2 model_dim, so every biased MoE on this path (e.g. gpt-oss) was wrong, and its output also changed with tile_n.

Changes

  • mxfp4_preshuffle_gfx1250_tdm.py
    • Round the k-tile count up. On the ragged last tile, every K-advancing TDM load (A, B, A-scale, B-scale) clamps its inner extent, so nothing past the row end is read and the hardware zero-fills the rest; the tile computes only its remaining k128 steps. Inside the loop the tail extent costs one scalar compare/select per issue. Everything is compile-time gated: when tile_k divides K the final ISA is byte-identical to main. K must be a multiple of 128 and now raises instead of silently computing a prefix.
    • Offset the bias address by the tile's N start (blk_n).
  • grouped_gemm_mxfp4.py: the buffer-ring clamp keeps its previous value (it counts full tiles), now written against the rounded-up tile count.
  • grouped_moe_gfx1250.py: shapes without a tuned CSV row default to tile_k=128, which divides every K the kernel accepts (blank tile_k cells and the env-override base follow). Tuned rows are unaffected.

Validation

On gfx1250 with the pinned FlyDSL 0.4.0:

  • GEMM level, 45 configurations: the tail result is bitwise equal to the same data zero-padded to a tile_k multiple, and rel_l2 against an fp64 dequantized reference is 1.66e-3 (bf16 output rounding, same as a divisible K). Covers a8w4/a4w4, post/mid-compute pipelines, carry prefetch, rolled drain, A-scale prologue, row-major A-scale, split-inner TDM, cluster 1x4/2x2, persistent workers, tile_k 128/256/512, K < tile_k, and the GEMM1 swiglu epilogue. Before the fix the same check gave rel_l2 0.453 at K=640, i.e. sqrt(128/640).
  • fused_moe end to end, 21 cases: inter_dim=640 is bitwise equal to the weights zero-padded to 768 for a8w4 (AITER_FORCE_A8W4=1) and a4w4 at 16/256/2048 tokens, with default tiles, tile_k 256 (tail), tile_k2 512, tile_m 32, carry prefetch and cluster_n 4.
  • Cross-model regression, 47 cases, main vs this branch: tuned CSV shapes of V4-Flash, Qwen3.5-397B, 7168/2048 and V4-Pro (EP and TP4); untuned gpt-oss and 3584/3072 SiTUv2; tail shapes V4.1-Flash TP4 and V4-Pro TP8. Every unbiased non-tail case is bitwise identical and its kernel time is within noise. With the K-tail change alone, all 70 kernels compiled for divisible K have byte-identical ISA.
  • Bias:
    • With zero weights, GEMM2 equals bias[col] in every N tile (tile_n 128/256), and GEMM1 matches swiglu(bias) per tile.
    • Biased fused_moe (a8w4/a4w4) is now bitwise invariant across tile_n, tile_n2 and tile_k.
    • logits_diff against the torch reference drops from 3.2e-5 / 9.4e-5 to 3.7e-6 / 3.9e-6.
  • Performance:
    • On V4.1-Flash TP4 GEMM2 (N=4096, K=640, E=256, topk 6), the tail tile costs 55–70% of a full tile.
    • The OOB clamp itself is 1–3% faster than an unclamped tail, because it fetches only the valid bytes.
    • On untuned shapes, tile_k=128 runs gemm1+gemm2 within −8% to +5% of the old tile_k=256 default, with bitwise-identical output.
  • Black and Ruff pass. This PR adds no in-tree tests; validation scripts are outside the PR.

Known limitations (not addressed here)

  • A biased MoE whose inter_dim is not a multiple of 256 (e.g. 640) still fails in the standalone stage-2 quant kernel, which requires feat_dim % 256 == 0.
  • An N that tile_n does not divide is still unsupported; the stage-1 quant already requires model_dim % 256 == 0.
  • waves_per_tensor_tdm=4 with m_warp=2 produces NaN on main as well; this PR does not change that.
  • EP (multi-rank) paths were not run; they share the same GEMM kernel.

lalala-sh and others added 3 commits October 19, 2026 07:44
…M GEMM

The grouped TDM GEMM ran K // tile_k k-tiles, so a K that tile_k does not
divide silently dropped its last partial tile. DeepSeek-V4.1-Flash at TP4
(inter_dim=640, default tile_k=256) lost 128 of 640 in GEMM2 (MoE output
rel_l2 ~0.44); V4-Pro at TP8 (inter_dim=384) lost a third of K.

Round the k-tile count up. On the ragged last tile every K-advancing TDM load
(A, B, A-scale, B-scale) clamps its inner extent, so nothing past the row end
is read and the hardware zero-fills the rest, and the tile computes only its
remaining k128 steps. All of it is compile-time gated: when tile_k divides K
the generated ISA is byte-identical to before. K must be a multiple of 128.

Tested on gfx1250: tail results are bitwise equal to the same data
zero-padded to a tile_k multiple across pipeline variants; fused_moe at
inter_dim=640 is bitwise equal to weights zero-padded to 768; tuned shapes of
other models are bitwise and timing unchanged.

Co-authored-by: Cursor <[email protected]>
Untuned shapes (no CSV row) ran tile_k=256, which leaves a K tail whenever
the K of either GEMM is an odd multiple of 128 (e.g. inter_dim 384/640).
tile_k=128 divides every K the kernel accepts. Blank tile_k cells and the
env-override base follow the same default; tuned rows are unaffected.

On gfx1250, untuned shapes run within -8%..+5% of the tile_k=256 default
(gemm1+gemm2), with outputs bitwise unchanged.

Co-authored-by: Cursor <[email protected]>
… N start

The epilogue read bias[expert, col] with col relative to the workgroup's N
tile, so every N tile past the first added the first tile's bias. GEMM1 has
2*inter_dim columns and GEMM2 model_dim, so every biased MoE (e.g. gpt-oss)
on this path was silently wrong, and its output also changed with tile_n.

Tested on gfx1250: with zero weights the GEMM2 output equals bias[col] in
every N tile (tile_n 128/256) and GEMM1 matches swiglu(bias) per tile;
biased fused_moe (a8w4/a4w4) is now bitwise invariant across tile_n,
tile_n2 and tile_k, and its logits_diff vs the torch reference drops from
3.2e-5/9.4e-5 to 3.7e-6/3.9e-6. Unbiased kernels are unchanged.

Co-authored-by: Cursor <[email protected]>
@lalala-sh
lalala-sh requested a review from a team October 19, 2026 08:54
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 6663 --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.

Comment thread aiter/ops/flydsl/grouped_gemm_mxfp4.py Resolved
lalala-sh and others added 4 commits October 20, 2026 13:52
Resolve the grouped MoE TDM conflict using the tiled API and its full tensor bounds. Preserve ragged-K zero filling and full K-tile advances for split-inner scale loads, along with the bias offset fix.

Validation: repository-wide Black and Ruff pass; 44 gfx1250 configurations compile with pinned FlyDSL 0.4.0. The two row-major tile_k=256 compile failures reproduce on main. GPU runtime validation requires gfx1250 hardware.
Honor the main-branch revert of the gfx1250 tiled TDM API migration. Restore the original PR kernel, retaining the K-tail bounds, partial-tile compute, and bias column offset fixes.

Validation: repository-wide Black and Ruff pass. All 46 gfx1250 compile configurations pass with FlyDSL 0.4.0, including both row-major tile_k=256 cases. Runtime numerics require gfx1250 hardware.
@yhl-amd
yhl-amd merged commit 60e01e5 into main Oct 23, 2026
@yhl-amd
yhl-amd deleted the wjx/moe_k_tail_oob branch October 23, 2026 02:44
zejunchen-zejun added a commit that referenced this pull request Oct 26, 2026
Kimi-K3 at TP8 with its experts split 8 ways has inter_dim 384, a multiple
of 128 but not of 256. The new case runs the real fused_moe dispatch (a4w4,
SiTUv2, 896 experts, top-16, model_dim 3584, no bias) against the torch
reference at 32 tokens (a bucket of kimik3tp8_tuned_grouped_fmoe.csv) and at
2048, 20000 (padded to 32768) and 131072 tokens, which have no row, so the
dispatch takes its default tiles. Nothing forces a config. It runs JIT rather
than run-only: the grouped-MoE AOT builds only the auxiliary kernels, so
run-only cannot load the TDM GEMM for any shape.

Before #6663 the default k-tile was 256 and the GEMM had no K tail, so the
three default-tile cases dropped the last 128 of K (logits_diff 0.20).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zejunchen-zejun added a commit that referenced this pull request Oct 26, 2026
#6663 made the grouped TDM GEMM run a K that its k-tile does not divide,
with a ragged last tile, but added no in-tree test for it. Kimi-K3 at TP8 is
such a shape for any GEMM2 k-tile wider than 128: inter_dim 384.

The new case runs the real fused_moe dispatch (a4w4, SiTUv2, 896 experts,
top-16, model_dim 3584, no bias, 2048 tokens, which have no row) with
AITER_TDM_TILE_K2 at 256, one full tile and a 128-wide tail, and at 512, a
single ragged tile with K < tile_k, against the torch reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zejunchen-zejun added a commit that referenced this pull request Oct 26, 2026
`--scenario csv` skipped every row of kimik3tp8_tuned_grouped_fmoe.csv. It
read act_type ActivationType.Situv2 as unsupported, and it skipped
inter_dim < 512 on the grounds that tile_k 256 needs two K tiles. Since #6663
the TDM GEMM runs a ragged last k-tile, so the only K constraint left is the
128-wide WMMA step.

The sweep now takes SiTUv2 and prints it as such rather than as silu. It
skips a model_dim or inter_dim that is not a multiple of 128. With a bias, it
also skips an inter_dim that is not a multiple of 256: a gemm1 bias turns off
gemm1's own requantization, and the stage-2 quant that replaces it needs
inter_dim % 256 == 0. Kimi-K3 at TP8 has inter_dim 384 and no bias, so its
rows run with --no-bias.

Its default --csv-path also pointed at op_tests/aiter/configs, which does not
exist; it is <repo>/aiter/configs/tuned_grouped_fmoe.csv, as the comment says.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zejunchen-zejun added a commit that referenced this pull request Oct 26, 2026
…6663

#6663 made the dispatch's default k-tile 128 for both GEMMs and let the TDM
GEMM run a ragged last k-tile. Every row of this table had been measured
against the old default, and buckets 2048-16384 had no row at all.

The table was retuned through the production call on one gfx1250 GPU
(MI455X, 256 CU, FlyDSL 0.4.0). The call is fused_moe with a4w4 and SiTUv2
(beta 4, linear_beta 25): 896 experts, top-16, model_dim 3584, inter_dim 384,
no bias, GateMode.INTERLEAVE and random top-16 routing.

Each candidate ran as a one-row table, found through the normal lookup, and
its output had to be bit-identical to the default tiles' output. Timing is a
CUDA graph of 16 calls that rotates over 8 weight copies and 8 routings, so
the weights are cold, as in the model, where every layer reads its own. The
hot number replays a single call.

Each bucket's best candidate and two runners-up were re-timed against the
default and the previous row, ABBA x 2. They ran at the bucket's own token
count and at about 0.6x of it, a count the same row serves. Buckets
2048-16384 were also checked at T/2 + 1.

The rules:
- A row needs at least 1.03x over the default at the bucket's count, and at
  least 1.00x inside the bucket.
- A previous row stays unless a new one beats it by 1% or more.

Under these rules 512 and 1024 keep their rows. The fastest candidates for
4096 gained 1.15x at 4096 tokens but were 0.90x at 2049-2458, so 4096 takes
8192's tiles instead, 1.04x across the bucket.

Speedup over the default tiles at the bucket's token count (us is the cold
time):

  tokens     1     2     4     8    16    32    64   128   256   512  1024
  cold    1.41  1.43  1.31  1.30  1.11  1.23  1.14  1.15  1.14  1.13  1.12
  hot     1.23  1.24  1.22  1.33  1.23  1.29  1.22  1.19  1.17  1.13  1.12
  tokens  2048  4096  8192 16384
  cold    1.04  1.04  1.03  1.09
  hot     1.05  1.04  1.03  1.10

tflops and bw are 0, as in the other grouped tables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zejunchen-zejun added a commit that referenced this pull request Oct 27, 2026
#6768)

* [Config] Kimi-K3 TP8 gfx1250 grouped-MoE tuning (experts split 8 ways)

Kimi-K3 served as one tensor-parallel group of 8 on gfx1250 with its MoE
split across the group (ATOM K3_MOE=tp) runs the FlyDSL grouped TDM MoE:
every rank holds all 896 experts with inter_dim 3072 / 8 = 384, top-16,
SiTUv2 (beta 4, linear_beta 25), A4W4 MXFP4 per_1x32, GUGU weights.
tuned_grouped_fmoe had no row for that shape, so every call took the TDM
function's default tile.

The default is also wrong for this shape. It runs GEMM2 with tile_k 256 on
K = 384 and drops the last 128 of K. Against the torch reference of aiter's
own test (op_tests/flydsl_tests/test_flydsl_grouped_gemm._torch_moe_ref,
whose gate is logits_diff <= 0.01), its output is 0.194-0.203 logits_diff
away on main, for every token count. (gyu/k3-455-tp8 cc8d4ff fits the tile
at run time instead; that commit is not on main.)

model_configs/kimik3tp8_tuned_grouped_fmoe.csv adds 15 rows for token
buckets 1, 2, 4, ..., 16384, which covers every padded token count of a TP8
server that batches up to 16384 tokens. kimik3tp8_untuned_grouped_fmoe.csv
lists the same shapes. Every row sets tile_k2 = 128, which divides K. Every
row matches the reference: logits_diff 4.5e-6 to 1.1e-4. No key repeats a
row of another grouped table.

Measured with a sweep of the production call, not with gemm_moe_tune.py
--grouped-gemm. That tuner has four problems here:
  - It times every non-Swiglu row as Silu, so a SiTUv2 row never matches
    its own candidate and all candidates run the default tile.
  - It clears _GROUPED_CONFIG_CACHE but not _find_grouped_config's
    lru_cache, so every candidate after a shape's first runs the first
    one's tile.
  - It varies only tile_m and never times the default.
  - It lays out scales differently from the n32k4 layout the model loads.

The sweep instead:
  - prepares weights and scales the way ATOM does on gfx1250
    (moe_shuffle_weight / moe_shuffle_scale, GUGU, n32k4);
  - calls fused_moe with SiTUv2, GateMode.INTERLEAVE and per_1x32, using
    random top-16 routing;
  - uses as baseline the default tile written as an explicit row with
    tile_k2 = 128, and checks it against the torch reference per token;
  - runs each candidate as a single config row, clears both lookup caches,
    and checks that the kernel looked that row up;
  - requires each candidate's output to be bit-identical to the baseline's;
  - times each candidate as a CUDA-graph replay.
GEMM1 tiles are swept first, with tile_m2 = tile_m. GEMM2 tiles are then
swept on the best GEMM1. The baseline and the four fastest candidates are
re-timed at the end.
Tiles that do not divide N or K are excluded: GEMM1 tile_n 512 on N = 768
page-faults.

  token    default us -> tuned us
      1        22.7 ->   19.7  (1.15x)
      2        23.8 ->   19.9  (1.19x)
      4        28.9 ->   23.3  (1.24x)
      8        45.1 ->   35.6  (1.27x)
     16        66.7 ->   55.2  (1.21x)
     32        94.9 ->   79.5  (1.19x)
     64       128.0 ->  107.1  (1.20x)
    128       160.4 ->  138.1  (1.16x)
    256       178.7 ->  151.8  (1.18x)
    512       189.9 ->  162.1  (1.17x)
   1024       212.0 ->  182.8  (1.16x)
   2048       246.9 ->  233.2  (1.06x)
   4096       396.1 ->  351.6  (1.13x)
   8192       640.2 ->  607.7  (1.05x)
  16384      1129.1 -> 1051.1  (1.07x)

Measured on MI455X (gfx1250, 256 CU) with aiter main e999585 and
FlyDSL 0.4.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [FlyDSL][MoE] Grouped-MoE AOT: skip the stage-2 quant prep a shape cannot build

The grouped-MoE AOT precompiled the stage-2 activation quant + preshuffle
(route-ksplit or plain) for every CSV row. Its quant layout needs
feat_dim % 256 == 0 on gfx1250 (wave32, pk8), so a row with inter_dim 384
(Kimi-K3 at TP8, 3072 / 8) failed the whole job:
"[FAIL] compile ... feat_dim must be a multiple of 256, got 384".

The runtime launches that prep only when gemm1 cannot requantize its own
output (a gemm1 bias, or AITER_FLYDSL_DISABLE_GEMM1_REQUANT=1); a bias-free
MoE has gemm1's epilogue write the MX payload and scales instead. So a job
whose inter_dim the quant layout rejects has no stage-2 prep to build: it is
skipped with a note, and the job's other kernels (stage-1 route + quant, the
gather-reduce epilogue) still compile.

quant_layout_supported() reports exactly the geometry the per-block quant
builders accept (_quant_layout's checks), unlike
fused_quant_preshuffle_supported(), which adds the compact path's limits and
would skip shapes the stage-2 builders do take.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [Config] Kimi-K3 TP8 grouped MoE: keep only the rows that are faster end to end

Timed through the real fused_moe dispatch (CUDA graph, a4w4, SiTUv2, 896
experts, top-16, 3584 -> 384, no bias, no forced config) on one gfx1250 GPU,
with the table and without it (the dispatch's default tiles, k-tile fitted to
K = 384), two runs each:

  tokens     1     2     4     8    16    32    64   128   256   512  1024
  speedup 1.14  1.18  1.16  1.11  1.14  1.14  1.11  1.11  1.12  1.11  1.10
  tokens  2048  4096  8192 16384
  speedup 1.01  1.03  0.97  0.97

The 2048-16384 rows were chosen on GEMM time; their larger tile_m pads more
rows for the routing, quant and gather kernels around the GEMMs, which cost
more than the GEMMs gain. Rows below the 1.03x the tuning used are dropped;
those buckets take the default tiles. Outputs are identical either way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [FlyDSL][MoE] Test the Kimi-K3 TP8 grouped MoE past its tuned buckets

Kimi-K3 at TP8 with its experts split 8 ways has inter_dim 384, a multiple
of 128 but not of 256. The new case runs the real fused_moe dispatch (a4w4,
SiTUv2, 896 experts, top-16, model_dim 3584, no bias) against the torch
reference at 32 tokens (a bucket of kimik3tp8_tuned_grouped_fmoe.csv) and at
2048, 20000 (padded to 32768) and 131072 tokens, which have no row, so the
dispatch takes its default tiles. Nothing forces a config. It runs JIT rather
than run-only: the grouped-MoE AOT builds only the auxiliary kernels, so
run-only cannot load the TDM GEMM for any shape.

Before #6663 the default k-tile was 256 and the GEMM had no K tail, so the
three default-tile cases dropped the last 128 of K (logits_diff 0.20).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [FlyDSL][MoE] Test the Kimi-K3 TP8 grouped MoE with a K tail in GEMM2

#6663 made the grouped TDM GEMM run a K that its k-tile does not divide,
with a ragged last tile, but added no in-tree test for it. Kimi-K3 at TP8 is
such a shape for any GEMM2 k-tile wider than 128: inter_dim 384.

The new case runs the real fused_moe dispatch (a4w4, SiTUv2, 896 experts,
top-16, model_dim 3584, no bias, 2048 tokens, which have no row) with
AITER_TDM_TILE_K2 at 256, one full tile and a 128-wide tail, and at 512, a
single ragged tile with K < tile_k, against the torch reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [FlyDSL][MoE] Let the grouped-MoE CSV sweep run SiTUv2 and K-tail rows

`--scenario csv` skipped every row of kimik3tp8_tuned_grouped_fmoe.csv. It
read act_type ActivationType.Situv2 as unsupported, and it skipped
inter_dim < 512 on the grounds that tile_k 256 needs two K tiles. Since #6663
the TDM GEMM runs a ragged last k-tile, so the only K constraint left is the
128-wide WMMA step.

The sweep now takes SiTUv2 and prints it as such rather than as silu. It
skips a model_dim or inter_dim that is not a multiple of 128. With a bias, it
also skips an inter_dim that is not a multiple of 256: a gemm1 bias turns off
gemm1's own requantization, and the stage-2 quant that replaces it needs
inter_dim % 256 == 0. Kimi-K3 at TP8 has inter_dim 384 and no bias, so its
rows run with --no-bias.

Its default --csv-path also pointed at op_tests/aiter/configs, which does not
exist; it is <repo>/aiter/configs/tuned_grouped_fmoe.csv, as the comment says.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [Config] Kimi-K3 TP8 grouped MoE: retune against the default tiles of #6663

#6663 made the dispatch's default k-tile 128 for both GEMMs and let the TDM
GEMM run a ragged last k-tile. Every row of this table had been measured
against the old default, and buckets 2048-16384 had no row at all.

The table was retuned through the production call on one gfx1250 GPU
(MI455X, 256 CU, FlyDSL 0.4.0). The call is fused_moe with a4w4 and SiTUv2
(beta 4, linear_beta 25): 896 experts, top-16, model_dim 3584, inter_dim 384,
no bias, GateMode.INTERLEAVE and random top-16 routing.

Each candidate ran as a one-row table, found through the normal lookup, and
its output had to be bit-identical to the default tiles' output. Timing is a
CUDA graph of 16 calls that rotates over 8 weight copies and 8 routings, so
the weights are cold, as in the model, where every layer reads its own. The
hot number replays a single call.

Each bucket's best candidate and two runners-up were re-timed against the
default and the previous row, ABBA x 2. They ran at the bucket's own token
count and at about 0.6x of it, a count the same row serves. Buckets
2048-16384 were also checked at T/2 + 1.

The rules:
- A row needs at least 1.03x over the default at the bucket's count, and at
  least 1.00x inside the bucket.
- A previous row stays unless a new one beats it by 1% or more.

Under these rules 512 and 1024 keep their rows. The fastest candidates for
4096 gained 1.15x at 4096 tokens but were 0.90x at 2049-2458, so 4096 takes
8192's tiles instead, 1.04x across the bucket.

Speedup over the default tiles at the bucket's token count (us is the cold
time):

  tokens     1     2     4     8    16    32    64   128   256   512  1024
  cold    1.41  1.43  1.31  1.30  1.11  1.23  1.14  1.15  1.14  1.13  1.12
  hot     1.23  1.24  1.22  1.33  1.23  1.29  1.22  1.19  1.17  1.13  1.12
  tokens  2048  4096  8192 16384
  cold    1.04  1.04  1.03  1.09
  hot     1.05  1.04  1.03  1.10

tflops and bw are 0, as in the other grouped tables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [FlyDSL][MoE] Test every row of the Kimi-K3 TP8 grouped-MoE table

The Kimi-K3 TP8 test ran one tuned bucket, 32, and three token counts that
have no row. Every row of the table is its own tile geometry, for example:
- GEMM1 tile_k 512 at 1-4 tokens;
- at 1024, a gemm1 that requantizes for a GEMM2 wave tile twice its own
  height;
- at 16384, GEMM2's single ragged k-tile (tile_k2 512 on K = 384).

The test now reads the table's buckets and runs each one through the real
fused_moe dispatch against the torch reference. It then runs 20000 tokens
(padded to 32768) and 131072, which are past the table and take the default
tiles; their routed buffers pass 2 GiB and 4 GiB.

The K-tail test moves from 2048 tokens, which now have a row, to 20000, which
have none, so its other tiles stay the defaults.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

5 participants