SGLang-AMD-Mono is the monokernel library of the SGLang framework for AMD Instinct GPUs. A monokernel is a persistent kernel that runs most of a decoder layer, including its attention, its mixture-of-experts block and both tensor-parallel all-reduces, in one or two launches. This removes the launch gaps and collective latency that dominate small-batch decoding.
The library implements SGLang's monokernel interface (RFC #43949) and loads as an SGLang general plugin (the sglang.srt.plugins entry point), which registers each model's spec under the monokernel backend amd. With --enable-amd-monokernel (--monokernel-backend amd before sgl-project/sglang#45389), every decode and speculative-verify step that a spec serves runs on its kernels, and every other step runs SGLang's standard path.
Experimental:
--enable-amd-monokernelis an experimental SGLang feature. The kernels, the models and setups they cover, and the plugin interface may change.
| Model | GPU | Tensor parallel | Coverage |
|---|---|---|---|
| DeepSeek-V4.1-Flash | MI350X, MI355X (gfx950) | 2, 4 | All 40 layers in decode and DSpark verify steps of up to 48 rows, and the DSpark draft stages |
| DeepSeek-V4-Pro | MI355X (gfx950) | 8 | All 61 layers (one launch each) in decode steps of up to 8 rows, and DSpark verify steps of one request (5 to 8 tokens) |
| GLM-5.3-Flash | MI355X (gfx950) | 2, 4, 8 | All 45 layers (one launch each; layer 0 from the tokens, with the embedding) and the final norm, LM head and logits (one launch), in decode and MTP verify steps of up to 16 rows (4 at TP2), on an f32 or bf16 KDA state (--mamba-ssm-dtype bfloat16) |
| GLM-5.3 | MI355X (gfx950) | 4, 8 | All 75 MoE layers (one launch each), in decode and MTP verify steps of up to 8 rows |
| GLM-5.2 (MXFP4 experts) | MI355X (gfx950) | 4, 8 | As GLM-5.3; the routed experts in MXFP4, on MXFP8 activations |
| GLM-5.3 (MXFP4) | MI355X (gfx950) | 4, 8 | As GLM-5.3 |
| Kimi-K3 | MI350X, MI355X (gfx950) | 8 | Every MoE layer in decode and DSpark verify steps of up to 8 rows |
| Kimi-K3.1 | MI350X, MI355X (gfx950) | 8 | Kimi-K3's launches on every MoE layer in DSpark and DFLASH verify steps of one request (the MLA layers' projection front too, without DCP), and one launch a KDA layer in verify steps of 2 to 48 requests |
| MiniMax-M3 (MXFP4) | MI350X, MI355X (gfx950) | 4 | The 57 sparse MoE layers in decode and EAGLE3 verify steps of up to 16 rows |
| MiniMax-M3.1-Flash (NVFP4 experts) | MI350X (gfx950) | 4 | o_proj and the FFN of the 57 sparse layers, after SGLang's attention, in decode and DSpark verify steps of up to 16 rows |
| Qwen3.5-397B-A17B-FP8 | MI355X (gfx950) | 4, 8 (MTP verify: 4) | Decode steps of up to 8 rows, and EAGLE/MTP target-verify steps of up to 8 requests x 4 draft tokens: every layer's norms, FP8 quants and dense projections, and the 45 GDN layers' conv and gated delta (two launches a GDN layer in decode, three in verify). Attention, the MoE and the MTP draft run SGLang's kernels. See its README |
| Qwen3.8-2.4T-A95B (MXFP4 experts) | MI355X (gfx950) | 8 | All 92 layers in decode steps of up to 8 rows, and the layer tail (K2) of all 92 in NEXTN verify steps of up to 8 rows |
| Qwen3.8-Flash-Next (MXFP4) | MI355X (gfx950) | 1 | The whole model (48 layers in 13 launches) in NEXTN verify steps of up to 8 requests x 4 tokens; the MTP draft's draft extend (up to 8 x 4 rows) and draft decode steps (up to 8 x 1) are routed to its launch |
- One or two launches per layer, or several layers per launch. DeepSeek-V4.1-Flash runs two. K1 runs the attention's input mixing and projections and writes the KV cache. K2 runs the sparse attention, the output projections, the FFN mixing, the MoE and both all-reduces. On the indexer layers, K2i runs between them: it scores the FP4 index keys in one launch, and SGLang's top-k kernels select each row's top-k from its logits. GLM-5.3-Flash and GLM-5.3 run each covered layer as one launch; GLM-5.3-Flash also runs the final norm, the LM head and the logits all-gather as one tail launch. MiniMax-M3 runs one too: K1 (the input norm, the fused qkv and index projection, the q / k norms, RoPE, the KV and index-key writes and the index scores) runs in front of the block selection, the sparse attention, o_proj, the router, the MoE and both all-reduces, in one launch. MiniMax-M3.1-Flash keeps SGLang's attention and runs the rest of each sparse layer as one launch: o_proj, the attention all-reduce and residual add, the post-attention norm, the router, the shared and routed experts and the MoE all-reduce. DeepSeek-V4-Pro runs each layer as one launch, its KV compressors and the CSA lightning indexer (its compressor, scores and an exact top-k) included, over SGLang's unified KV, compressor states and FP4 index keys. Qwen3.8-2.4T runs two on its 69 Gated DeltaNet layers: K1 runs the input norm, the GDN projections, the conv and the gated delta rule with their state updates, and the gated norm. K2 runs out_proj (o_proj on the attention layers), the post-attention norm, the router, the experts and both all-reduces. Its 23 full-attention layers run SGLang's attention, then K2. Qwen3.8-Flash-Next runs on one GPU, so a launch holds whole layers: 3 Gated DeltaNet layers and a QSA layer each, 13 launches from the token embedding to the model-level hyper-connection mixer.
- Graph-safe routing. Each step is routed by its CUDA graph key alone, so every rank makes the same decision and a captured graph replays the decision made at capture. Monokernel API 1 does not route a draft model's own steps, so Qwen3.8-Flash-Next's MTP draft spec routes its draft extend and draft decode steps itself: a wrapper it puts in front of the draft's forward at build routes them on the same static step properties and checks the draft's attention backend; it can move to SGLang if a later API routes draft steps. SGLang's capture check does not see draft steps, so the spec logs each draft key at its first launch and refuses to capture a draft-shaped step it cannot run.
- Fail-stop synchronization. Every wait on another workgroup or GPU has a deadline. A failed wait stops the launch on every rank, so no token from a failed step is returned.
- In-place weights. The kernels read the weights SGLang loaded. The few weights that need another layout or precision (MiniMax-M3's attention projections run in FP8; MiniMax-M3.1-Flash's shared expert keeps the checkpoint's MXFP8 values; DeepSeek-V4-Pro's attention and shared-expert matrices, packed from the checkpoint into its tiles, about 6 GB a rank) are copied once at startup, and each copy is logged.
- Step glue in fewer launches (DeepSeek-V4.1-Flash). Around the kernels, the DSpark step's attention metadata, accept, draft-KV inject and draft head, and the prefill indexer's kernels, run in fewer launches (
deepseek_v41/glue). Each piece replaces an SGLang function only where its first call agrees with SGLang's output, and keeps SGLang's otherwise.SGLANG_AMD_MONO_DSV41_GLUE=0turns them all off;SGLANG_AMD_MONO_DSV41_{METADATA,ACCEPT,INJECT,PREFILL_JIT,FUSED_POST,MARKOV}=0one each. The FP8 draft head is off unlessSGLANG_AMD_MONO_DSV41_DRAFT_HEAD_FP8=1. The inject and Markov kernels are HIP C++ built at their first use (common/hip_ext.py), so the serving image needshipcc,ninjaand torch's headers; the build setsPYTORCH_ROCM_ARCHfor the process while it runs, and its library is cached underSGLANG_AMD_MONO_CACHE_DIR.
- SGLang with the monokernel interface (
sglang.kernels.plugin_kernels.amdandsglang.srt.kernel_plugins.amd;sglang.srt.monokernelsbefore sgl-project/sglang#45389) and its specs by model type (register(..., model_type=...)), which tell DeepSeek-V4-Pro and V4.1 apart under their shared architecture - ROCm with FlyDSL and AITER, as included in SGLang's ROCm images
- AMD Instinct MI350X or MI355X
- MiniMax-M3 also needs SGLang's page16 SHUFFLE K / V for AITER sparse attention (sgl-project/sglang#41998, on #41708). Until both merge,
--enable-amd-monokernelrefuses MiniMax-M3 and names them. - MiniMax-M3.1-Flash needs SGLang's MiniMax-M3.1-Flash support (sgl-project/sglang#45925) and its gfx950 path (#45936).
- GLM-5.3-Flash on a bf16 KDA state (
--mamba-ssm-dtype bfloat16): SGLang's gfx950 HIP prefill and row-streaming decode take a bf16 state with sgl-project/sglang#49036 (on #44659). Without them, SGLang's prefill and its decode steps the kernels do not cover run its Triton kernels. - Qwen3.8-2.4T runs the fused shared expert (
--enforce-shared-experts-fusion) in MXFP4 with sgl-project/sglang#41899, and the MXFP4 GDN projections of sgl-project/sglang#43839.
git clone https://github.com/sgl-project/sgl-amd-mono.git
cd sgl-amd-mono
pip install -e .SGLANG_USE_AITER=1 AITER_BF16_FP8_MOE_BOUND=0 python -m sglang.launch_server \
--model-path deepseek-ai/DeepSeek-V4.1-Flash \
--tp 4 \
--speculative-algorithm DSPARK \
--speculative-dspark-block-size 5 \
--fp8-gemm-backend aiter \
--enforce-shared-experts-fusion \
--enable-amd-monokernelOn gfx950 the decode graph capture fails in AITER's MoE without
AITER_BF16_FP8_MOE_BOUND=0. The flags are those of the serving tests
(test/e2e/deepseek_v41_server.py).
GLM-5.3, with MTP (its NextN layer drafts one chain; a verify step of 4 rows a request runs the kernels at batch sizes 1 and 2 at TP8):
SGLANG_USE_AITER=1 python -m sglang.launch_server \
--model-path zai-org/GLM-5.3 \
--tp 8 \
--dsa-prefill-backend tilelang \
--dsa-decode-backend tilelang \
--speculative-algorithm EAGLE \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--enable-amd-monokernelThe MXFP4 checkpoint amd/GLM-5.3-Quark-MXFP4-AttnFP8 serves with the same flags,
and so does amd/GLM-5.2-MXFP4 (MXFP4 routed experts, the rest bf16), whose bf16
matrices the kernels copy to FP8 once at startup (sgl_amd_mono/glm53/README.md).
MiniMax-M3, with an EAGLE3 draft:
SGLANG_USE_AITER=1 SGLANG_MINIMAX_M3_INDEX_TOPK_FREQ=1 python -m sglang.launch_server \
--model-path amd/MiniMax-M3-MXFP4 \
--tp 4 \
--quantization quark \
--attention-backend aiter \
--kv-cache-dtype fp8_e4m3 \
--page-size 128 \
--speculative-algorithm EAGLE3 \
--speculative-draft-model-path Inferact/MiniMax-M3-EAGLE3-GQA \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--enable-amd-monokernelKimi-K3 runs at TP8, where the win is on small decode and DSpark verify steps:
SGLANG_USE_AITER=1 SGLANG_AITER_K3_OPT=1 python -m sglang.launch_server \
--model-path moonshotai/Kimi-K3 --trust-remote-code \
--tp 8 \
--attention-backend aiter \
--speculative-algorithm DSPARK \
--speculative-dspark-block-size 7 \
--enable-amd-monokernelKimi-K3.1, with DFLASH (the launches read and write the ReplaySSM ring):
SGLANG_USE_AITER=1 SGLANG_AITER_K3_OPT=1 AITER_FLYDSL_FORCE=1 AITER_SITUV2_A8W4=1 \
python -m sglang.launch_server \
--model-path moonshotai/Kimi-K3.1 --trust-remote-code \
--tp 8 \
--kv-cache-dtype fp8_e4m3 \
--speculative-algorithm DFLASH \
--speculative-draft-model-path <its DFlash2 MLA draft> \
--speculative-num-draft-tokens 6 \
--speculative-draft-attention-backend triton \
--enable-linear-replayssm-spec \
--enable-amd-monokernelMiniMax-M3.1-Flash, with DSpark:
SGLANG_USE_AITER=1 python -m sglang.launch_server \
--model-path MiniMaxAI/MiniMax-M3.1-Flash \
--tp 4 \
--speculative-algorithm DSPARK \
--fp8-gemm-backend aiter \
--enable-amd-monokernelDeepSeek-V4-Pro, on SGLang's two-pool fp8 unified KV:
SGLANG_HACK_FLASHMLA_BACKEND=unified_kv_triton SGLANG_DSV4_UNIFIED_KV_FP8=1 \
AITER_BF16_FP8_MOE_BOUND=0 python -m sglang.launch_server \
--model-path deepseek-ai/DeepSeek-V4-Pro \
--tp 8 \
--attention-backend dsv4 \
--enable-deepseek-v4-fp4-indexer \
--page-size 256 \
--kv-cache-dtype fp8_e4m3 \
--disable-shared-experts-fusion \
--cuda-graph-max-bs-decode 8 \
--enable-amd-monokernelAITER_BF16_FP8_MOE_BOUND=0 makes SGLang's decode run the routed experts on
MXFP8 activations, as the kernels do.
Qwen3.8-2.4T-A95B:
SGLANG_USE_AITER=1 python -m sglang.launch_server \
--model-path amd/Qwen3.8-2.4T-A95B-Quark-MXFP4 \
--tp 8 \
--trust-remote-code \
--attention-backend aiter \
--kv-cache-dtype fp8_e4m3 \
--mamba-ssm-dtype bfloat16 \
--enable-amd-monokernelThe serving test uses more flags (test/e2e/qwen38_a95b_mxfp4_server.py).
For MoRI PD, enable monokernels only on the decode server
(--disaggregation-mode decode --disaggregation-transfer-backend mori): TP8 for
DeepSeek-V4-Pro, TP2 or TP4 for DeepSeek-V4.1-Flash. Leave the flag off on prefill;
both peers must use the same KV layout.
Qwen3.5-397B-A17B-FP8 (128x128 block FP8), with decode graphs at the kernels'
widths (the flags of test/e2e/qwen35_a17b_fp8_server.py):
SGLANG_USE_AITER=1 AITER_BF16_FP8_MOE_BOUND=0 python -m sglang.launch_server \
--model-path Qwen/Qwen3.5-397B-A17B-FP8 \
--tp 4 \
--attention-backend aiter \
--moe-runner-backend aiter \
--cuda-graph-config '{"decode":{"backend":"full","max_bs":8,"bs":[1,2,3,4,5,6,7,8]}}' \
--enable-amd-monokernelThe same model with MTP (EAGLE, 3 steps, top-k 1, 4 draft tokens), where the
monokernel serves the target-verify steps (the flags of
test/e2e/qwen35_a17b_fp8_mtp_server.py, which follow the InferenceX MI355X
FP8 MTP recipe):
SGLANG_USE_AITER=1 SGLANG_USE_AITER_UNIFIED_ATTN=1 AITER_BF16_FP8_MOE_BOUND=0 \
python -m sglang.launch_server \
--model-path Qwen/Qwen3.5-397B-A17B-FP8 \
--tp 4 \
--attention-backend aiter \
--enable-aiter-allreduce-fusion \
--page-size 16 \
--max-running-requests 8 \
--speculative-algorithm EAGLE \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--cuda-graph-config '{"decode":{"backend":"full","max_bs":8,"bs":[1,2,3,4,5,6,7,8]}}' \
--enable-amd-monokernelQwen3.8-Flash-Next, with its MTP head (one MI355X; the server flags of test/e2e/qwen38_flash_next_server.py, which also caps running requests at 16 to step past 8):
SGLANG_USE_AITER=1 SGLANG_USE_AITER_UNIFIED_ATTN=1 AITER_FLYDSL_FORCE=1 \
SGLANG_MAMBA_SSM_DTYPE=bfloat16 SGLANG_USE_AITER_FP8_PER_TOKEN=1 \
python -m sglang.launch_server \
--model-path amd/Qwen3.8-Flash-Next-Quark-MXFP4-AttnFP8-PLEFP8 \
--tp 1 \
--attention-backend triton \
--speculative-algorithm NEXTN \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--cuda-graph-max-bs-decode 8 \
--enable-amd-monokernelIf the model, GPU or configuration is not supported, the server refuses to start and lists every reason.
sgl-amd-mono/
├── sgl_amd_mono/
│ ├── common/ # HIP device runtime: guarded waits, epochs, peer memory
│ ├── deepseek_v4/
│ │ ├── spec.py # spec and forward
│ │ └── gfx950/ # the layer kernel, weight packing and launch runner
│ ├── deepseek_v41/
│ │ ├── spec.py # target model: spec and forward
│ │ ├── draft.py # DSpark draft model: spec and forward
│ │ ├── glue/ # SGLang's DSpark step and prefill glue in fewer launches
│ │ └── gfx950/ # kernels and launch runner
│ ├── glm53_flash/
│ │ ├── spec.py # spec and forward
│ │ ├── check.py # SGLANG_AMD_MONO_CHECK: each layer against SGLang's own
│ │ └── gfx950/ # kernels and launch runner
│ ├── glm53/
│ │ ├── README.md # the launches, the weights of both checkpoints and the tests
│ │ ├── spec.py # spec and forward
│ │ ├── check.py # SGLANG_AMD_MONO_CHECK: each layer against SGLang's own
│ │ └── gfx950/ # kernels and launch runner
│ ├── kimi_k3/
│ │ ├── spec.py # spec and forward
│ │ ├── check.py # SGLANG_AMD_MONO_CHECK: each layer against SGLang's own
│ │ └── gfx950/ # kernels and launch runner
│ ├── kimi_k31/
│ │ ├── spec.py # spec: Kimi-K3's launches up to 8 rows, the wide launch above
│ │ ├── wide.py # the wide verify steps' forward
│ │ └── gfx950/ # the wide layer launch
│ ├── minimax/
│ │ ├── spec.py # the MiniMax-M3 architecture's spec: selects M3 or M3.1
│ │ └── check.py # SGLANG_AMD_MONO_CHECK: each layer against SGLang's own
│ ├── minimax_m3/
│ │ ├── spec.py # spec and forward
│ │ ├── weights.py # the layer views the kernels read
│ │ └── gfx950/ # kernels and launch runner
│ ├── minimax_m31/
│ │ ├── spec.py # spec and forward
│ │ ├── ffn.py # the FFN launch (from vLLM)
│ │ ├── a16w4.py # routed experts' MXFP4 GEMV steps
│ │ ├── a16w8.py # the shared expert's MXFP8 GEMV steps
│ │ └── runner.py # launch runner
│ ├── qwen35_a17b/
│ │ ├── README.md # the decode and target-verify steps, stage by stage
│ │ ├── spec.py # family spec: block-FP8 now, MXFP4 when that path moves here
│ │ ├── config.py # shared checkpoint checks
│ │ ├── layout.py # model facts shared by every precision
│ │ └── fp8/
│ │ ├── spec.py # block-FP8 spec and forward, TP4 and TP8
│ │ ├── check.py # SGLANG_AMD_MONO_CHECK: each launch against SGLang's own layer
│ │ └── gfx950/ # kernels (verify.py: the MTP verify GDN chain) and the step barriers
│ ├── qwen38_a95b_mxfp4/ # Qwen3.8-2.4T-A95B-Quark-MXFP4
│ │ ├── README.md # the K1 and K2 launches, the files and the tests
│ │ ├── spec.py # spec and forward
│ │ ├── check.py # SGLANG_AMD_MONO_CHECK: each layer against SGLang's own
│ │ └── gfx950/ # kernels and launch runner
│ └── qwen38_flash_next/
│ ├── README.md # how the kernel works, stage by stage
│ ├── spec.py # target model: spec and forward
│ ├── draft.py # MTP draft: spec and forward
│ ├── check.py # SGLANG_AMD_MONO_CHECK: weights and each step against SGLang's own
│ └── gfx950/ # kernel, layer views and launch runner
└── test/
├── unit/ # CPU: the specs and the SGLang interface contract
├── kernels/ # GPU: each launch against SGLang's reference ops
└── e2e/ # GPU: serving accuracy and fault injection
pytest test/unit # CPU only
pytest test/kernels test/e2e -k "not glm53 and not minimax_m3 and not qwen38 and not qwen35_a17b_fp8" # 4 x MI350X or MI355X, DEEPSEEK_V41_FLASH_MODEL_PATH set
pytest test/kernels -k "deepseek_v4 and not deepseek_v41" # one MI355X: every DeepSeek-V4-Pro launch compiles
pytest test/kernels test/e2e -k glm53_flash # GLM_53_FLASH_MODEL_PATH set: kernels on 8 GPUs, server at TP4
pytest test/e2e -k "glm53 and not glm53_flash" # GLM_53_MODEL_PATH set: server at TP8
pytest test/kernels test/e2e -k "minimax_m3 and not minimax_m31" # 4 x MI350X or MI355X, MINIMAX_M3_MODEL_PATH and MINIMAX_M3_EAGLE3_PATH set
pytest test/kernels test/e2e -k minimax_m31 # 4 x MI350X, MINIMAX_M31_FLASH_MODEL_PATH set
pytest test/kernels -k qwen35_a17b_fp8 # 1 x MI355X, no model needed: the verify GEMV and GDN chain
pytest test/e2e -k qwen35_a17b_fp8 # MI355X, QWEN35_FP8_MODEL_PATH set; QWEN35_FP8_TP=4 (default) or 8 for decode, MTP at TP4
pytest test/kernels test/e2e -k qwen38_a95b_mxfp4 # 8 x MI355X, QWEN38_A95B_MXFP4_MODEL_PATH set: K1 on 1 GPU, K2 on 8, server at TP8
pytest test/kernels test/e2e -k qwen38_flash_next # 1 x MI355X, QWEN38_FLASH_NEXT_MODEL_PATH set (the kernel test needs no checkpoint)
pytest test/kernels test/e2e -k "kimi_k3 and not quark" # 8 x MI350X or MI355X, KIMI_K3_MODEL_PATH and KIMI_K3_DSPARK_MODEL_PATH set
pytest test/e2e -k kimi_k3_quark # 8 x MI355X, KIMI_K3_QUARK_MODEL_PATH and KIMI_K3_DSPARK_MODEL_PATH set; needs sgl-project/sglang#44362 for K1Kernel-only time of a DeepSeek-V4.1-Flash layer: torchrun --nproc-per-node 4 test/kernels/deepseek_v41/time_layer.py --widths 6,12.
Kernel-only time of the GLM-5.3-Flash launches (no model needed): torchrun --nproc-per-node 4 test/kernels/glm53_flash/time_layers.py --kind model --rows 2,4,8 (--kind full for the whole served step: layer 0 from the tokens, the dense layers, layers 3 to 44 and the tail).
Format code with pre-commit (pre-commit install). Every module that reads SGLang internals declares them in SGLANG_READS. test/unit/test_contract.py checks each declared name against the installed SGLang, so an incompatible SGLang change fails on CPU.