Skip to content

[FlyDSL] [Bugfix] Route a16w4 SiLU MoE to CK-Tile and apply swiglu_limit - #5802

Closed
kevin-mii wants to merge 2 commits into
ROCm:mainfrom
kevin-mii:fix/moe-bf16-silu-fp4-cktile
Closed

kevin-mii wants to merge 2 commits into
ROCm:mainfrom
kevin-mii:fix/moe-bf16-silu-fp4-cktile

Conversation

@kevin-mii

@kevin-mii kevin-mii commented Sep 24, 2026 •

Copy link
Copy Markdown

Summary

Route interleaved bf16-activation × MXFP4-weight SiLU MoE with bf16 output to CK-Tile’s split-K post-activation path. CK2stages has no matching A16W4 SiLU heuristic. Forward the caller’s swiglu_limit through CK-Tile to the FlyDSL interleaved activation instead of dropping it.

This is the small-batch DeepSeek-V4.1 path below AITER_BF16_FP8_MOE_BOUND. The existing SwiGLU tagged/untagged weight-layout routing is preserved. SwiGLU continues to request the standard post-activation layout; the new SiLU route is limited to GateMode.INTERLEAVE.

Validation

Against main 1dd826c42, on gfx950 / ROCm 10 / PyTorch 2.11 / FlyDSL 0.4:

  • op_tests/test_moe_a16w4_silu_limit.py: both M=1 and M=32 end-to-end cases passed against the clamped reference, with a check that unclamped output differs.
  • Existing test_swiglu_mxfp4_nonsplit_nobias_dispatch and test_swiglu_mxfp4_untagged_layout_dispatch regressions passed.
  • Black, CI-pinned Ruff 0.16.0, and whitespace checks passed.

New-head required CI remains pending upstream workflow approval.

A bf16-activation x MXFP4-weight SiLU MoE (the small-batch route below
AITER_BF16_FP8_MOE_BOUND, e.g. DeepSeek-V4.1 on gfx950) fell through to
CK2stages, which has no A16W4 SiLU kernel and no clamp: the JIT build fails,
and where it builds the swiglu_limit is dropped. Give SiLU on gate/up
interleaved weights the same CK-Tile split-K route SwiGLU uses, forward
swiglu_limit to cktile_moe_stage1, and let flydsl_silu_and_mul_interleaved
take the limit instead of a fixed inf.

op_tests/test_moe_a16w4_silu_limit.py runs a DeepSeek-V4.1-shaped MoE
(model_dim 5120, inter_dim 2304) through fused_moe against the clamped torch
reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kevin-mii
kevin-mii requested review from a team and a lite review from Copilot September 24, 2026 01:28

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.

kevin-mii added a commit to kevin-mii/sglang that referenced this pull request Sep 24, 2026
Measured on MI355X (DeepSeek-V4.1-Flash TP4, DSpark EP4) with
AITER_BF16_FP8_MOE_BOUND=0, as the AMD DeepSeek-V4 tests and cookbook set it:
- the stage-1 LDS-DMA drain: GSM8K 0.885 unpatched vs 0.905 patched (200
  questions), throughput within noise, and its race test passes unpatched;
  it stays upstream as ROCm/aiter#5561;
- the bf16 SiLU route is never taken at bound 0; the fix is ROCm/aiter#5802;
- the tuned FMoE CSV shows no end-to-end gain; it stays upstream as
  ROCm/aiter#5562.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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; main branch always runs both MI35X and MI300X
multigpu 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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 5802 --add-label <label>

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 opt this PR out.

@github-actions github-actions Bot changed the title [Bugfix] Route a16w4 SiLU MoE to CK-Tile and apply swiglu_limit [FlyDSL] [Bugfix] Route a16w4 SiLU MoE to CK-Tile and apply swiglu_limit Sep 24, 2026
@zufayu
zufayu requested a review from yadaish September 26, 2026 00:20
@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 Oct 11, 2026
@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Oct 16, 2026
Copilot AI lite review requested due to automatic review settings October 28, 2026 00:06
@kevin-mii

Copy link
Copy Markdown
Author

Updated against main in a436a92. The SiLU A16W4 route and clamp are still missing upstream, so this PR remains needed. The merge preserves the newer SwiGLU tagged/untagged weight-layout rules while adding the interleaved SiLU route separately.

Fresh gfx950 / ROCm 10 / PyTorch 2.11 / FlyDSL 0.4 validation:

  • Both end-to-end SiLU clamp cases (M=1 and M=32) pass against the clamped reference. The test also checks that the unclamped reference differs, so it exercises the limit.
  • The existing SwiGLU no-bias and untagged-layout regression functions pass.
  • Black, CI-pinned Ruff 0.16.0 and whitespace checks pass.

The fork branch is updated. GitHub’s upstream workflow runs need maintainer approval before required CI can establish merge readiness.

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.

🟡 Changes recommended

The change still has critical SiLU dispatch bugs that can select unsupported stage-2 shapes or misinterpret non-interleaved weights, and its regression test is not executed by CI and uses insufficient output validation.

4 open issues

Review effort: Lite

Comment thread aiter/fused_moe.py
Comment on lines +4226 to +4231
or (
activation == ActivationType.Silu
and dtype == dtypes.bf16
and q_dtype_a in [dtypes.bf16, dtypes.fp16]
and gate_mode is GateMode.INTERLEAVE
)
Comment thread aiter/fused_moe.py
Comment on lines +4487 to +4489
"standard"
if mxfp4_bf16_cktile and activation == ActivationType.Swiglu
else "auto"
Comment on lines +105 to +106
diff = _cos_diff(ref.float(), out.float())
assert diff < 1e-2, f"a16w4 SiLU with swiglu_limit: cos diff {diff:.3e}"
Comment on lines +104 to +106
assert not out.isnan().any().item(), "a16w4 SiLU output contains NaN"
diff = _cos_diff(ref.float(), out.float())
assert diff < 1e-2, f"a16w4 SiLU with swiglu_limit: cos diff {diff:.3e}"
@kevin-mii

Copy link
Copy Markdown
Author

Closing because this is no longer needed by the current DeepSeek-V4.1 serving path.

sgl-project/sglang#45480 now explicitly passes quant_dtype_a=fp8 for V4.1's FP4 routed experts, bypassing AITER's small-batch BF16 selection. The cookbook removed AITER_BF16_FP8_MOE_BOUND=0 in sgl-project/sglang#45693 with the 20261021 image; the same FP8 path is selected without the environment override.

The earlier validation established that this patch supplies behavior missing from AITER. The subsequent downstream-history check establishes that our current V4.1 recipe no longer needs that behavior. This closure does not mean the BF16 SiLU dispatch/clamp issue is fixed upstream, or that BF16 and FP8 have been shown accuracy-equivalent.

The branch and test evidence remain available if BF16 activation support becomes a concrete requirement again. The new review findings remain unresolved and would need attention before reviving the change.

@kevin-mii kevin-mii closed this Oct 28, 2026
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