Repository navigation
feat(plugins): serve Qwen3.5 GDN decode with unquantized projections on the BF16 op - #76
Merged
Merged
Conversation
…on the BF16 op The GDN route on Qwen3_5GatedDeltaNet.forward served only layers whose out_proj is block FP8, so the Qwen3.5 MXFP4 checkpoint, whose GDN projections sglang runs unquantized, always fell back. When in_proj_qkvz, in_proj_ba and out_proj are all UnquantizedLinearMethod, decode now runs [email protected] alone and hands its BF16 output to out_proj, as sglang's own decode does; prefill of such layers stays on sglang. The FP8 path keeps its checks, ops and calls. Up to 64 rows, sglang packs the two BF16 projections into one GEMM and hands on column slices of its output; the route copies them contiguous for the op, which reads them row-major. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zhenhuang12
marked this pull request as ready for review
November 9, 2026 01:24
zhenhuang12
requested review from
jiejingzhangamd,
xiaobochen-amd and
zhenhuang12
as code owners
November 9, 2026 01:24
zhenhuang12
approved these changes
Nov 9, 2026
zhenhuang12
left a comment
Collaborator
There was a problem hiding this comment.
Verified the latest successful CI run for this head and inspected the change scope. Unit tests and audit passed. No schema changes; benchmark validation is conditionally skipped. The new route tests passed. Approving for the requested squash merge; this does not claim additional end-to-end model validation.
There was a problem hiding this comment.
🟡 Changes recommended
The packed-projection route can select a slower decode path because its speedup qualification excludes the two .contiguous() copy launches.
1 open issue
What changed in this PR
Extends the Qwen3.5 GDN route to decode layers with unquantized projections, allowing MXFP4 checkpoints’ BF16 GDN layers to use existing AKLR kernels.
Changes:
- Adds BF16-only decode routing while retaining the existing FP8 path and unsupported-case fallbacks.
- Makes packed projection slices contiguous and adds six stand-in routing tests.
- Reuses existing schemas; companion PR #75 expands supported batch sizes.
| File | Description |
|---|---|
tests/plugins/sglang/test_qwen3_5_gdn_route.py |
Tests FP8/BF16 routing, contiguous projections, and unsupported-case fallback. |
aklr/plugins/sglang/models/qwen3_5/api.py |
Adds unquantized-projection eligibility checks and BF16-only decode execution. |
Review effort: Max
| if not fp8_groups: | ||
| # up to 64 rows, sglang runs both BF16 projections as one GEMM and hands on | ||
| # column slices of its output; the ops read them row-major | ||
| qkvz, ba = qkvz.contiguous(), ba.contiguous() |
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.

Why
The GDN route on
Qwen3_5GatedDeltaNet.forwardserves only layers whoseout_projis block FP8. For the Qwen3.5 MXFP4 checkpoint (amd/Qwen3.5-397B-A17B-MXFP4), every GDN decode falls back to SGLang. Its Quark config excludes all 45 GDN layers'linear_attn.*projections, so SGLang 0.5.22 runs them withUnquantizedLinearMethod. This PR extends the same route: decode of such a layer goes to[email protected], whose BF16 outputout_projtakes as SGLang's own decode hands it.Scope
versions=("0.5.22",)).out_projis not block FP8 on aiter's CK GEMM, decode runs on[email protected]alone, providedin_proj_qkvz,in_proj_baandout_projare allUnquantizedLinearMethod.main: SGLang's projections, then the op,_track_mamba_state_decode, andout_proj.main.main's BF16 schema.[email protected]).Tradeoffs
finalize_fused_in_proj,SGLANG_QWEN35_PACKED_IN_PROJon by default) and hands on column slices of its (rows, 5152) output. Those slices are not contiguous from 2 rows on, and[email protected]reads its inputs row-major, so dispatch would decline them.main's 64-row BF16 kernel ran 27.3 µs against SGLang's 38.9 µs in an earlier MI355X run (not CI). The copies may take a third to most of that 11.6 µs gain.SGLANG_QWEN35_PACKED_IN_PROJ=0makes SGLang run the two projections separately, so nothing is copied but one more GEMM runs. Or a[email protected]layout variant for strided projection rows plus kernels that take a row stride: a contract and kernel change, not made here.Verification
Environment: head
5e5d0c6, Mac CPU only: Python 3.12.11, torch 2.8.0 (CPU), no Triton, SGLang or AITER. CI withci:gpuruns the GPU unit tests on this head; no schema changes, so there is nothing to bench.Gate overrides: none
Code
New
tests/plugins/sglang/test_qwen3_5_gdn_route.py: 6 tests on stand-ins of SGLang 0.5.22's modules.out_projtakes its (rows, 2048) BF16 output.main'sapi.py, only the unquantized-decode test fails, as expected.FP8 path unchanged: an uncommitted stand-in harness traced every call the route makes into SGLang and the ops, with each argument's shape, dtype, contiguity and identity. On
mainand on this head it covered 11 FP8-checkpoint scenarios:out_projon aiter's Triton GEMM;All 11 traces are identical. For MXFP4 layers, decode at 1, 32, 64 and 128 rows is now served (copies only at 32 and 64); prefill, LoRA and a Quark FP8
out_projstay on SGLang.python -m aklr export check: exit 0.python -m aklr validate --base origin/main --stages audit: no schema to validate, passed.pytest -q tests/plugins/sglang tests/ops: 185 passed, 62 skipped (main: 179 passed, 62 skipped, plus the 6 new tests).pytest -q tests: 55 failed, 605 passed, 161 skipped, 1 error; the FAILED/ERROR set is identical tomain's, all environment-only.pre-commit run --files <changed files>: passed.Not run
ci:gpu): its GPU unit tests, including the new test with real SGLang installed.AKLR_SGLANG_PLUGIN=1. The new branch has not run inside a real SGLang graph capture, its outputs have not been compared with SGLang's in the model, and the copies' cost has not been measured.Risk
Affects:
[email protected]serves (64 rows onmain; 1–256 rows with the companion PR's schemas).If wrong:
Undo:
[email protected]turns the BF16 op off for every checkpoint,main's FP8 fallback at 64 rows included; otherwisegit revert.🤖 Generated with Claude Code