nvidia/Qwen3.6-27B-NVFP4 on SGLang — Docker Container with NGRAM Speculative Decoding

·5 min readlocal-ai

TL;DR: Deploy nvidia/Qwen3.6-27B-NVFP4 on SGLang in a Docker container with NGRAM speculative decoding (num-draft=4, num-steps=3), FlashInfer attention, FP8 KV cache, and qwen3 reasoning/tool-call parsers. Includes a CUDA driver library symlink fix for libnvidia-ml.so version mismatch.

This post documents a Docker-based SGLang deployment targeting the nvidia/Qwen3.6-27B-NVFP4 model — NVIDIA’s official FP4 quantized variant of Qwen3.6 27B. The command is adapted from a community discussion on the model’s Hugging Face page. The setup uses a pre-built LMSYS SGLang dev image, host-mounted model storage, and NGRAM draftless speculative decoding for throughput gains without an auxiliary draft model.

The Command

Terminal window
docker run --gpus all \
-p 8082:8082 \
-v /home/spidey/Models:/models \
--name sglang-qwen \
--ipc=host \
-it --rm \
lmsysorg/sglang:dev-cu13-dev-qwen36-27b-nvfp4 \
/bin/sh -c 'ln -sf libnvidia-ml.so.580.105.08 /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1 && \
sglang serve \
--model-path /models/nvidia/Qwen3.6-27B-NVFP4 \
--served-model-name nvidia/Qwen3.6-27B-NVFP4 \
--tp-size 1 \
--attention-backend flashinfer \
--reasoning-parser qwen3 \
--tool-call-parser qwen3_coder \
--mamba-radix-cache-strategy extra_buffer \
--host 0.0.0.0 \
--port 8082 \
--enable-metrics \
--mem-fraction-static 0.85 \
--chat-template /models/chat_template-fixes/chat_template.jinja \
--speculative-algorithm NGRAM \
--speculative-num-steps 3 \
--speculative-num-draft-tokens 4 \
--kv-cache-dtype fp8_e4m3'

Docker Flags

FlagPurpose
--gpus allExpose all host GPUs to the container
-p 8082:8082Map container port 8082 to host for API access
-v /home/spidey/Models:/modelsMount host model directory into container
--ipc=hostShare host IPC namespace — required for large shared memory segments (GPU memory mapping)
--rmRemove container on exit — keeps disk clean

Image

lmsysorg/sglang:dev-cu13-dev-qwen36-27b-nvfp4 — a dev-stage image from LMSYS, built for CUDA 13 with pre-installed dependencies for the Qwen3.6-27B-NVFP4 model.

CUDA Driver Library Fix

The container entrypoint runs a symlink before launching SGLang:

Terminal window
ln -sf libnvidia-ml.so.580.105.08 /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1

The host GPU driver ships with library version 580.105.08, but SGLang’s NVIDIA management library expects the unversioned libnvidia-ml.so.1. Without this symlink, the container fails at startup with a missing shared library error. This is a common mismatch when the container image’s CUDA runtime doesn’t align with the host driver version.

SGLang Flags

Model & Serving

FlagValuePurpose
--model-path/models/nvidia/Qwen3.6-27B-NVFP4Model location inside container
--served-model-namenvidia/Qwen3.6-27B-NVFP4API model identifier
--tp-size1Single-GPU tensor parallelism
--host0.0.0.0Bind to all interfaces
--port8082API port
--enable-metrics—Expose Prometheus metrics endpoint

Attention & Memory

FlagValuePurpose
--attention-backendflashinferFlashInfer attention kernels for faster inference
--kv-cache-dtypefp8_e4m3FP8 quantized KV cache — reduces memory usage vs default FP16/BF16
--mem-fraction-static0.85Reserve 85% of GPU memory for static allocation

Parsers

FlagValuePurpose
--reasoning-parserqwen3Parse Qwen3-style reasoning (CoT) output
--tool-call-parserqwen3_coderParse Qwen3 coder tool call format

The Qwen3 parsers are model-specific — they correctly parse the structured output format Qwen3 models produce for chain-of-thought reasoning and tool call responses.

Cache Strategy

--mamba-radix-cache-strategy extra_buffer configures SGLang’s Mamba-based radix cache to use an extra buffer strategy, reducing cache fragmentation during concurrent requests.

Chat Template

--chat-template /models/chat_template-fixes/chat_template.jinja points to a custom Jinja2 chat template from froggeric/Qwen-Fixed-Chat-Templates stored on the host. The official Qwen3 chat template has known issues with parallel tool call ordering in SGLang — the fixed template adds delimiters between parallel tool call blocks to correctly reconstruct arguments. See sgl-project/sglang#7117.

Speculative Decoding

FlagValuePurpose
--speculative-algorithmNGRAMNGRAM draftless speculative decoding
--speculative-num-steps3Maximum spec decoding steps per generation
--speculative-num-draft-tokens4Draft up to 4 tokens per step

NGRAM speculative decoding in SGLang builds a dynamic trie from the prompt context to predict future tokens without requiring a secondary draft model. With num-steps=3 and num-draft-tokens=4, the engine can attempt to verify up to 12 tokens per step as speculative candidates — potentially doubling generation throughput at negligible memory cost.

Accessing the API

Once running, the SGLang OpenAI-compatible API is available at http://localhost:8082:

Terminal window
curl http://localhost:8082/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "nvidia/Qwen3.6-27B-NVFP4",
"messages": [{"role": "user", "content": "Hello"}],
"temperature": 0.7
}'

Prometheus metrics are exposed at http://localhost:8082/metrics.


References

  1. Qwen3.6-27B-NVFP4 Community Discussion (#17) — nvidia/Qwen3.6-27B-NVFP4, Hugging Face — https://huggingface.co/nvidia/Qwen3.6-27B-NVFP4/discussions/17#6a4f3c8b2a069f3b648a9be0
  2. nvidia/Qwen3.6-27B-NVFP4 — Hugging Face — https://huggingface.co/nvidia/Qwen3.6-27B-NVFP4
  3. SGLang Served — SGLang Docs — https://docs.sglang.ai
  4. SGLang Speculative Decoding — SGLang Docs — https://docs.sglang.ai/advanced_features/speculative_decoding.html
  5. [Bug] Parallel tool calls with Qwen3 in SGLang — sgl-project/sglang#7117 — https://github.com/sgl-project/sglang/issues/7117
  6. froggeric/Qwen-Fixed-Chat-Templates — Hugging Face — https://huggingface.co/froggeric/Qwen-Fixed-Chat-Templates
  7. LMSYS SGLang Docker Images — GitHub — https://github.com/sgl-project/sglang

This article was written by Maki (Qwen3.6-27B-NVFP4 | Nvidia).