Repository navigation
feat(plugins): route aiter's fused MoE calls to fused_moe, SiTUv2 fp8 activations included - #160
Merged
Merged
Conversation
kyle-256
requested review from
RuibinCheung,
irvineoy,
jiejingzhangamd,
xiaobochen-amd and
zhenhuang12
as code owners
November 12, 2026 10:14
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues can block SGLang startup without optional aiter and alter SwiGLU arithmetic, alongside additional API compatibility and validation gaps.
7 open issues
Check SwiGLU activation dtype selection before enabling the route · New Skip aiter route registration when the optional package is unavailable · New Preserve positional binding of the out parameter · New Gate route installation on the installed aiter signature · New Validate vLLM paths or retain the existing exclusions · New Use uint8 fallback when float4_e2m1fn_x2 is unavailable · New Include benchmark client commands and prompt corpus details · New
What changed in this PR
This PR centralizes aiter fused MoE routing for SGLang and vLLM, allowing AKLR to serve SiTUv2 FP8 activations while unsupported calls fall back to aiter.
Changes:
- Add a shared adapter for argument translation, output buffers, and per-call SiTUv2 activation selection.
- Register the SGLang 0.5.22 aiter hook and reuse the adapter in vLLM.
- Extend the op API with
act_quant, add routing tests, and document the integration.
| File | Description |
|---|---|
tests/plugins/sglang/test_hook.py |
Checks aiter route registration and parameter compatibility. |
tests/plugins/aiter/test_routes.py |
Tests routing, activation selection, fallbacks, and output forwarding. |
tests/plugins/aiter/__init__.py |
Adds the aiter test package. |
aklr/plugins/vllm/layers/fused_moe.py |
Delegates vLLM calls to the shared adapter. |
aklr/plugins/sglang/aiter_calls.py |
Declares the SGLang aiter fused MoE route. |
aklr/plugins/sglang/__init__.py |
Loads aiter routes during plugin registration. |
aklr/plugins/README.md |
Documents the shared adapter and SGLang hooks. |
aklr/plugins/aiter/fused_moe.py |
Implements argument translation and activation-aware routing. |
aklr/plugins/aiter/__init__.py |
Exports the shared fused MoE adapter. |
aklr/ops/fused_moe/api.py |
Adds the activation quantization width parameter. |
Review effort: Max
| act_quant = 4 | ||
| # aiter picks SiTUv2's activation dtype at each call (AITER_SITUV2_A8W4, AITER_SITUV2_A4W4): fp8 is | ||
| # fused_moe's, on sglang's gate-up interleaved weights; any other goes back to aiter | ||
| if attr_value(activation) == "situv2": |
| for package in op_packages(): | ||
| if package.startswith(f"{__name__}."): | ||
| importlib.import_module(f"{package}.api") | ||
| importlib.import_module(f"{__name__}.aiter_calls") |
Comment on lines
+42
to
43
| act_quant=4, # bits per quantized activation element: SiTUv2 quantizes to fp8 (8) | ||
| out: torch.Tensor | None = None, # the caller's output buffer; None: dispatch allocates it |
Comment on lines
+18
to
+19
| @sglang_route("aiter.fused_moe.fused_moe", versions=("0.5.22",)) | ||
| def _fused_moe( |
| ): | ||
| return FallbackReason.OUT_OF_CONTRACT | ||
| return fused_moe( | ||
| return aklr_aiter.fused_moe( |
| Situv2 = 1 | ||
|
|
||
|
|
||
| FP8, FP4 = torch.float8_e4m3fn, torch.float4_e2m1fn_x2 |
| __all__: list[str] = [] | ||
|
|
||
|
|
||
| @sglang_route("aiter.fused_moe.fused_moe", versions=("0.5.22",)) |
… activations included Routes aiter's `fused_moe` calls to AKLR `fused_moe` from sglang 0.5.22 and vLLM through one function in `aklr/plugins/aiter`.
kyle-256
force-pushed
the
kyle/k3-fused-moe
branch
from
November 12, 2026 14:04
d023ccc to
e43eedd
Compare
This was referenced Nov 13, 2026
zhenhuang12
pushed a commit
that referenced
this pull request
Nov 14, 2026
- aiter's SwiGLU MoE reaches fused_moe only where aiter rounds its activations as fused_moe does (#160). - A sglang route whose target needs a package that is not installed is left unhooked instead of ending sglang's start (#160). The lm_head routes hand gemm the hidden states as they are; the Triton GEMM route takes the K3 image's aiter's persistent option (#159). vLLM's GEMM warmup records no workload and builds only the weight shapes of the rank's model and drafter (#165). - Attention residual, sglang and vLLM: masked lanes score -inf; one lane stores each LDS partial; sums of squares past float32 are summed again scaled (decode kernels, on a uniform rare path, the common path as before) or prescaled by 2**-32 (prefill kernels); vLLM's mix without an output norm is weighted by normalized weights (#162, #176). - kimi_k3_attn_res: RMS weights may be any finite value; the reference widens each chunk only and returns the prefix unscored with no bank row (#176). Route tests, GPU range regressions, the vLLM baseline's parity with vLLM's kernel, and two more vLLM Points.
kyle-256
added a commit
that referenced
this pull request
Nov 16, 2026
… activation rounding, sglang without aiter (#197) * fix(plugins): fixes from Copilot's reviews of the merged Kimi-K3 PRs - aiter's SwiGLU MoE reaches fused_moe only where aiter rounds its activations as fused_moe does (#160). - A sglang route whose target needs a package that is not installed is left unhooked instead of ending sglang's start (#160). The lm_head routes hand gemm the hidden states as they are; the Triton GEMM route takes the K3 image's aiter's persistent option (#159). vLLM's GEMM warmup records no workload and builds only the weight shapes of the rank's model and drafter (#165). - Attention residual, sglang and vLLM: masked lanes score -inf; one lane stores each LDS partial; sums of squares past float32 are summed again scaled (decode kernels, on a uniform rare path, the common path as before) or prescaled by 2**-32 (prefill kernels); vLLM's mix without an output norm is weighted by normalized weights (#162, #176). - kimi_k3_attn_res: RMS weights may be any finite value; the reference widens each chunk only and returns the prefix unscored with no bank row (#176). Route tests, GPU range regressions, the vLLM baseline's parity with vLLM's kernel, and two more vLLM Points. * test(plugins): drop the finite-input attention-residual tests Their 36 sglang and 18 vLLM cases each loaded every committed schema (about 23 s on the CI node) and stopped the unit tests at their 25-minute limit. * fix(plugins): keep the no-norm attention residual within its VGPRs The rare path for a sum of squares past float32 loaded all nine rows at once for its mix. That pushed the 896-thread kernel past its 128 VGPRs, so the common path spilled its rows to scratch (47 VGPRs, 192 bytes) and ran at 0.76x of the baseline. Without a norm the rare path now loads one row at a time, with a scheduling barrier between rows of the mix: 120 VGPRs and no scratch, about 1.9x again on all four workloads.
kyle-256
added a commit
that referenced
this pull request
Nov 23, 2026
…situv2_a4w4_moe to aklr/ops aklr/plugins/aiter/fused_moe.py was #160's route on aiter's public fused_moe. Since #271 the provider serves that call and nothing ran the wrapper; provider/moe.py took only its argument mapping. The mapping (op_kwargs and its three helpers) moves into provider/moe.py, unchanged; the wrapper, the package's fused_moe export and test_routes.py go. test_routes.py's mapping tests now test op_kwargs (test_provider_moe_mapping.py); its declined-argument test was test_provider_moe's DECLINED already. situv2_a4w4_moe is an op: it moves to aklr/ops with its schemas, unchanged (contract [email protected]), and its small Point to tests/ops/cases.py.
xiaobochen-amd
pushed a commit
that referenced
this pull request
Nov 23, 2026
* refactor(plugins/aiter): only the provider under aklr/plugins/aiter; situv2_a4w4_moe to aklr/ops aklr/plugins/aiter/fused_moe.py was #160's route on aiter's public fused_moe. Since #271 the provider serves that call and nothing ran the wrapper; provider/moe.py took only its argument mapping. The mapping (op_kwargs and its three helpers) moves into provider/moe.py, unchanged; the wrapper, the package's fused_moe export and test_routes.py go. test_routes.py's mapping tests now test op_kwargs (test_provider_moe_mapping.py); its declined-argument test was test_provider_moe's DECLINED already. situv2_a4w4_moe is an op: it moves to aklr/ops with its schemas, unchanged (contract [email protected]), and its small Point to tests/ops/cases.py. * refactor(plugins/sglang): drop the aiter MLA prefill and lm_head routes from sglang's layers aiter_backend_mla_prefill replaced AiterAttnBackend._mla_fp8_prefill_attn_ps and _build_prefill_ps_metadata, which run aiter's fp8 MLA prefill (mla_prefill_ps, mla_reduce): a route on an aiter call from a framework plugin. aiter routes these ops, so AKLR serves them through the aiter provider or not at all; the provider has no mla_prefill_ps selector yet. Until it has, sglang's fp8 MLA prefill runs on aiter, as with AKLR off, including aiter's fault past 131072 keys a chunk that the route stepped around. logits_processor_torch_gemm replaced LogitsProcessor._compute_lm_head, the lm_head GEMM of every sglang model: a generic GEMM in a framework plugin. sglang's layers keep model-specific routes only. * refactor(plugins/vllm): drop the route on aiter's Triton unified_attention The route replaced aiter.ops.triton.unified_attention.unified_attention, an aiter function, from the vLLM plugin. aiter does not route it (it is not among aiter's plugin contracts), so no route of AKLR's takes it until aiter does; the README's exception for it goes. On stack.json's aiter its five new parameters also failed the route's signature check, and with it the whole device_ready hook batch, so vLLM did not start with AKLR on. The unified_attention op and its schemas stay. * refactor(plugins): drop the routes that swap one aiter call: DeepSeek's MLA core and Muse Spark's experts sglang's DeepseekMLARocmForwardMixin.forward_absorb_rocm_core route swapped two aiter calls one for one (mla_kc_rope_cache for fused_fp8_bmm_rope_cat_and_cache_mla, mla_vc for the a8w8 batched GEMM) and called sglang's attention and o_proj back unchanged. aiter routes neither function. The route, both ops and their schemas go; the prepare route (mla_qkv_a_norm, qkv_a GEMM with both norms) stays and no longer yields to it. vLLM's MuseSparkAiterExperts.apply route (muse_spark_moe) wrapped aiter's fused_moe behind one deferred RMSNorm (_defer_norm). Both routes, the op, its schemas and test go; aiter's fused_moe reaches AKLR through the provider. The pooler and unpooler route (_torch_linear) stays. * docs(plugins): the vLLM plugin tutorial on Kimi-K3's attn_res; no route replaces an aiter function The tutorial's example, Muse Spark's muse_spark_moe and its two routes, is gone: it walks through Kimi-K3's attn_res instead, a model's own Triton kernel that aiter has no op for, and says what a route may replace. hook.py's docstring and the plugins README said a route could replace an aiter function inside a vLLM custom op; neither does any more. * fix(ops): the moved situv2_a4w4_moe schemas without their measured fields At their new path the audit's change rule finds no base for them, so the accuracy, speedup and microseconds they carried read as edits (PERF_EDITED); only CI writes those. CI measures the three kernels again. * refactor(plugins): keep Muse Spark's fused experts and DeepSeek MLA's absorb kernels Muse Spark's route stays: its op fuses vLLM's pre-expert RMSNorm (what _defer_norm leaves) into the MXFP4 experts' gather, one FlyDSL launch doing more than aiter's fused_moe call, so it replaces a segment, not an aiter function; the plugins README and the vLLM hook say so. Its contract, 4 schemas and tests are main's, unchanged. DeepSeek MLA's mla_kc_rope_cache and mla_vc lose their route (each swapped one aiter call that aiter does not route) but keep their kernels: both contracts move to aklr/ops/mla_absorb (op_type mla_absorb) with their 7 schemas, without measured fields for CI to measure again. The aiter provider serves them once aiter routes fused_fp8_bmm_rope_cat_and_cache_mla and its a8w8 batched GEMM.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Routes aiter's
fused_moecalls to AKLRfused_moefrom sglang 0.5.22 and vLLM through one function inaklr/plugins/aiter.AITER_SITUV2_A8W4) goes tofused_moewithact_quant=8(newfused_moeargument), anything else back to aiter.fused_moedoes not take (scaled activations, padding, shared experts, scatter, a caller's quant types) goes back to aiter.Base: main. The GEMM, fused_moe and MLA decode PRs each add
aklr/plugins/aiterand sglang'saiter_calls.pyholding only their own functions; whichever lands later rebases (import lines).End to end
Kimi-K3 on 8× MI355X, sglang 0.5.22 as the cookbook's MI355X cell (TP8, DCP8 a2a, aiter attention, fp8 KV, DSPARK block 7, ReplaySSM). Prompts are cut from a fixed corpus of Python source, the same every run. This PR off (
[email protected]) vs on, every other K3 PR on in both, same server flags otherwise; the 100K rows and the 200K/500K rows come from two MI355X nodes, each row's off and on from the same node:fused_moe serves no call of Kimi-K3's decode at C=1 and 2: the 8 and 16 tokens of those steps go to
kimi_k3_latent_moe, the same in both arms, so the decode column is run-to-run spread. It serves the prefill (16384-token chunks) and decode at 24–56 tokens (3–7 requests).Commands:
SGLANG_USE_AITER=1 SGLANG_AITER_K3_OPT=1 AITER_FLYDSL_FORCE=1 AITER_SITUV2_A8W4=1 SGLANG_AITER_HONOR_EXPLICIT_MEM_FRACTION=1 AKLR_SGLANG_PLUGIN=1 sglang serve --model-path Kimi-K3 --tp-size 8 --dcp-size 8 --dcp-comm-backend a2a --prefill-attention-backend aiter --decode-attention-backend aiter --kv-cache-dtype fp8_e4m3 --mem-fraction-static 0.85 --mamba-full-memory-ratio 7.97 --speculative-algorithm DSPARK --speculative-draft-model-path Kimi-K3-DSpark --speculative-dspark-block-size 7 --enable-linear-replayssm-spec. Each case flushes the cache and times each prompt's prefill (max_tokens=1), then decodes 1000 tokens for its C requests at once from the cached prompts; the decode step is decode time × accept length / tokens.