Three small engine-side changes for SGLang 0.5.21 on a single RTX PRO 6000 Blackwell (SM120):
+22 % to +38 % output tokens/s in production traffic (1–15 concurrent requests), +34 % single-stream
at 45k context in a controlled bench, same quality, no extra memory (KV pool and max running
requests unchanged). Measured on 14 Oct 2026 with the ThinkingCap-Qwen3.8-27B-NVFP4A4-AWQ checkpoint
(compressed-tensors: NVFP4 W4A4 MLPs, FP8 per-channel attention/GDN projections and lm_head, bf16 MTP head),
MTP/EAGLE 3/1/4, FP8 KV cache, HiCache.
A torch-profiler trace of single-stream decode (≈30.7 ms per scheduler step, GPU 99 % busy) showed the step is dominated by weight-streaming GEMMs that run far below the card's ~1.79 TB/s at M = 1–16 tokens:
| Part of the step | Time | Effective bandwidth |
|---|---|---|
| FP8 per-token GEMMs (CUTLASS) | 10.6 ms | ~46–54 % |
| NVFP4 W4A4 GEMMs (FlashInfer CUTLASS) | 7.7 ms | ~50–70 % |
| Draft lm_head (full 248,320-row vocab, 3×/step) | 2.9 ms | ~74 % |
| Change | Effect | Files |
|---|---|---|
FR-Spec with a quantized lm_head. --speculative-token-map crashes (OOM) when the target lm_head is FP8: SGLang keeps the FP8 weight transposed [K, V], so head.data[hot] slices K instead of the vocab and the per-row scale is left full size. The patch builds a pruned copy that slices weight and scale along the vocab axis, same dtype/layout; it refuses (clear error) layouts it cannot slice per row. Draft lm_head: ~1.0 ms → ~0.18 ms per call, bit-identical logits on the kept rows. |
patches/frspec_fp8_lmhead.patch |
|
KDA NVFP4 SM120 GEMM for more shapes. SGLang already ships an SM120 NVFP4 kernel that reaches 85–89 % of bandwidth at small M (×1.27–1.71 vs the default), but only for an allowlist of shapes. The patch lets you add shapes via SGLANG_KDEV_KDA_NVFP4_KN="KxN,..." and SGLANG_KDEV_KDA_NVFP4_MAX_M. |
patches/kda_nvfp4_allowlist.patch |
|
Tuned triton_scaled_mm configs for FP8 per-token GEMMs on SM120. SGLang reads N=..,K=..,device_name=..,dtype=fp8_w8a8_channelwise.json; a 16×32×256 / 4 warps / 4 stages tile reaches ~87 % (×1.88 vs CUTLASS) at M ≤ 16. Entries are null from M = 24 up so prefill keeps CUTLASS. |
fp8_configs/*.json → <sglang>/kernels/ops/gemm/configs/ |
|
| Hot-token list for the draft (40,000 ids, multiple of 64; built only from public lists — HyperQwen + MiaAI-Lab es_en_code_65k — ranked by frequency on real Spanish/English agent traffic). The Qwen3.8 27B and Flash-Next tokenizers are byte-identical. | tokens/ |
|
| Tools: GEMM microbench in CUDA graphs with real shapes (writes the JSONs), FR-Spec equivalence test, trace summarizer. | tools/ |
| baseline | FR-Spec only | all three | |
|---|---|---|---|
| 1 req, 45k ctx | 98.5 tok/s | 102.0 | 131.7 (+34 %) |
| 4 req, 45k ctx | 45.9 | 49.7 | 52.1 (+13.5 %) |
| 8 req, 27k ctx | 38.7 | 38.9 | 40.0 (+3 %) |
| 1 req, 141k ctx | 93.9 | 104.7 | 116.6 (+24 %) |
Quality: reasoning 48/48 (3 runs × 16) for both baseline and patched, tool calls 24/24, needle 4/4; MTP accept length ~3.0 in both. One hour of real production traffic (gateway logs, responses ≥ 300 tokens, bucketed by context size): +15 % to +38 % tokens/s per call in every bucket, 0 server errors.
At 8+ concurrent requests the gain shrinks because attention over long contexts becomes the larger cost.
SG=$(python -c "import sglang,os;print(os.path.dirname(sglang.__file__))") # copy it first if you prefer
cd "$(dirname "$SG")" && patch -p0 < /path/to/patches/frspec_fp8_lmhead.patch && patch -p0 < /path/to/patches/kda_nvfp4_allowlist.patch
cp /path/to/fp8_configs/*.json "$SG/kernels/ops/gemm/configs/" # only valid for NVIDIA_RTX_PRO_6000_Blackwell_Workstation_Edition and these N,K
export SGLANG_KDEV_KDA_NVFP4_KN="5120x34816,17408x5120" SGLANG_KDEV_KDA_NVFP4_MAX_M=16 SGLANG_ENABLE_FP8_GEMM_CONFIG_TUNE=1
python -m sglang.launch_server ... --speculative-token-map /path/to/tokens/hot_tokens_qwen38_es_en_code_40000.ptCheck the server log for FR-Spec: draft lm_head pruned to 40000 rows, Using configuration from .../N=...json
and KDA NVFP4 SM120 path. For another GPU or checkpoint, regenerate configs with
tools/microbench.py --solo fp8 --m 1,4 (set FP8_CFG_INSTALL to auto-install winners) and validate KDA with --solo fp4.
- Tested only on SGLang 0.5.21, RTX PRO 6000 Workstation Edition (600 W), CUDA 13, this checkpoint. The JSONs are per (N, K, GPU name).
- The token list must be multiple of 16 (64 recommended) or the pruned FP8 lm_head falls back to an untuned kernel.
- Things that did not help here:
--linear-attn-prefill-backend flashinfer,--enable-torch-compile,--bf16-gemm-backend gemv(requires SM90),--fp8-gemm-backend(only affects block-wise FP8).
Apache-2.0. Contributions welcome via issues/PRs; the maintainers review every change.
Port. The FR-Spec (quantized lm_head) and KDA allowlist changes apply cleanly to SGLang 0.5.22
(patches/sglang-0.5.22/frspec_kda_sglang-0.5.22.patch, patch -p1 inside the copied sglang package;
the fp8_configs/*.json are unchanged). Note for 0.5.22 with hybrid (Gated DeltaNet) models + MTP: add
--enable-linear-replayssm-spec, otherwise the KV-cache sizing in kv_cache_configurator.py fails with
"Loaded weights leave no GPU memory for the KV cache".
MTP5 only pays off with FR-Spec. Same server (1× RTX PRO 6000 Workstation, power-capped at 450 W),
ThinkingCap-Qwen3.8-27B-NVFP4A4-AWQ, EAGLE/MTP top-k 1, measured on real agent text (multi-turn coding
sessions with ~73k-token prompts, 4 turns each), output tokens/s per request:
| Concurrent requests | MTP4 + FR-Spec | MTP5 + FR-Spec | Δ |
|---|---|---|---|
| 1 | 140 | 149 | +6 % |
| 2 | 103 | 117 | +13 % |
| 4 | 69 | 77 | +12 % |
With stock SGLang (no FR-Spec, full 248,320-row draft lm_head) MTP5 lost on the same real text:
1 request 96 vs 107 tok/s (−10 %), 10 requests 31 vs 34 (−9 %); real acceptance only rose from 2.90 to 3.02
tokens per step, not enough to pay for the extra draft step. The pruned 40k-row head makes that step cheap.
In production MTP5 + FR-Spec is now our default (--speculative-num-steps 5 --speculative-num-draft-tokens 6 --speculative-token-map <40k list>).
Lesson: decide draft settings on real text only. A synthetic bench (summarize long lists of random words) reported +42 % for MTP5 with a mean acceptance of 4.19; on real traffic acceptance was ~3.0 and the gain is the table above. Benchmark with outputs that look like your traffic (same languages, same mix of prose, tables, tool-call JSON and code, same lengths).
Regenerating the hot-token list with your own text (without publishing the text).
- Collect the model's outputs (not prompts) from recent weeks; keep the last week aside for evaluation only.
- Tokenize with the checkpoint's tokenizer and keep counts only; the text never leaves your server.
- Start from a generic base (e.g. HyperQwen ∪ MiaAI es_en_code_65k), rank by your own frequency plus a small bonus for base membership, always keep special/control tokens.
- Cut to a multiple of 64 (40,000 here) and save
torch.save(sorted(ids), "hot_token_map.pt"). - Measure coverage (% of generated tokens inside the list) on the held-out week. A good list saturates fast:
on our traffic the list in
tokens/already covers 99.97 % of six weeks of outputs, and rebuilding it with that text improved held-out coverage by only +0.001 pp — the misses are one-off code identifiers and names that no fixed list can predict. Beyond this point the next gain is training the draft (MTP) head on your traffic, not a bigger list. - Privacy: require each new token to appear in several sessions and users before it enters, and publish the recipe and the public base lists, not a list built from your users' traffic.