Skip to content

[FlyDSL] [fix] gfx942: keep a clamped SiLU on CK, not the whole-graph backend - #8337

Closed
zufayu wants to merge 1 commit into
mainfrom
zufayu/gate-gfx942-flydsl-clamp
Closed

zufayu wants to merge 1 commit into
mainfrom
zufayu/gate-gfx942-flydsl-clamp

Conversation

@zufayu

@zufayu zufayu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Fixes the routing half of #8334.

Summary

On gfx942, a fused_moe call with per_Token FP8 and an active swiglu_limit
was routed to the FlyDSL whole-graph backend, which clamps inaccurately — and
worse the tighter the bound. This closes both paths that reach it so a clamped
call stays on CK.

Two entry points, both removed:

  1. the clamped-SiLU fallback added in [FlyDSL] gfx942 MoE: offset and clamp fixes, num_local_tokens, clamped-SiLU default, V4.1-Flash rows #7820
  2. the flydsl_gfx942_row exemption from [FlyDSL] [MoE] gfx942: check the CK swiglu_limit limits after the FlyDSL backend #8178, which let a tuned
    impl__flydsl_gfx942__ row survive the "this row cannot clamp" discard

Evidence

Max per-row relative L2 error against a torch fp32 reference with no fp8
intermediate requantization (per_Token, token=64, gfx942):

limit fused_moe (FlyDSL) two-stage reference routed to
None 0.0275 0.0274 CK
7.0 0.0497 0.0202 FlyDSL
1.0 0.1140 0.0089 FlyDSL

Not a swapped clamp order: the test's own swapped reference
(silu(gate).clamp(max=L) * up.clamp(-L,L)) scores > 0.2, FlyDSL scores
0.09–0.11. Full matrix and an unverified lead into gfx9_fp8/gemm1.py are in
#8334.

This also unbreaks main

The routing is why test_plain_fp8_swiglu_limit_dispatch dies with
AttributeError: 'NoneType' object has no attribute 'keywords' on MI300X (run
44408312107, shard 5/8): the whole-graph metadata carries stage1=None. With
this change that test passes unmodified, including its
inter_dim=192 must raise NotImplementedError expectation — the guard it checks
is the inter_dim % 128 one that the FlyDSL fallback was bypassing.

#8294 was opened to revert #7361 for that crash. It is not needed if this lands.

Validation

Run on gfx942 (MI308X, cu=80), aiter built from this branch:

  • test_plain_fp8_swiglu_limit_dispatch — passes, source unmodified
  • test_plain_fp8_swiglu_limit, all 30 (quant, token, limit) combinations —
    30/30 pass. Before: every case an active clamp routed to FlyDSL failed
    (row error 0.0906 / 0.1141, and 42% outside rtol/atol at limit=7); after,
    those cases sit at 0.0041–0.0048.
  • black --check, ruff check clean.

Not verified by me: the CI runner is MI300X (cu=304) and tuned config lookup
keys on cu_num, so the exact dispatch can differ. The dispatch failure matched
the CI log line for line; the numerical matrix has not been independently
confirmed at cu=304. ci:mi300x is set on this PR.

Trade-off for the reviewers

#7820 added the fallback because the default heuristics take the 1-stage kernel,
which cannot clamp. With it closed, such a call falls back to CK and an
unsupported shape raises NotImplementedError instead of silently computing a
differently-clamped result. That is the intended direction — raise rather than
compute wrong — but it is a behavior change for callers that relied on the
fallback, so it is your call whether to take this or to fix the FlyDSL clamp
first.

… backend

A fused_moe call with per_Token FP8 and an active swiglu_limit on gfx942 was
routed to the FlyDSL whole-graph backend, by two paths: the clamped-SiLU
fallback added in #7820, and the flydsl_gfx942_row exemption from #8178 that
let a tuned impl__flydsl_gfx942__ row survive the "this row cannot clamp"
discard.

That backend clamps inaccurately, and worse the tighter the bound. Max per-row
relative L2 error against a torch fp32 reference with no fp8 intermediate
requantization, per_Token, token=64, on gfx942:

  limit    fused_moe (FlyDSL)   two-stage reference   routed to
  None     0.0275               0.0274                CK
  7.0      0.0497               0.0202                FlyDSL
  1.0      0.1140               0.0089                FlyDSL

It is not a swapped clamp order: the test's own swapped reference scores > 0.2,
FlyDSL scores 0.09-0.11.

Close both paths so a clamped call stays on CK, which also restores the
inter_dim % 128 guard below for these shapes. #8334 tracks the
accuracy problem itself; this only stops the routing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu requested a review from a team November 20, 2026 02:23
@zufayu zufayu added the ci:mi300x Run MI300X standard and OPUS CI on PRs label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 8337 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision ea324da090ce · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What is the most important boundary or failure mode introduced by this change, and what evidence covers it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@zufayu

zufayu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Closing this: routing around the problem is the wrong fix, and testing it
proved so.

Gating the whole-graph backend does stop the inaccurate clamp and does unbreak
test_plain_fp8_swiglu_limit_dispatch, but it regresses shapes CK cannot
serve. fused_moe with an active clamp on V4.1-Flash (inter_dim=576, not a
multiple of 128) now raises instead of running:

NotImplementedError: fused_moe cannot apply swiglu_limit=10.0 for
QuantType.per_Token SiLU at inter_dim=576; the runtime-limit CK stage1 needs a
multiple of 128.

FlyDSL needs only a multiple of 64, which is why it was serving those shapes.
Trading "computes inaccurately" for "does not run at all" on a shape #7820 was
built for is not mine to decide, and narrowing the gate to inter_dim % 128 == 0
would just leave the remaining shapes quietly inaccurate.

The accuracy problem itself is the thing to fix, and it is written up with
evidence in #8334: fp32-reference comparison, the with/without-gate error
matrix, and an unverified lead into gfx9_fp8/gemm1.py where the two scale
paths clamp at different points.

One more thing surfaced while testing this and is worth a look independently:
with the clamped call routed back to CK on MI300X (cu=304), the tuned row from
a8w8_plain_tuned_swiglu_limit_fmoe_gfx942.csv fails to resolve:

RuntimeError: Unknown or incompatible CK MoE kernel:
moe_ck2stages_gemm1_256x16x64x256_1x4_MulABScale_v1_Nswizzle0_Quant2_MulRoutedWeight0_silu_F8_F8_B16;
regenerate instances or retune this configuration

The instance is present in a locally JIT-built runtime-clamp module, so this
looks specific to the prebuilt wheel; I did not get to the bottom of it. Those
rows have not been exercised since #7820 landed, because the fallback took
these calls.

Reopen this if the call is "raise rather than compute wrong" — the change and
its validation stand as written.

@zufayu zufayu closed this Nov 20, 2026
@zufayu

zufayu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #8353, which takes the narrow version of this: CK-capable FP8
shapes (inter_dim % 128 == 0) go back to the CK clamp, and shapes CK cannot
serve (inter_dim 576) keep the FlyDSL fallback — avoiding the
NotImplementedError regression that closed this PR.

@zufayu

zufayu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Correction to my closing comment above: the accuracy claim in it is wrong, and
I have retracted it in #8334.

The gfx942 FlyDSL decode kernels read bf16 activations; my fp32 reference fed
fp8-quantized ones (CK's pipeline). Measured against a bf16-input reference,
FlyDSL sits at ~0.005 relative row error and is flat across clamp tightness —
it is accurate. #8350 fixes the test reference for exactly this reason.

That does not change the outcome for this PR: the broad gate still caused the
inter_dim=576 NotImplementedError regression, and #8353 is the right shape
of fix. But the premise I gave for it — "the whole-graph backend clamps
inaccurately" — was my measurement error, not a property of the kernel.

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

Labels

ci:mi300x Run MI300X standard and OPUS CI on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants