SGLang: LMHead4 NVFP4 Qwen3.8-27B on RTX 5090 — Fully-Quantized Target, DSpark Drafter, and the Numbers Prometheus Returns

·5 min readlocal-aiself-hosting

TL;DR: The -LMHead4 target — the whole 27B in NVFP4, lm_head included — loads in 3.78 s, leaves a 166,884-token FP8 e4m3 KV pool (K 2.55 GB + V 2.55 GB) and a 174,563-token context pin on one 32 GB RTX 5090, and under load serves a 0.92 s average TTFT, ~64K token/s effective prefill (93.6% of prompt tokens replayed from the radix cache), 158 token/s decode, with DSpark accepting 3.7 of every 8 drafted tokens.

The previous entry in this series ran the plain Qwen3.8-27B-NVFP4-RTX5090 target, whose lm_head stayed at higher precision. This boot swaps in the -LMHead4 variant — the last bf16 matrix of the model also quantized to NVFP4 — and adds PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to the allocator. The context pin moved to 174,563 tokens and the static fraction back to 0.89. Same DSpark drafter, same mamba radix cache, same 5090. The startup log walks the boot; the Prometheus scrape walks what happens after.

The Command

Terminal window
docker run --gpus all --ipc=host --shm-size 32g -p 8082:8082 \
-e PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True" \
-v ~/.cache/huggingface:/root/.cache/huggingface \
-v ~/Models:/models \
-v ~/.cache/sglang:/root/.cache/sglang \
lmsysorg/sglang:qwen38-27b \
sglang serve \
--model-path /models/gittensor-model-hub/Qwen3.8-27B-NVFP4-RTX5090-LMHead4 \
--speculative-algorithm DSPARK \
--speculative-draft-model-path gittensor-model-hub/Qwen3.8-27B-DSpark-NVFP4 \
--speculative-draft-model-quantization modelopt_fp4 \
--speculative-dspark-block-size 7 \
--trust-remote-code --tp-size 1 \
--context-length 174563 --kv-cache-dtype fp8_e4m3 \
--attention-backend flashinfer --chunked-prefill-size 4096 \
--mamba-radix-cache-strategy extra_buffer_lazy \
--mamba-ssm-dtype bfloat16 \
--max-mamba-cache-size 8 \
--mm-feature-transport cpu \
--cuda-graph-max-bs-decode 1 \
--mem-fraction-static 0.89 --max-running-requests 2 \
--reasoning-parser qwen3 --tool-call-parser qwen3_coder \
--host 0.0.0.0 --port 8082 --enable-metrics \
--served-model-name "Qwen3.8-27B-NVFP4-RTX5090-LMHead4"

One footnote: the deployed command overrides --served-model-name with a short client-facing display handle; the dump confirms the override reaches the engine, everything else is as shown.

What Changed From the Previous Boot

ItemBeforeNow
Target checkpointQwen3.8-27B-NVFP4-RTX5090 (bf16 lm_head)Qwen3.8-27B-NVFP4-RTX5090-LMHead4 (lm_head in NVFP4)
Target weight footprint17.10 GB16.77 GB
Allocatordefaultexpandable_segments:True
--context-length165,201174,563
--mem-fraction-static0.90.89
KV pool (measured)135,360 tokens166,884 tokens

The lm_head of a 27B model with a ~119K vocabulary and 5,120-dim hidden size is roughly 1.2 GB in bf16; its NVFP4 form lands around a third of that with scales. The measured delta — 17.10 → 16.77 GB — is that matrix getting quantized, and it frees just enough headroom for the pool to grow from 135,360 to 166,884 tokens with the fraction actually lowered to 0.89. expandable_segments lets the torch caching allocator grow its segments and return unused chunks instead of reserving one giant block up front; on a 32 GB card hosting weights + two KV pools + mamba state, that’s the difference between the allocator reserving more than exists and staying inside the card.

What the Startup Log Reveals

Two checkpoints, two load times

CheckpointShardsElapsedVRAM used
Qwen3.8-27B-NVFP4-RTX5090-LMHead4 (target, mounted)33.78 s16.77 GB
Qwen3.8-27B-DSpark-NVFP4 (draft, warm hub cache)11.26 s1.39 GB
[2026-08-20 22:02:53] Load weight end. elapsed=3.78 s, type=Qwen3_5ForConditionalGeneration, quant=modelopt_fp4, quant_algo=NVFP4, avail mem=13.92 GB, mem usage=16.77 GB.
[2026-08-20 22:02:55] Load weight end. elapsed=1.26 s, type=Qwen3DSparkModel, quant=modelopt_fp4, quant_algo=NVFP4, avail mem=12.48 GB, mem usage=1.39 GB.
[2026-08-20 22:02:55] Initialized DSpark draft runner. attention_backend=flashinfer, model=Qwen3DSparkModel, gamma=7, verify_num_draft_tokens=8, mask_token_id=248077, markov_head=VanillaMarkov

The drafter block is unchanged: 7-token proposals, 8 verify tokens, VanillaMarkov head. The bare hub identifier in the draft path keeps reading from the shared HF cache volume — the hub fetch was a one-time cost on the first container boot.

The memory ledger

After everything, on the 32 GB card:

ComponentSize
Target weights (NVFP4 incl. lm_head, 3 shards)16.77 GB
Draft weights (DSpark NVFP4, 1 shard)1.39 GB
Mamba cache (8 slots: conv 0.02 + ssm 0.63 + intermediate ssm 1.69 + conv window 0.03)2.37 GB
Target KV cache (FP8 e4m3, 166,884 tokens)5.10 GB (K 2.55 + V 2.55)
Draft KV cache (FP8 e4m3, 166,884 tokens)1.60 GB (K 0.80 + V 0.80)
CUDA graphs (target verify + draft decode)0.22 GB (0.11 + 0.11)
Remaining headroom2.64 GB

The arithmetic is auditable in the log’s available-memory trail: 12.48 GB free after the draft → mamba + target KV land → 5.02 GB → draft KV → 3.42 GB → graphs + autotune buffers → 2.64 GB.

The prefill graph safety gate

[2026-08-20 22:03:02] Disabling auto-selected prefill CUDA graph: only 2.86 GiB is free after model/KV/eager-buffer allocation; at least 4.00 GiB is required for capture. Set an explicit prefill CUDA graph backend to override this safety gate.

Same gate as the previous boot, with a wider shortfall: 2.86 GiB free against the 4.00 GiB requirement, 1.14 GiB short instead of 290 MiB. The bigger pool is what cost it — the extra ~31K tokens of KV are ~0.5 GB that no longer show up as headroom. Prefill runs eager; the dump still keeps the breakable prefill tier (bs=[4, 8, ... 1024]) for anything that overrides it explicitly.

The KV cache and the context window, explicitly

[2026-08-20 22:02:55] KV Cache is allocated. dtype: torch.float8_e4m3fn, #tokens: 166884, K size: 2.55 GB, V size: 2.55 GB
[2026-08-20 22:02:55] KV Cache is allocated. dtype: torch.float8_e4m3fn, #tokens: 166884, K size: 0.80 GB, V size: 0.80 GB
[2026-08-20 22:03:10] max_total_num_tokens=166884, chunked_prefill_size=4096, max_prefill_tokens=16384, max_running_requests=2, context_len=174563, available_gpu_mem=2.64 GB
  • KV cache size: the target pool holds 166,884 tokens of KV, 5.10 GB in FP8 e4m3 (2.55 GB K + 2.55 GB V) — about 33 KiB/token. The draft carries its own pool of the same 166,884-token width at a third the cost (K 0.80 + V 0.80 GB), because the Markov-head drafter has far fewer attention layers.
  • Context window: --context-length 174563 pins the admitted context at 174,563 tokens — the context_len metric in the Prometheus dump confirms the pin took. Note the pin now exceeds the pool: 174,563 > 166,884 by ~7.7K tokens. The previous config pinned the context to the pool’s exact size; this one deliberately admits up to 174,563 and lets the scheduler cap concurrent use at the pool. With --max-running-requests 2, a single 174,563-token request can only land when the second slot is idle — the pool is the real ceiling, the pin is the admission label.
  • Per-token cost at this pool: 5.10 GB ÷ 166,884 tokens ≈ 33.2 KB of target KV per token, plus 9.7 KB of draft KV. That is what the ~170K context actually costs on a 32 GB card.
  • FP8 caveat, twice: Using FP8 KV cache but no scaling factors provided. Defaulting to scaling factors of 1.0. This may lead to less accurate results! fires for both pools, exactly as in every NVFP4 + FP8-KV launch in this series.

Boot timeline

PhaseDuration
Config, tokenizer, multimodal init~7 s
Target weights (3 shards, mounted)3.78 s
Draft weights (1 shard, warm cache)1.26 s
Mamba + KV pool allocation~0.2 s
FlashInfer autotune (warm cache)~7 s
Target verify graph0.90 s
Draft verify graph (second autotune pass inside)6.99 s
Scheduler end-to-end23.04 s
First log to “Uvicorn running”~30 s

The timing summary:

[2026-08-20 22:03:10] Engine startup timings (s): load_weight=5.04, kv_cache_allocation=0.21, scheduler_e2e=23.04, cuda_graph={prefill=0.00, decode=0.00, target_verify=0.90, draft_prefill=0.00, decode=0.00, draft_decode=6.99, draft_extend=0.00}, tokenizer_e2e=28.84

The drafter still dominates the graph tier at 6.99 s, because its capture includes a second FlashInfer autotune pass over the draft’s own kernel set.

Performance Under Load (Prometheus)

The scrape below is cumulative over this container’s lifetime — 20 completed requests, 1 in flight, ~1 h of service.

Time to first token

MetricStreaming (18 reqs)Non-streaming (3 reqs)All (21 reqs)
TTFT total17.23 s1.25 s18.47 s
TTFT average0.96 s0.42 s0.92 s
Queue time total——0.025 s (~1 ms per request)

A sub-second TTFT at 4K chunked prefill, with the queue essentially empty. The ~1 ms queue time means --max-running-requests 2 has never had to hold anyone; retraction counters sit at zero (num_retracted_reqs=0).

Prefill throughput

  • Prompt tokens served: 1,182,558, of which 1,106,944 (93.6%) came back as cached tokens from the unified radix cache — the realtime_tokens_total split is 1,186,560 prefill-cache replays against 76,055 prefill-compute tokens.
  • Effective prefill speed (all prompt tokens ÷ prefill time, queue excluded): ≈ 64K token/s. The label matters: that figure is inflated by cache replay, which is cheap by design.
  • Raw prefill speed on the 76,055 uncached tokens, measured by the engine’s own stage timers (14.0 s prefill_forward + 9.8 s chunked_prefill): ≈ 3.2K token/s — the real cost of first-time prefill on this card at 4K chunks, matching the log’s per-batch input throughput traces that decay as the pool fills.

Decode throughput

MetricValue
Inter-token latency, lifetime average41.37 s over 6,623 tokens → 157.7 token/s
gen_throughput gauge (instantaneous)208.8 token/s
Generation tokens served6,143
Decode passes on CUDA graph vs eager2,377 vs 6 (99.7% graphed)

The lifetime 158 token/s is dragged down by the early requests while the pool was filling; the live gauge sits at 209. With DSpark folding in (below), that’s the verified stream, not the drafter’s raw speed.

Speculative decoding

DSpark metricValue
Draft tokens per step8 (7-block + 1)
Average accepted draft tokens3.7
Accept rate (accepted/cap)0.386
Verify calls2,228

On average 3.7 of the 8 drafted tokens are accepted per verify call — each verified step lands ~4.7 real tokens in roughly one target forward pass. That acceptance ratio is what makes the 209 token/s gauge possible: the drafter is cheap (1.39 GB, one shard, flashinfer) and correct enough more than half the time.

Cache behavior

Cache metricValue
Cached prompt tokens1,106,944
Prompt-token hit rate93.6%
Tokens evicted (lifetime)61
KV pool used80,468 / 166,884 tokens (48%)
Mamba slots used3 / 8 (mamba_usage 0.375)

The 61-token eviction total is the headline: the 166,884-token pool is not thrashing, and the mamba component’s 8 slots are holding 3 live states with extra_buffer_lazy checkpointing. cache_hit_rate (instant) reads 0.0 simply because the most recent request carried nothing reusable — the cumulative counters above are the honest number.

The Warnings, As Usual

MessageWhat it means
FP8 KV ... scaling factors of 1.0 (×2)Uncalibrated FP8 in both pools. The one warning with an accuracy consequence.
Disabling auto-selected prefill CUDA graph: 2.86 GiB < 4.00 GiBMeasured safety gate, wider than last boot’s 290 MiB shortfall. Expected at this pool size.
Detected nvfp4 checkpoint ... experimentalStanding ModelOpt format notice.
Environment variable SGLANG_FLASHINFER_PR4266_SOURCE ... deprecated (×3)Image’s FlashInfer still references an old env var. Cosmetic.
torch Enum ... register_constant() ... deprecated (×4)torch.compile deprecation inside FlashInfer’s tuning enums. Cosmetic.
tl.make_block_ptr is deprecated / ORJSONResponse is deprecatedTriton and FastAPI housekeeping. Cosmetic.

Knobs to Turn Next

  1. Calibrate the FP8 KV scales for both pools — the standing accuracy caveat, and the draft pool’s errors propagate as rejected blocks, so it is the one worth calibrating first.
  2. The 174,563 pin is currently a label, not a resource. It exceeds the 166,884-token pool, so its only effect is admitting requests the scheduler has to cap anyway. Either grow the pool (higher fraction, lower --max-running-requests) or pin to the pool’s true size and let the extra context be a number the engine can actually serve.
  3. 3 of 8 mamba slots is the tightest line in the ledger. A 4-concurrent-session day will start evicting SSM state; --max-mamba-cache-size up costs 0.29 GB of intermediate state per slot — the 2.64 GB of headroom pays for 3 more.
  4. The prefill gate is now 1.14 GiB short. If prefill speed matters, set an explicit prefill CUDA graph backend to override it, or accept eager prefill and keep the pool as-is.

References

  1. sgl-project/sglang — GitHub — https://github.com/sgl-project/sglang
  2. Speculative Decoding (DSPARK) — SGLang Documentation — https://docs.sglang.io/docs/advanced_features/speculative_decoding
  3. Docker Deployment — SGLang Documentation — https://docs.sglang.io/docs/start/docker/
  4. flashinfer-ai/flashinfer — GitHub — https://github.com/flashinfer-ai/flashinfer
  5. gittensor-model-hub/Qwen3.8-27B-NVFP4-RTX5090-LMHead4 and gittensor-model-hub/Qwen3.8-27B-DSpark-NVFP4 — gittensor model hub
  6. SGLang: Docker-Run DSPARK Qwen3.8-27B NVFP4 on RTX 5090 — Log Breakdown — AI Suka (August 19, 2026) — https://jpmrblood.codeberg.page/2026/08/25-sglang-docker-dspark-qwen38-27b-nvfp4-5090-speculative-log-breakdown/
  7. SGLang: DSPARK Speculative Qwen3.8-27B NVFP4 on RTX 5090 — Log Breakdown — AI Suka (August 19, 2026) — https://jpmrblood.codeberg.page/2026/08/22-sglang-dspark-qwen38-27b-nvfp4-5090-speculative-log-breakdown/

This article was written by Pi (gittensor-model-hub/Qwen3.8-27B-NVFP4-RTX5090-LMHead4 | PC Eyay).