Skip to content

[FlyDSL] [CI] [MoE] Enable AITER_FLYDSL_USE_HERD on gfx1250 and add a fused HERD selector for GPT-OSS - #6527

Merged
coderfeli merged 16 commits into
mainfrom
cguo/gfx1250_herd
Oct 29, 2026
Merged

coderfeli merged 16 commits into
mainfrom
cguo/gfx1250_herd

Conversation

@charlieguo1106

@charlieguo1106 charlieguo1106 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

HERD selects K+1 candidate experts per token and drops the least batch-popular candidate, breaking ties by score and expert ID. This change supports performing the drop either in a standalone router finalize kernel or inside MoE token sorting on gfx950.

  • AITER_HERD_FUSED_DROP=1: fused drop, enabled by default.
  • AITER_HERD_FUSED_DROP=0: standalone router drop.

Both paths renormalize the retained K weights and preserve the routed scaling factor. GPT-OSS candidate softmax remains in the router. The fused path reuses the existing sorting buffer allocation.

Performance

End-to-end: DeepSeek-V4-Flash, TP1, gfx1250

Setup

  • Model: DeepSeek-V4-Flash, TP1 on a single gfx1250.
  • ATOM f19778df4 with the FlyDSL HERD patch; aiter cguo/gfx1250_herd (266d1641c).
  • Serving benchmark: random dataset, ISL 1024 / OSL 1024, 256 prompts, max concurrency 64, --ignore-eos.
  • FlyDSL: prefill and decode on the FlyDSL routed experts. HERD on = AITER_FLYDSL_USE_HERD=1 with the default fused drop (AITER_HERD_FUSED_DROP=1): Top-7 candidates, dropped to 6 inside the route/prefix-sum kernel.
  • Triton: FlyDSL prefill + Triton/Gluon decode (ATOM_USE_TRITON_MOE=1 ATOM_USE_TRITON_MOE_DECODE=1). HERD on = AITER_TRITON_USE_HERD=1.
  • HERD applies to decode batches of 16-128 tokens.

Throughput and latency (concurrency 64)

Backend HERD Total throughput (tok/s) Mean TPOT (ms) Mean TTFT (ms)
FlyDSL off 12702.75 9.34 755.91
FlyDSL on 13647.26 8.65 752.23
Backend Total throughput, HERD on vs off Mean TPOT, HERD on vs off
FlyDSL +7.4% -7.4%

Accuracy: gsm8k (lm_eval local-completions, 3-shot, 65 concurrent requests, max_gen_toks 2048)

Backend HERD flexible-extract strict-match
FlyDSL off 0.9553 ± 0.0057 0.9560 ± 0.0056
FlyDSL on 0.9560 ± 0.0056 0.9568 ± 0.0056
Triton off 0.9515 ± 0.0059 0.9507 ± 0.0060
Triton on 0.9454 ± 0.0063 0.9462 ± 0.0062

Notes

  • Each configuration is a single benchmark run. The GPU was shared, and another user's GPU job ran during all four runs, so treat the throughput and latency numbers as indicative.
  • Two of the gsm8k numbers come from a different server session of the same configuration than the throughput row: FlyDSL HERD off and Triton HERD on.

ATOM integration

Enabling the environment variable alone is insufficient. ATOM must allocate K+1 candidate outputs, select those candidates without dropping, and pass herd_topk and herd_routed_scaling_factor to fused_moe:

import torch

from aiter.fused_moe import fused_moe
from aiter.ops.flydsl.herd_topk import herd_topk_candidates

candidate_weights = torch.empty(
    (num_tokens, top_k + 1),
    device=hidden_states.device,
    dtype=torch.float32,
)
candidate_ids = torch.empty_like(candidate_weights, dtype=torch.int32)

herd_topk_candidates(
    candidate_weights,
    candidate_ids,
    router_logits,
    correction_bias,
    scoring_func,
)

output = fused_moe(
    hidden_states,
    w1,
    w2,
    candidate_weights,
    candidate_ids,
    herd_topk=top_k,
    herd_routed_scaling_factor=routed_scale,
    **existing_moe_args,
)

Keep the model's existing activation, quantization, weight scales and layout arguments. Use this integration for renormalized decode routing; retain ordinary routing for hash layers, prefill and unsupported configurations.

The current fused path requires unmasked routes without fused shared experts or stage-1 route weighting.

Set AITER_HERD_FUSED_DROP before CUDA graph capture and recapture when switching paths.

Validation

  • 11 local correctness tests passed, covering retained experts and weights, sorting layout, scaling and CUDA graph replay.
  • Both drop paths passed model operator output checks across five seeds.
  • Ruff, Python compilation and formatting checks passed.

@charlieguo1106
charlieguo1106 requested a review from a team October 14, 2026 09:17
@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 6527 --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.

@charlieguo1106

Copy link
Copy Markdown
Contributor Author

herd_e2e_bench.py

Use command like python herd_e2e_bench.py --model gptoss_tp1 --fmt a4w4 --tile 16 256 256 to reproduce the results.

@zufayu
zufayu requested a review from coderfeli October 15, 2026 02:10
@zufayu
zufayu requested review from aoli26 and yadaish October 15, 2026 07:33
@zufayu zufayu assigned yadaish and unassigned coderfeli Oct 15, 2026
Comment thread aiter/ops/flydsl/grouped_moe_gfx1250.py Resolved
…-kernel, dropping the per-call bias cast and standalone quant for GPT-OSS.
…d GEMM and decouple bias from the fused requant.
Fused drop (AITER_HERD_FUSED_DROP=1) runs in the gfx1250 grouped MoE route and
prefix-sum kernel: one launch counts K+1 candidate popularity, drops the least
popular candidate per token, renormalizes the kept K with the routed scaling
factor, and writes topids_to_rows, psum and the gather weights.

Router drop (AITER_HERD_FUSED_DROP=0) reuses the standalone finalize kernel and
then takes the ordinary grouped MoE path.
charlieguo1106 and others added 2 commits October 26, 2026 03:53
# Conflicts:
#	aiter/ops/flydsl/grouped_gemm_mxfp4.py
#	aiter/ops/flydsl/kernels/mxfp4_preshuffle_gfx1250_tdm.py
#	aiter/ops/topk.py
A4W4 and A8W4 rows for GPT-OSS TP1 (model_dim=3072, inter_dim=3072, E=128,
K=4) on gfx1250, tokens 16..32768, taken from dev/yadai_gptoss_mi450_tuning
(e74d504).
@github-actions github-actions Bot changed the title [FlyDSL] [MoE] Enable AITER_FLYDSL_USE_HERD on gfx1250 and add a fused HERD selector for GPT-OSS [FlyDSL] [CI] [MoE] Enable AITER_FLYDSL_USE_HERD on gfx1250 and add a fused HERD selector for GPT-OSS Oct 27, 2026
@github-actions github-actions Bot added the CI label Oct 27, 2026
…nter

The router now routes pad rows to expert -1 (num_valid_rows), and on the
gfx1250 grouped TP path those ids reach moe_route unchanged. It indexed the
per-expert counter through a raw pointer, so every -1 route did an atomic
add on the int32 just before the counter allocation. The route now takes
DROPPED_ROUTE_ROW instead, which the psum remap, the route-indexed quant and
gather-reduce already skip.

A test guards the counter with one extra leading element: before the fix it
read 384 after a batch of 64 pad rows at top-6, now 0.
@coderfeli
coderfeli merged commit b5078fc into main Oct 29, 2026
55 checks passed
@coderfeli
coderfeli deleted the cguo/gfx1250_herd branch October 29, 2026 04:01
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
… fused HERD selector for GPT-OSS (#6527)

* [FlyDSL][MoE] Support selectable router and fused HERD drop paths on gfx950

* [MoE] Update the fused_moe signature test for the HERD parameters

* [FlyDSL][MoE] Fuse biased gfx1250 GEMM1 requant and read fp32 bias in-kernel, dropping the per-call bias cast and standalone quant for GPT-OSS.

* [FlyDSL][MoE] Read bf16/fp32/fp16 bias natively in the gfx1250 grouped GEMM and decouple bias from the fused requant.

* [FlyDSL][MoE] Support router and fused HERD drop paths on gfx1250

Fused drop (AITER_HERD_FUSED_DROP=1) runs in the gfx1250 grouped MoE route and
prefix-sum kernel: one launch counts K+1 candidate popularity, drops the least
popular candidate per token, renormalizes the kept K with the routed scaling
factor, and writes topids_to_rows, psum and the gather weights.

Router drop (AITER_HERD_FUSED_DROP=0) reuses the standalone finalize kernel and
then takes the ordinary grouped MoE path.

* [MoE][gfx1250] Add GPT-OSS gfx1250 tuned grouped MoE configs

A4W4 and A8W4 rows for GPT-OSS TP1 (model_dim=3072, inter_dim=3072, E=128,
K=4) on gfx1250, tokens 16..32768, taken from dev/yadai_gptoss_mi450_tuning
(e74d504).

* Fix gfx1250 MoE bias and constrain fused HERD routing

* Keep original gfx1250 MoE bias epilogues

* Delete docs/herd_pr_review_response.md

* Keep automatic HERD topk routing on gfx950

* [FlyDSL][MoE] Keep -1 routes out of the gfx1250 TP route kernel's counter

The router now routes pad rows to expert -1 (num_valid_rows), and on the
gfx1250 grouped TP path those ids reach moe_route unchanged. It indexed the
per-expert counter through a raw pointer, so every -1 route did an atomic
add on the int32 just before the counter allocation. The route now takes
DROPPED_ROUTE_ROW instead, which the psum remap, the route-indexed quant and
gather-reduce already skip.

A test guards the counter with one extra leading element: before the fix it
read 384 after a batch of 64 pad rows at top-6, now 0.

* [FlyDSL][MoE] Support ATOM valid token counts in HERD

---------

Co-authored-by: yadaish <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
… fused HERD selector for GPT-OSS (ROCm#6527)

* [FlyDSL][MoE] Support selectable router and fused HERD drop paths on gfx950

* [MoE] Update the fused_moe signature test for the HERD parameters

* [FlyDSL][MoE] Fuse biased gfx1250 GEMM1 requant and read fp32 bias in-kernel, dropping the per-call bias cast and standalone quant for GPT-OSS.

* [FlyDSL][MoE] Read bf16/fp32/fp16 bias natively in the gfx1250 grouped GEMM and decouple bias from the fused requant.

* [FlyDSL][MoE] Support router and fused HERD drop paths on gfx1250

Fused drop (AITER_HERD_FUSED_DROP=1) runs in the gfx1250 grouped MoE route and
prefix-sum kernel: one launch counts K+1 candidate popularity, drops the least
popular candidate per token, renormalizes the kept K with the routed scaling
factor, and writes topids_to_rows, psum and the gather weights.

Router drop (AITER_HERD_FUSED_DROP=0) reuses the standalone finalize kernel and
then takes the ordinary grouped MoE path.

* [MoE][gfx1250] Add GPT-OSS gfx1250 tuned grouped MoE configs

A4W4 and A8W4 rows for GPT-OSS TP1 (model_dim=3072, inter_dim=3072, E=128,
K=4) on gfx1250, tokens 16..32768, taken from dev/yadai_gptoss_mi450_tuning
(e74d504).

* Fix gfx1250 MoE bias and constrain fused HERD routing

* Keep original gfx1250 MoE bias epilogues

* Delete docs/herd_pr_review_response.md

* Keep automatic HERD topk routing on gfx950

* [FlyDSL][MoE] Keep -1 routes out of the gfx1250 TP route kernel's counter

The router now routes pad rows to expert -1 (num_valid_rows), and on the
gfx1250 grouped TP path those ids reach moe_route unchanged. It indexed the
per-expert counter through a raw pointer, so every -1 route did an atomic
add on the int32 just before the counter allocation. The route now takes
DROPPED_ROUTE_ROW instead, which the psum remap, the route-indexed quant and
gather-reduce already skip.

A test guards the counter with one extra leading element: before the fix it
read 384 after a batch of 64 pad rows at top-6, now 0.

* [FlyDSL][MoE] Support ATOM valid token counts in HERD

---------

Co-authored-by: yadaish <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants