Skip to content

[FlyDSL] Use typed APIs in MoE routing and MX quantization - #6379

Merged
coderfeli merged 7 commits into
mainfrom
codex/flydsl-moe-route-api
Oct 20, 2026
Merged

coderfeli merged 7 commits into
mainfrom
codex/flydsl-moe-route-api

Conversation

@coderfeli

@coderfeli coderfeli commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Use typed FlyDSL pointers and fx.atomic_add for global and LDS route counters in MoE routing, fused prefix sum, and quant scatter kernels.
  • Express TDM gather descriptor address widening and splitting with FlyDSL numeric casts.
  • Use public typed fx arithmetic, unsigned comparisons and shifts, selects, min/max, and casts in shared MX quantization helpers. The helpers retain their raw IR return contract and target-specific rocdl.cvt_scalef32_* operations.

Validation

  • Black, Ruff, py_compile, and git diff --check pass across all five files.
  • With pinned FlyDSL 0.3.4.1 on gfx950, route-map and fused route-prefix-sum probes passed for 128 routes and 8 experts, checking counters, row bands, bijection, and inverse mapping where applicable.
  • With pinned FlyDSL 0.3.4.1, fused quant scatter and fused route-prefix-sum quant scatter cross compiled for gfx1250 and produced final ISA. The fx.Index launcher cast produced byte identical gfx1250 final ISA.
  • TDM gather group-0 MLIR verified for runtime i32 and index offsets, including zero extension, logical high-word shift, and truncation.
  • The MX scale helper's final gfx950 ISA is byte identical to origin/main for all four E8M0 rounding modes across FP4 E2M1, FP8 E4M3, and FP8 E4M3 FNUZ, plus FP4 nibble conversion. Its native amax/scale path has byte identical final gfx1250 ISA.

The gfx1250 checks are compile-only on this host.

TDM vector follow-up

TDM gather descriptor groups now use fx.Vector.from_elements, and the direct MLIR vector and rocdl imports are gone. With pinned FlyDSL 0.3.4.1, the descriptor probe's final ISA is byte identical to the previous PR head. Black, Ruff, compileall, and git diff --check pass.

TDM vector follow-up (folded from closed #6391)

  • Build TDM descriptor groups with fx.Vector.from_elements and remove the vendored MLIR vector dialect proxy.
  • With pinned FlyDSL 0.3.4.1, final gfx950 ISA is byte identical for the TDM gather and TDM primitive descriptor probes after consolidation.

@coderfeli
coderfeli requested a review from a team October 10, 2026 15:23
@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: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 6379 --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.

@github-actions github-actions Bot changed the title Refactor FlyDSL MoE routing to typed APIs [FlyDSL] Refactor FlyDSL MoE routing to typed APIs Oct 10, 2026
@coderfeli coderfeli changed the title [FlyDSL] Refactor FlyDSL MoE routing to typed APIs [FlyDSL] Use typed APIs in MoE routing and MX quantization Oct 10, 2026
@zufayu
zufayu requested a review from yadaish October 12, 2026 01:25
@zufayu
zufayu requested a review from aoli26 October 15, 2026 07:33
@coderfeli
coderfeli merged commit eb56b2d into main Oct 20, 2026
@coderfeli
coderfeli deleted the codex/flydsl-moe-route-api branch October 20, 2026 00:49

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

LGTM

GwilliamHu pushed a commit that referenced this pull request Oct 20, 2026
main deleted this package's `vector` proxy in #6379 and moved its own
descriptor builders onto `fx.Vector`, so the stage-1 kernel's nine
`vector.from_elements(T.vec(n, T.i32), ...)` calls no longer import. The
element type comes from the elements now, so the type argument goes with
them.

`TDM._i32` returns an `fx.Int32` in that same commit, which leaves the one
raw `arith.shli` beside it mixing a typed operand into a raw op;
`_tdm_group1_rows` reads its row count and shifts through `fx` instead, the
way main's `tdm_group1_rows_4b` already does.

Rebased onto main (65 commits) and re-measured: stage 1 is 209.4 us at tpr
1536 and 138.6 at 512, against 208.6-209.4 and 138.5 before the rebase, and
logits stay identical to the default path at both.

Co-Authored-By: Claude Opus 5 <[email protected]>
lalala-sh added a commit that referenced this pull request Oct 20, 2026
…after merging main

The main merge broke both halves of this branch:

- #6379 moved moe_fused_route_quant_scatter.py to the typed fx API and dropped
  its arith import, but the multidest token loop still built its block offset
  with arith.constant. Tracing the multidest copy raised NameError, so the
  EP4 MegaMoE path with a prequantized dispatch failed at its first call.
  Build it with fx.Uint32, as the rest of this kernel now does with bid/tid.
- The tuned_grouped_fmoe.csv conflict was resolved to main's rows, which
  reverted gemm1 of the 8192 x 7168 x 2048, E=64/65, topk=-1 rows to
  m_warp=1, n_warp=4. Restore m_warp=4, n_warp=2.
GwilliamHu added a commit that referenced this pull request Oct 29, 2026
main deleted this package's `vector` proxy in #6379 and moved its own
descriptor builders onto `fx.Vector`, so the stage-1 kernel's nine
`vector.from_elements(T.vec(n, T.i32), ...)` calls no longer import. The
element type comes from the elements now, so the type argument goes with
them.

`TDM._i32` returns an `fx.Int32` in that same commit, which leaves the one
raw `arith.shli` beside it mixing a typed operand into a raw op;
`_tdm_group1_rows` reads its row count and shifts through `fx` instead, the
way main's `tdm_group1_rows_4b` already does.

Rebased onto main (65 commits) and re-measured: stage 1 is 209.4 us at tpr
1536 and 138.6 at 512, against 208.6-209.4 and 138.5 before the rebase, and
logits stay identical to the default path at both.

Co-Authored-By: Claude Opus 5 <[email protected]>
Boss2002n pushed a commit that referenced this pull request Oct 30, 2026
main deleted this package's `vector` proxy in #6379 and moved its own
descriptor builders onto `fx.Vector`, so the stage-1 kernel's nine
`vector.from_elements(T.vec(n, T.i32), ...)` calls no longer import. The
element type comes from the elements now, so the type argument goes with
them.

`TDM._i32` returns an `fx.Int32` in that same commit, which leaves the one
raw `arith.shli` beside it mixing a typed operand into a raw op;
`_tdm_group1_rows` reads its row count and shifts through `fx` instead, the
way main's `tdm_group1_rows_4b` already does.

Rebased onto main (65 commits) and re-measured: stage 1 is 209.4 us at tpr
1536 and 138.6 at 512, against 208.6-209.4 and 138.5 before the rebase, and
logits stay identical to the default path at both.

Co-Authored-By: Claude Opus 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.

2 participants