Repository navigation
[HIP] [CK] [JIT] Enable swiglu_limit for FP8 per_1x128 blockscale MoE - #7019
amd-yashagar merged 12 commits into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
e8f6df2 to
4f5c6a1
Compare
…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]>
e14234b to
863c23c
Compare
There was a problem hiding this comment.
🟡 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
|
@valar-cop review |
valar-cop
left a comment
There was a problem hiding this comment.
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
… 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]>
…#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]>
…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]>
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]>
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]>
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]>


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
ck_moe_stage1load 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._silu_kernel; a Splitk or non-_silu_kernel name raises.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.gemm_moe_tune.py --swiglu_limitwrites 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.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
Documentation
Dependencies
f93c029e09f6, which includes merged feat(composablekernel): add a runtime SiLU limit to blockscale MoE rocm-libraries#14751 plus 93 other develop commits since main's pin96afae1d54. The dependency check passes on the current PR head.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_guardsandrun_blockscale_limit_casesinop_tests/test_moe_2stage.pypassed, 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 at8cc94b06d7, 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 orck_moe_stage1, and CKIsSupportedArgumentrequires 0 < L < inf and KBatch 1.Changed op tests
op_tests/test_moe_2stage.pycovers blockscale limit accuracy, clamp order, no-limit cases, and invalid/unsupported-limit guards.op_tests/tuning_tests/test_config_shape_collision.pycovers collisions for the new swiglu-limit config family.