Skip to content

[FlyDSL] Kimi-K3 TP8 gfx1250 grouped-MoE tuning (experts split 8 ways) - #6768

Merged
zejunchen-zejun merged 8 commits into
mainfrom
zejun/k3-tp8-moe-tune
Oct 27, 2026
Merged

zejunchen-zejun merged 8 commits into
mainfrom
zejun/k3-tp8-moe-tune

Conversation

@zejunchen-zejun

Copy link
Copy Markdown
Contributor

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.

@zejunchen-zejun
zejunchen-zejun requested review from a team and a balanced review from Copilot October 21, 2026 09:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 6768 --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.

@zufayu
zufayu self-requested a review October 22, 2026 01:16
@zufayu zufayu self-assigned this Oct 22, 2026
Copilot AI balanced review requested due to automatic review settings October 22, 2026 01:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zufayu

zufayu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

The K=384 configuration is not safe across the full production dispatch range yet.

The Python 3.12 AOT build currently reports multiple GROUPED_MOE failures because the route/quant path assumes feat_dim % 256 == 0, which K=384 does not satisfy. In addition, the new tuning rows only cover token counts through 16384. Larger buckets such as 32768 and 131072 fall back to the default tile_k2=256 path, which does not cover the final 128 elements of K=384 correctly.

Please fix the runtime/default fallback so K=384 is handled correctly for every token bucket, rather than relying only on additional tuning rows. Please add regression coverage that exercises the real dispatch at the larger token counts, and rerun AOT correctness and same-machine performance tests without forcing a configuration.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot changed the title [Config] Kimi-K3 TP8 gfx1250 grouped-MoE tuning (experts split 8 ways) [FlyDSL] Kimi-K3 TP8 gfx1250 grouped-MoE tuning (experts split 8 ways) Oct 22, 2026
@github-actions github-actions Bot added FlyDSL and removed Config labels Oct 22, 2026
@zejunchen-zejun

Copy link
Copy Markdown
Contributor Author

Thanks @zufayu. All four points are addressed on the branch (144ca3af9..6123d6067). Everything below was measured on one gfx1250 GPU, Python 3.12.

1. AOT GROUPED_MOE failures (feat_dim % 256) (f57366232)

Cause. The grouped-MoE AOT precompiled the stage-2 activation quant + preshuffle for every CSV row. Its quant layout needs feat_dim % 256 == 0 on gfx1250 (wave32, pk8), so each K3 TP8 row (inter_dim 384) failed its whole job.

Why the runtime doesn't need it. The runtime launches that prep only when gemm1 cannot requantize its own output: a gemm1 bias, or AITER_FLYDSL_DISABLE_GEMM1_REQUANT=1. For a bias-free MoE, gemm1's epilogue writes the MX payload and scales itself.

Fix. The AOT now skips that prep for such a shape and prints a note; the job's other kernels still compile. quant_layout_supported() reports exactly the geometry the per-block quant builders accept. fused_quant_preshuffle_supported() adds the compact path's limits, and would skip shapes the stage-2 builders do take.

python -m aiter.aot.flydsl.grouped_moe before vs after:

CSV before after
kimik3tp8_tuned_grouped_fmoe.csv 0 ok, 30 failed 22 ok, 0 failed
default (all grouped tables) 356 ok, 30 failed 378 ok, 0 failed

2. Token buckets past the table fell back to tile_k2 = 256 (641ca39e6, Guanbao Yu's cc8d4ff12 cherry-picked; 6123d6067 for ruff UP033)

_grouped_a8w4_tdm_moe now narrows each stage's k-tile to the widest of 512, 256 or 128 that divides its K. flydsl_grouped_gemm_a8w4_masked raises for a tile that does not divide K. Every bucket and every shape without a row is now correct; the rows only choose speed.

3. Regression coverage through the real dispatch (b5ea5632e)

test_grouped_a4w4_situv2_kimi_k3_tp8_matches_torch_ref runs fused_moe (a4w4, SiTUv2, 896 experts, top-16, 3584 → 384, no bias) against _torch_moe_ref, with logits_diff < 0.01. Nothing forces a config.

tokens bucket before after
32 tuned row 3.7e-6 3.7e-6
2048 default tiles — 3.6e-6
20000 32768, default tiles 0.201 3.6e-6
131072 131072, default tiles 0.201 3.6e-6

The test runs JIT, not run-only. The grouped-MoE AOT builds only the auxiliary kernels; the TDM GEMM has no AOT wiring yet, so run-only cannot load the GEMM for any shape. The existing grouped tests fail the same way under run-only, before and after this change.

4. Same-machine performance, no forced config (e0d9e056e)

End-to-end fused_moe (CUDA graph) with the table vs without it. Two runs each; run-to-run noise was under 1%. Outputs are identical.

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

The 2048–16384 rows had been chosen on GEMM time. Their larger tile_m pads more rows for the routing, quant and gather kernels around the GEMMs, and that costs more than the GEMMs gain. Those four rows are dropped (below the 1.03× bar the tuning used), so their buckets take the default tiles, which the k-tile fit keeps correct. The table now has 11 rows, 1–1024 tokens.

@zufayu

zufayu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for the detailed follow-up. The AOT fix, large-token regression cases, and unforced end-to-end performance results address the concerns on the previous base.

However, current main has since merged #6663, which adds correct K-tail handling to the grouped TDM GEMM and changes its default tile_k to 128. This branch now has a real merge conflict in grouped_gemm_mxfp4.py (mergeable_state: dirty). More importantly, the new K % tile_k rejection in this PR is based on the old no-tail behavior and would reject shapes that #6663 now supports; _fit_tile_k also needs to be reconsidered against the new default.

Please rebase onto current main and reconcile these changes semantically, rather than just resolving the conflict textually. Keep the AOT fix and useful tuning, but remove or justify any remaining divisibility restriction/retile logic. On the rebased head, please rerun the K=384 default-dispatch correctness cases (including the 32768 and 131072 token buckets), the AOT build, and same-machine performance without forced configuration, then let CI complete. I can re-review that head promptly.

zejunchen-zejun and others added 5 commits October 26, 2026 10:57
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]>
…nnot 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]>
…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]>
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]>
#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]>
Copilot AI balanced review requested due to automatic review settings October 26, 2026 03:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@zejunchen-zejun

Copy link
Copy Markdown
Contributor Author

Rebased onto main 8965764059, which includes #6663, and force-pushed (6123d6067..6e13e6348). The branch is linear, and the PR no longer touches grouped_gemm_mxfp4.py or grouped_moe_gfx1250.py, so the conflict is gone.

Changes on this head

Next steps on this head (on gfx1250; results will be posted here)

  1. Correctness through the real dispatch, nothing forced. pytest op_tests/flydsl_tests/test_flydsl_grouped_gemm.py -k kimi_k3_tp8: 32 tokens (tuned row); 2048, 20000 (padded to 32768) and 131072 (default tiles); and the two K-tail cases. Gate: logits_diff < 0.01.
  2. AOT. python -m aiter.aot.flydsl.grouped_moe, once with --csv aiter/configs/model_configs/kimik3tp8_tuned_grouped_fmoe.csv and once with the default (all grouped tables). Expect 0 failed.
  3. Same-machine performance, no forced config. End-to-end fused_moe (CUDA graph), table vs no table, 1–16384 tokens, two runs each. The speedups in the description and in the CSV commits were measured against the pre-[FlyDSL] [gfx1250] Fix the dropped K tail and the bias column offset in the grouped MoE TDM GEMM #6663 default (GEMM1 tile_k 256, GEMM2 fitted to 128). The default is now 128 for both GEMMs, so they will be re-measured:
    • any of the 11 rows (1–1024) below 1.03× against the new default is dropped;
    • 2048–16384, which have no row (dropped earlier at 0.97–1.03× against the old default), are re-checked;
    • tile_k2 256 and 512, which K=384 can now run with a tail, are added to the candidates.
  4. Config shape-collision guard (op_tests/tuning_tests/test_config_shape_collision.py) in a ROCm env. A pandas check of the merged tuned_grouped_fmoe family already finds no duplicate key, and no open PR adds a 3584/384 row.
  5. Then fold the two CSV commits into one with the re-measured numbers, and update the description, which still says the default drops K's tail. CI runs on MI300X/MI35X, where the gfx1250 tests skip, so the gfx1250 results will be posted here once CI finishes.

@zejunchen-zejun
zejunchen-zejun marked this pull request as draft October 26, 2026 07:19
zejunchen-zejun and others added 3 commits October 26, 2026 09:10
`--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]>
…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]>
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]>
@zejunchen-zejun
zejunchen-zejun marked this pull request as ready for review October 26, 2026 10:39
Copilot AI balanced review requested due to automatic review settings October 26, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@zejunchen-zejun
zejunchen-zejun merged commit cd69afd into main Oct 27, 2026
98 checks passed
@zejunchen-zejun
zejunchen-zejun deleted the zejun/k3-tp8-moe-tune branch October 27, 2026 01:07
zhiding512 added a commit that referenced this pull request Oct 27, 2026
…-moe-dryrun-20261009

aiter/aot/flydsl/grouped_moe.py stays deleted: moe.py replays the grouped
table through the runtime. #6768 taught it to skip the stage-2 quant prep
for an inter_dim the quant layout rejects (Kimi-K3 TP8, 384); the runtime
launches that prep only when gemm1 cannot requantize (a gemm1 bias, or
AITER_FLYDSL_DISABLE_GEMM1_REQUANT=1), and the replay passes SiTUv2 rows no
bias, so it never reaches the prep either.

Co-authored-by: Cursor <[email protected]>
zhiding512 added a commit that referenced this pull request Oct 27, 2026
#6768 added it so the grouped-MoE AOT script could skip the stage-2
quant prep that inter_dim 384 (Kimi-K3 at TP8) cannot build. This branch
deletes that script: moe.py replays the grouped rows through the
runtime, which launches the prep only when gemm1 cannot requantize its
own output (a gemm1 bias, or AITER_FLYDSL_DISABLE_GEMM1_REQUANT=1).
Kimi-K3's SiTUv2 rows take no bias, so their replay requests no stage-2
quant kernel, and nothing else calls the helper.

Signed-off-by: zhimding <[email protected]>
Co-authored-by: Cursor <[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.

3 participants