Skip to content

[HIP] [CK] [JIT] Enable swiglu_limit for FP8 per_1x128 blockscale MoE - #7019

Merged
amd-yashagar merged 12 commits into
mainfrom
users/msaffari-amd/aiter/gfx942-fp8-blockscale-swiglu-limit
Nov 11, 2026
Merged

amd-yashagar merged 12 commits into
mainfrom
users/msaffari-amd/aiter/gfx942-fp8-blockscale-swiglu-limit

Conversation

@msaffari-amd

@msaffari-amd msaffari-amd commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

FP8 per-1x128 blockscale MoE was dropping swiglu_limit. A finite SiLU limit is now clamped in the CK stage-1 epilogue, then SiLU runs.

Motivation

The limit was ignored, so the output matched the unclamped path and nothing warned. Callers need the limit they passed, including values other than 7, with the clamp applied before SiLU.

Changes

  • A finite positive limit makes ck_moe_stage1 load a runtime-limit build of the same _silu_ stage-1 CK instances (a separate JIT module): SiLU(min(gate, L)) * clamp(up, -L, L). No new op. None, 0, and +inf disable the clamp and keep the existing module; negative and NaN limits are rejected.
  • Stage 1 stays non-split (ksplit 0) on a _silu_ kernel; a Splitk or non-_silu_ kernel name raises.
  • Paths that would drop the limit now raise: 1-stage, ASM stage 1 without split-K, CK-Tile stage 1, and CK stage 1 with a non-per-1x128 quant. ASM split-K applies the limit in silu_and_mul.
  • Limit rows use their own config family, AITER_CONFIG_FMOE_SWIGLU_LIMIT. A shape with no row falls back to the default config; a config that cannot clamp is discarded with a warning and the heuristic is used, so the result is clamped either way.
  • gfx942 tuned rows: 2048/768, 128 experts, top-k 8, and 4096/1024, 289 experts, top-k 9. Tokens 1, 32, 1024, 8192. Limits 5 and 7. gemm_moe_tune.py --swiglu_limit writes such rows to a separate file.

Performance

No-limit path, FP8 per-1x128, 7168/256, 257 experts, top-k 9, SiLU. Median of five interleaved runs. Before: main 356b0798f0; after: ddeef24b42, the last PR code commit. Both dispatch these shapes identically; ranges overlap except at token 32.

Hardware Workload/configuration Before After Change
MI300X gfx942, ROCm 7.2.4 token 1 40.02 us 40.74 us +1.8%
MI300X gfx942, ROCm 7.2.4 token 16 194.54 us 192.46 us -1.1%
MI300X gfx942, ROCm 7.2.4 token 32 262.97 us 252.67 us -3.9%
MI300X gfx942, ROCm 7.2.4 token 128 392.34 us 395.00 us +0.7%
MI300X gfx942, ROCm 7.2.4 token 1024 590.17 us 566.51 us -4.0%

The limit rows keep timings from an earlier tune of the same tiles; only the stage-1 kernel name changed, so they are not fresh measurements of the runtime-limit kernels.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • No documentation change is needed. The limit is an existing argument.

Dependencies

Breaking Changes

None for callers without a limit: None, 0, and +inf keep the existing path. A finite SiLU limit on a path that cannot clamp now raises instead of being ignored; negative and NaN limits are rejected.

PR Self-Review

Reviewed revision

5a1854a

Behavior and intent

Per-1x128 SiLU now honors a finite swiglu_limit in the CK epilogue: clamp the gate and the up projection, then SiLU. The old path produced the unclamped result and did not say so.

Validation and unverified scope

gfx942 (MI300X, ROCm 7.2.4) after merging main: test_swiglu_limit_guards and run_blockscale_limit_cases in op_tests/test_moe_2stage.py passed, eight cases, max logits diff 1.41e-5 against a 1e-3 threshold (the wrong clamp order gives about 0.044). gfx950: the same eight cases passed in MI35X CI at 8cc94b06d7, max logits diff 5.3e-6 (https://github.com/ROCm/aiter/actions/runs/42788827865/job/129792404357), and on a gfx950 node. The head only adds the main merge and a blank-line fix. Black and Ruff pass on this head.
Not run: MI250X and model end-to-end.

PR-specific question

gfx942 and gfx950; FP8 inputs and weights, per-1x128 (per-128x128 is remapped), SiLU, a finite positive limit, non-split CK stage 1 with a _silu_ kernel. Shapes: any the existing per-1x128 CK kernels support; tuned rows are gfx942 only, and other shapes use the default config or the heuristic, still clamped. Unsupported inputs raise in dispatch or ck_moe_stage1, and CK IsSupportedArgument requires 0 < L < inf and KBatch 1.

Changed op tests

op_tests/test_moe_2stage.py covers blockscale limit accuracy, clamp order, no-limit cases, and invalid/unsupported-limit guards. op_tests/tuning_tests/test_config_shape_collision.py covers collisions for the new swiglu-limit config family.

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

@aiter-bot

aiter-bot commented Oct 30, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 313efee03c1c · 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. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching 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 — Reviewed revision must contain at least the first 7 characters of the current head SHA

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

@amd-yashagar
amd-yashagar force-pushed the users/msaffari-amd/aiter/gfx942-fp8-blockscale-swiglu-limit branch from e8f6df2 to 4f5c6a1 Compare October 30, 2026 09:09
jatseng-ai added a commit to jatseng-ai/aiter that referenced this pull request Nov 3, 2026
…u_limit

With CK RuntimeSwigluLimit (rocm-libraries#13490), route clamped
per_Token / per_Tensor SiLU stage1 to CK silu_and_mul instantiated with
RuntimeSwigluLimit=true and pass the limit to MakeArgument explicitly.
It builds as its own JIT module (-act silulimit, aiter ActOP 5), so the
unclamped silu module is unchanged. Thread swiglu_limit through
ck_moe_stage1 and the shared MoeKernel signature with the same names and
defaults as the blockscale wiring in ROCm#7019.

Without RuntimeSwigluLimit in the CK headers the old behaviour stays:
7.0 runs swiglustep_and_mul (after SiLU), any other finite limit raises.
ASM 1-stage is still refused in get_2stage_cfgs. None and +inf stay
unclamped.

The tuner times the same module and accepts any plain-quant limit. Also
keep the stage1 raise from failing on a missing w1.

Co-authored-by: Cursor <[email protected]>
@amd-yashagar
amd-yashagar force-pushed the users/msaffari-amd/aiter/gfx942-fp8-blockscale-swiglu-limit branch 2 times, most recently from e14234b to 863c23c Compare November 3, 2026 12:22
@amd-yashagar
amd-yashagar marked this pull request as ready for review November 3, 2026 12:34
@amd-yashagar
amd-yashagar requested review from a team and a balanced review from Copilot November 3, 2026 12:34
@github-actions github-actions Bot changed the title [CK] Enable swiglu_limit for FP8 per_1x128 blockscale MoE [HIP] [CK] Enable swiglu_limit for FP8 per_1x128 blockscale MoE Nov 3, 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.

🟡 Changes recommended

Unsupported swiglu limits are still silently dropped for some quantization modes, and CI does not execute the new regression tests.

2 open issues
What changed in this PR

This PR adds runtime swiglu_limit support to FP8 per-1x128 blockscale MoE, applying the gate/up clamp before SiLU in the CK stage-1 epilogue.

Changes:

  • Threads the limit through Python dispatch, bindings, and CK kernels, with guards for unsupported paths.
  • Adds limit-specific tuning and gfx942 configurations for limits 5 and 7.
  • Adds regression tests for clamped outputs, dispatch selection, and missing-row warnings.
File Description
op_tests/​test_moe_blockscale_swiglu_limit.py Adds clamp correctness and dispatch regression tests.
csrc/​include/​rocm_ops.hpp Exposes the limit through Python bindings.
csrc/​include/​moe_ck.h Adds the stage-1 limit parameter.
csrc/​ck_gemm_moe_2stages_codegen/​gen_instances.py Generates swiglustep instances and activation mapping.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_tune.py Adds limit-aware tuning and tagged result storage.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_ck2stages.h Extends shared kernel signatures.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_ck2stages.cu Forwards the limit and maps clamped SiLU activation.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_ck2stages_common.py Registers the swiglustep activation value.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_ck2stages_common.cuh Aligns standard kernels with the extended signature.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_ck2stages_common_mxfp4.cuh Aligns MXFP4 kernel signatures.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_ck2stages_common_mxfp4_bns.cuh Aligns MXFP4 BNS kernel signatures.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_ck2stages_common_blockscale.cuh Passes the runtime clamp into the CK epilogue.
aiter/​ops/​moe_op.py Adds swiglustep module selection and limit forwarding.
aiter/​fused_moe.py Adds clamp-aware dispatch, config lookup, and guards.
aiter/​configs/​model_configs/​a8w8_blockscale_untuned_fmoe_swiglu_limit_gfx942.csv Defines eight tuning shapes.
aiter/​configs/​model_configs/​a8w8_blockscale_tuned_swiglu_limit_fmoe_gfx942.csv Adds sixteen limit-tagged gfx942 tuning results.

Review effort: Balanced

Comment thread aiter/fused_moe.py Resolved
Comment thread aiter/ops/moe_op.py Resolved
@yzhou103

yzhou103 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@valar-cop review

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed..

reproducer for the split-K zeros claim, and any test of the changed unclamped split-K path?

ci Check Repository Dependency failed — looks like the pr itself (high): The head pins 3rdparty/composable_kernel to 6c34b91fd, which the author says is not yet on composable_kernel develop, so the dependency check cannot resolve it.

+Subproject commit 6c34b91fd21bf97abf1226df4bdb583e08612327
composable_kernel pin 6c34b91fd. The dependency check stays red until that commit is on composable_kernel develop.
next: Land the CK commit or re-pin to a commit on develop, then re-run the check. https://github.com/ROCm/aiter/actions/runs/41635165756/job/125914407137

ci check-signal (Aiter Test) failed — not sure yet (low): The job log is empty (0 bytes), so the failure cannot be attributed. The missing CK pin plausibly breaks the build in this run, but that cannot be verified.

next: Re-run with logs retained; if it persists, check whether the CK submodule fetch is the cause. https://github.com/ROCm/aiter/actions/runs/41636816512/job/125920079276

ci Aiter Test Gate failed — not sure yet (low): The log is empty. This gate also fails on 6 of 8 recent runs in other PRs (success 2), which suggests a pre-existing gate/harness issue rather than this PR, but it cannot be confirmed.

next: Check the gate's own history/logs on main; do not treat as blocking until attributed. https://github.com/ROCm/aiter/actions/runs/41636816512/job/125920217595

ci check-signal (OPUS Test) failed — not sure yet (low): The job log is empty and the same job succeeds on all recent main runs, so the cause is undetermined.

next: Re-run with logs retained and compare against main. https://github.com/ROCm/aiter/actions/runs/41636816529/job/125919983176

Comment thread aiter/fused_moe.py Resolved
Comment thread aiter/fused_moe.py Resolved
Comment thread aiter/ops/moe_op.py Resolved
Comment thread aiter/fused_moe.py Resolved
Comment thread aiter/fused_moe.py Resolved
Copilot AI balanced review requested due to automatic review settings November 6, 2026 17:06
@github-actions github-actions Bot changed the title [HIP] [CK] Enable swiglu_limit for FP8 per_1x128 blockscale MoE [HIP] [CK] [JIT] Enable swiglu_limit for FP8 per_1x128 blockscale MoE Nov 6, 2026
@github-actions github-actions Bot added the JIT label Nov 6, 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.

🟡 Changes recommended

A missing API in the pinned CK version prevents blockscale compilation, and disabled limits still clamp outputs, violating the no-clamp contract.

4 open issues
1 resolved since last review

Review effort: Balanced

Comment thread aiter/ops/moe_op.py Resolved

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 insufficient remaining quota.

@amd-yashagar
amd-yashagar merged commit 8c964fa into main Nov 11, 2026
@amd-yashagar
amd-yashagar deleted the users/msaffari-amd/aiter/gfx942-fp8-blockscale-swiglu-limit branch November 11, 2026 19:39
jatseng-ai added a commit to jatseng-ai/aiter that referenced this pull request Nov 12, 2026
… runtime limit

Reuse the per_1x128 runtime SiLU limit from ROCm#7019 for FP8 per_Token and
per_Tensor instead of a separate silulimit / swiglustep stage1 module.

- RUNTIME_SILU_LIMIT_QUANT_TYPES in moe_limits lists per_1x128, per_Token
  and per_Tensor; the dispatch, module, codegen, prebuild and tuner gates
  use it.
- The non-blockscale CK stage1 template passes RuntimeSwigluLimit and the
  limit to DeviceMoeGemm, with the same checks as the blockscale one, and
  the plain FP8 heuristic dispatch forwards the flag.
- get_2stage_cfgs discards tuned rows that cannot clamp before a FlyDSL
  whole-graph row resolves. per_Token / per_Tensor also require FP8 and
  inter_dim % 128 == 0.
- The gfx942 per_Token rows tuned at swiglu_limit=7 move into the
  tuned_swiglu_limit_fmoe family.

Signed-off-by: jatseng-ai <[email protected]>
Co-authored-by: Cursor <[email protected]>
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
…#7019)

* chore(ck): pin the SiLU runtime-limit epilogue

* fix(moe): honor opt-in SiLU limits in blockscale dispatch

* test(moe): cover SiLU limits in the existing two-stage tests

* chore(ck): pin composable_kernel develop with the SiLU limit

Move the pin from the review commit 1152de473 to develop f93c029e09f6,
the mirror of ROCm/rocm-libraries#14751 (commit 78b67c1). The
runtime-limit patch is identical. Develop also carries 93 other
commits since main's pin 96afae1d54.

* fix(moe): reject SiLU-limit tuning with run_config or compare

* test(moe): skip the unlimited ASM 1-stage case in the SiLU limit test

Without a limit, token 1024 at model_dim 256 takes main's untuned
ASM 1-stage default. On gfx942 that now picks a flat kernel for sorted
inputs and faults, on main as well. The case never reaches the limit
epilogue, so it is dropped; the unlimited path stays covered at tokens
1 and 32.

* style(moe): drop extra blank line from main merge

---------

Co-authored-by: Yashvardhan Agarwal <[email protected]>
yzhou103 pushed a commit that referenced this pull request Nov 16, 2026
…untime swiglu_limit (#7361)

* fused_moe: swiglu_limit for FP8 per_Token / per_Tensor on the #7019 runtime limit

Reuse the per_1x128 runtime SiLU limit from #7019 for FP8 per_Token and
per_Tensor instead of a separate silulimit / swiglustep stage1 module.

- RUNTIME_SILU_LIMIT_QUANT_TYPES in moe_limits lists per_1x128, per_Token
  and per_Tensor; the dispatch, module, codegen, prebuild and tuner gates
  use it.
- The non-blockscale CK stage1 template passes RuntimeSwigluLimit and the
  limit to DeviceMoeGemm, with the same checks as the blockscale one, and
  the plain FP8 heuristic dispatch forwards the flag.
- get_2stage_cfgs discards tuned rows that cannot clamp before a FlyDSL
  whole-graph row resolves. per_Token / per_Tensor also require FP8 and
  inter_dim % 128 == 0.
- The gfx942 per_Token rows tuned at swiglu_limit=7 move into the
  tuned_swiglu_limit_fmoe family.

Signed-off-by: jatseng-ai <[email protected]>
Co-authored-by: Cursor <[email protected]>

* Move FP8 per_Token/per_Tensor SiLU limit tests into test_moe_2stage.py

Replace the pytest-only test_moe_ptpc_swiglu_limit.py with a @benchmark
sweep (run_perftest, asserted checkAllclose and per-row error against the
fp32 torch reference, us/TFLOPS/TB/s/err, markdown summary) and a dispatch
check with an injected tagged row, both run by the standard CI invocation.

Co-authored-by: Cursor <[email protected]>

* test_moe_2stage: run FP8 per_Token/per_Tensor SiLU limit cases on gfx950

Add gfx950 to _PLAIN_FP8_LIMIT_GFX so the numerical sweep and the
dispatch/guard checks run on MI35x. The dispatch check's injected tagged
row uses the gfx950 stage-1 and stage-2 instance names (TypeCast CDE op,
N=128 stage-2 tile) on gfx950, and also asserts the stage-2 name.

Co-authored-by: Cursor <[email protected]>

---------

Signed-off-by: jatseng-ai <[email protected]>
Co-authored-by: Cursor <[email protected]>
josh-schell-amd added a commit to josh-schell-amd/vllm that referenced this pull request Nov 23, 2026
AITER applies swiglu_limit to unquantized MoE only on its bf16 a16wmix
path. For fp16, CK stage 1 has no clamped epilogue: v0.1.29.post1 dropped
the clamp silently and v0.1.30 raises NotImplementedError (ROCm/aiter#7019),
which fails HyV4 eager-fp16. Reject that config in
AiterUnquantizedExperts.is_supported_config so the oracle picks a backend
that applies the clamp.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: josh schell <[email protected]>
AndreasKaratzas added a commit to yuzhouo7/vllm that referenced this pull request Nov 28, 2026
ROCm/aiter#7019 first shipped in AITER v0.1.30; say so in the docs and
in the load error. Also state the exactness condition per TP shard,
what happens outside it, and the doubled expert memory.

Co-Authored-By: Claude Code <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
josh-schell-amd added a commit to josh-schell-amd/vllm that referenced this pull request Nov 29, 2026
AITER applies swiglu_limit to unquantized MoE only on its bf16 a16wmix
path. For fp16, CK stage 1 has no clamped epilogue: v0.1.29.post1 dropped
the clamp silently and v0.1.30 raises NotImplementedError (ROCm/aiter#7019),
which fails HyV4 eager-fp16. Reject that config in
AiterUnquantizedExperts.is_supported_config so the oracle picks a backend
that applies the clamp.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: josh schell <[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.

7 participants