Skip to content

[FlyDSL] [Perf] gfx1250 grouped MoE: route small TP batches in one launch - #6894

Open
ahmed-bsod wants to merge 1 commit into
mainfrom
ahmed/qwen
Open

ahmed-bsod wants to merge 1 commit into
mainfrom
ahmed/qwen

Conversation

@ahmed-bsod

@ahmed-bsod ahmed-bsod commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

On gfx1250, the grouped MoE builds the TP expert row map with three launches: a counter fill, moe_route and moe_contiguous_psum_remap. In decode these kernels are short, so the launches cost more than the work. fused_route_psum_remap does the same work in one launch, but nothing called it.

Technical Details

For TP calls with tokens * topk <= 4096 and experts <= 512, call fused_route_psum_remap and skip contiguous_psum_remap. The outputs do not change. Larger batches and the EP and compact paths keep the old code.

Test Plan

  • op_tests/test_flydsl_moe_aux.py (test_route_psum_fused)
  • op_tests/flydsl_tests/test_flydsl_grouped_gemm.py --scenario verify --data-format a4w4 --experts 256 --topk 8 --model-dim 2048 --inter-dim 512 --act silu --no-bias --tokens 1 32 64 512 513
  • Qwen3.5-35B-A3B-MXFP4, TP4 on gfx1250: serving benchmark (1k in / 1k out) and GSM8K

Test Result

  • Both tests pass: the fused routing matches exactly, and the grouped MoE passes on both sides of the 4096 limit.
  • Routing time per MoE layer: 5.5 µs → 2.6–3.2 µs at 1 token, 6.5 µs → 2.7–3.3 µs at 64 tokens.
  • Output throughput: +1.7% at c32 (7,458 → 7,588 tok/s), +1.8% at c64 (12,586 → 12,807 tok/s). c1 is unchanged within noise.
  • GSM8K (3-shot, strict match): 0.857.

Submission Checklist

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

@Boss2002n
Boss2002n marked this pull request as ready for review October 24, 2026 14:22
@Boss2002n
Boss2002n requested review from a team and a balanced review from Copilot October 24, 2026 14:22
@github-actions github-actions Bot changed the title In the TP path, when tokens x topk <= 4096 and experts <= 512, build the [FlyDSL] In the TP path, when tokens x topk <= 4096 and experts <= 512, build the Oct 24, 2026

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.

🔵 Needs a closer look

Correctness and latency validation on gfx1250 are not provided for the newly selected execution path.

No open issues 🎉

What changed in this PR

This PR optimizes small-batch expert routing in the gfx1250 FlyDSL tensor-parallel MoE path by reusing the existing fused routing helper.

Changes:

  • Selects fused routing when tokens × top-k ≤ 4096 and experts ≤ 512.
  • Reuses the fused counts, contiguous row map, and aligned prefix sums, bypassing separate routing and remapping launches.
  • Retains the existing path for larger batches.
File Description
aiter/​ops/​flydsl/​grouped_moe_gfx1250.py Adds small-batch fused routing dispatch and skips redundant prefix-sum remapping.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 24, 2026 16:34
@ahmed-bsod ahmed-bsod changed the title [FlyDSL] In the TP path, when tokens x topk <= 4096 and experts <= 512, build the [FlyDSL] [Perf] gfx1250 grouped MoE: route small TP batches in one launch Oct 24, 2026

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.

🔵 Needs a closer look

Correctness and comparative latency evidence on gfx1250 is unavailable for the newly enabled routing path, so final human review is needed.

No open issues 🎉

Review effort: Balanced

@yadaish

yadaish commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

#6668
looks quite similar as this PR, Could you take a look whether PR above can resolve your problem.

@github-actions

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FlyDSL stale The PR hasn't been updated in 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants