vLLM/Recipes
Search
Qwen

Qwen/Qwen3.8-Flash-Next

Qwen4 architecture preview with a 125B-parameter main model, supplemented by an additional 51B N-gram embeddings, with 6B parameters activated per token.

Qwen4 architecture preview with 6B active parameters and efficient 262K context

moe176B / 6B262,144 ctxvLLM 0.30.0+Multimodal
Default configuration: 8× B200 · Tensor + Expert Parallel · NVFP4
export VLLM_USE_RUST_FRONTEND=1
vllm serve Inferact/Qwen3.8-Flash-Next-NVFP4 \
  --max-num-seqs 256 \
  --enable-prefix-caching \
  --enable-expert-parallel \
  --tensor-parallel-size 8 \
  --kv-cache-dtype fp8 \
  --attention-config.indexer_kv_dtype fp8 \
  --enable-auto-tool-choice \
  --tool-call-parser qwen3_coder \
  --reasoning-parser qwen3 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3}'

The interactive builder loads with JavaScript. Append .md to this page's URL, query string included, for any configuration's command as Markdown — e.g. /Qwen/Qwen3.8-Flash-Next.md.

Overview

Qwen3.8-Flash-Next is a multimodal, ultra-sparse Mixture-of-Experts model. It has 125B parameters, including an additional 51B N-gram embedding table, while activating 6B parameters per token.

The architecture combines four main ideas:

  • GDN + QSA: three of every four layers use Gated DeltaNet to compress history; the fourth uses Qwen Sparse Attention for precise long-range retrieval.
  • Gated Residual: four residual branches dynamically control cross-layer reads and writes.
  • N-gram Embedding: a 51B lookup memory adds capacity with little per-token compute and can be asynchronously offloaded to host memory. (note that offload currently only runs on Nvidia devices)
  • MTP: the built-in Multi-Token Prediction module supports speculative decoding.

The checkpoint natively supports 262,144 tokens. Qwen reports that QSA reaches up to 10.2x prefill and 6.6x decode attention-kernel speedups at one million tokens. On GB300, TEP4 is the recommended full-tray configuration. On an 8x H200 node, use TEP8 for the official FP8 checkpoint; plain TP8 is incompatible with its 128-wide quantization blocks.

Prerequisites

  • Runtime: vLLM 0.30.0 or newer runs the model. This recipe was tuned and verified on nightly builds that have since shipped, so use the latest release (vllm/vllm-openai:latest on NVIDIA, vllm/vllm-openai-rocm:latest on AMD).
  • Hardware: NVIDIA CUDA and AMD ROCm instructions are provided below.
  • FP8 memory: the checkpoint is 172.78 GiB; it fits on a single GB300 GPU (288 GB HBM3e).
  • BF16 memory: the checkpoint is 335.28 GiB. The validated TP2 configuration used about 190 GiB per GB300 GPU.
  • MXFP4 memory: the AMD Quark MXFP4 checkpoint is 169.8 GiB; it fits on a single MI355X GPU (288 GB HBM3E).
  • Host memory for N-gram Embedding offload: at least 51 GB plus runtime headroom.

The Install block above generates the pip and Docker launch flows.

Serving

Use the official Qwen/Qwen3.8-Flash-Next-FP8 checkpoint tested by this recipe.

vllm serve Qwen/Qwen3.8-Flash-Next-FP8 \
  --tensor-parallel-size 4 \
  --enable-expert-parallel \
  --max-num-seqs 256 \
  --enable-prefix-caching \
  --kv-cache-dtype fp8 \
  --attention-config.indexer_kv_dtype fp8 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3}' \
  --enable-auto-tool-choice \
  --tool-call-parser qwen3_coder \
  --reasoning-parser qwen3

TEP4 is the recommended full-tray configuration — we recommend it over plain TP4 because expert parallelism is consistently faster for this model. TP4 and TEP4 are both validated full-tray configurations, including with MTP3.

To serve BF16, use the Qwen/Qwen3.8-Flash-Next checkpoint with the same arguments.

Single-GPU deployment on GB200/GB300

The model fits on a single GPU: the FP8 checkpoint on one GB300 (288 GB HBM3e), and the NVFP4 variant on GB200 as well. Single-GPU TP1 suits evaluation and development; multi-GPU TEP remains the recommended deployment for serving throughput.

Use TEP8 with the Triton MoE backend on Hopper:

vllm serve Qwen/Qwen3.8-Flash-Next-FP8 \
  --tensor-parallel-size 8 \
  --enable-expert-parallel \
  --moe-backend triton \
  --max-num-seqs 256 \
  --enable-prefix-caching \
  --kv-cache-dtype fp8 \
  --attention-config.indexer_kv_dtype fp8 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3}' \
  --enable-auto-tool-choice \
  --tool-call-parser qwen3_coder \
  --reasoning-parser qwen3

Plain TP8 is incompatible with the FP8 checkpoint; use TEP8.

H100's 80GB/GPU is not enough headroom for the 51B N-gram/PLE embedding table — it relies on PLE CPU offload, which vLLM enables by default. Use TEP8 with the Triton MoE backend; as on other hardware, expert parallelism is faster than plain TP, and plain TP8 is incompatible with the FP8 checkpoint's 128-wide quantization blocks.

vllm serve Qwen/Qwen3.8-Flash-Next-FP8 \
  --tensor-parallel-size 8 \
  --enable-expert-parallel \
  --moe-backend triton \
  --max-num-seqs 256 \
  --enable-prefix-caching \
  --kv-cache-dtype fp8 \
  --attention-config.indexer_kv_dtype fp8 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3}' \
  --enable-auto-tool-choice \
  --tool-call-parser qwen3_coder \
  --reasoning-parser qwen3

Benchmark MTP with SPEED-Bench (--dataset-name speed_bench), not random.

MXFP4 on MI355X

On MI355X, the MXFP4 variant serves AMD's amd/Qwen3.8-Flash-Next-Quark-MXFP4 checkpoint, which quantizes the routed experts to MXFP4 with AMD Quark. The variant sets:

  • VLLM_ROCM_USE_AITER=1, which turns on the AITER kernels.
  • VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1, which fuses the shared expert into the routed-expert MoE kernel.
  • AITER_USE_FLYDSL_MOE_SORTING=1, which sorts MoE tokens with a FlyDSL kernel.
  • --gdn-prefill-backend aiter_flydsl, which runs Gated DeltaNet prefill with a FlyDSL kernel.

The default deployment is TEP8, and the TP strategy runs TP2. The checkpoint also fits on a single MI355X (288 GB HBM3E), so TP1 with the same flags serves one replica per GPU; the builder offers one TP size per variant, so set --tensor-parallel-size 1 yourself. TP2 leaves more memory for KV cache and gives slightly lower per-token latency; TP1 gives more throughput per GPU.

Validated on vllm/vllm-openai-rocm:nightly-83c078d955cd6e0c63d3b12abe669c8de936a370 with the builder's TEP8 and TP2 commands, and TP1 as the TP2 command with --tensor-parallel-size 1. GSM8K is 5-shot over 1,319 questions through chat completions with thinking off; throughput uses random 8k-token prompts and 1k-token outputs.

MXFP4 on MI355XGSM8KOutput tok/s, concurrency 8 / 32
TEP80.965665 / 1831
TP20.967801 / 1384
TP10.967751 / 1282

BF16 on MI325X

The BF16 variant sets VLLM_ROCM_USE_AITER=1 and VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1. With AITER on, Gated DeltaNet prefill uses the AITER FlyDSL kernel (requested=auto), and the shared expert runs inside the routed-expert MoE kernel.

FP8 configuration on a 4x MI355X GPU

export VLLM_ROCM_USE_AITER=1
export VLLM_ROCM_USE_AITER_MOE=0

vllm serve Qwen/Qwen3.8-Flash-Next-FP8 \
--tensor-parallel-size 4 \
--max-model-len auto

MTP is opt-in on MI355X; to turn it on, add the option from the MTP speculative decoding section below.

Full native context

The checkpoint advertises a native 262,144-token context, which vLLM uses when --max-model-len is omitted. Startup and bounded evaluation were validated with this limit configured, but a single 262K-token request was not tested.

MTP speculative decoding

Add the following option:

--speculative-config '{"method":"mtp","num_speculative_tokens":3}'

Offload the 51B N-gram embedding table

Builds containing N-gram Embedding offload can keep the N-gram lookup memory in host RAM and asynchronously prefetch the required rows. The initial implementation supports both ModelRunner V1 and V2. PLE CPU offload is required for DEP, and also required for TP/TEP on 80GB-class GPUs (H100) where the embedding table alone exceeds available headroom — optional only on GPUs with more VRAM per rank (H200 and above). vLLM enables it by default; set it explicitly with --engram-config '{"cpu_offload":true}'.

vllm serve Qwen/Qwen3.8-Flash-Next-FP8 \
  --tensor-parallel-size 4 \
  --enable-expert-parallel \
  --max-model-len 262144 \
  --enable-auto-tool-choice \
  --tool-call-parser qwen3_coder \
  --reasoning-parser qwen3

Extend to one million tokens with YaRN

The checkpoint is native at 262K. For a one-million-token workload, turn on the Long Context feature above: it applies the model card's YaRN RoPE configuration under text_config (where this checkpoint carries rope_parameters) and raises --max-model-len to 1,000,000. Evaluate shorter-context quality before making it the default — static YaRN holds the scaling factor constant regardless of input length.

Verifying

from openai import OpenAI

client = OpenAI(api_key="EMPTY", base_url="http://localhost:8000/v1")
response = client.chat.completions.create(
    model="Qwen/Qwen3.8-Flash-Next-FP8",
    messages=[{
        "role": "user",
        "content": "Explain how Gated DeltaNet and Qwen Sparse Attention complement each other.",
    }],
    max_tokens=8196,
)
print(response.choices[0].message.content)

A correct response should explain that GDN maintains a compact recurrent summary, while QSA selectively retrieves important regions from the full token history.

Troubleshooting

  • FP8 on eight GPUs: use TEP8; plain TP8 is incompatible with this checkpoint. TP4 is also supported if GPU memory capacity allows.
  • Mamba-cache capacity error at startup: keep --max-num-seqs 256.
  • Runtime OOM on large multimodal batches: lower --max-num-batched-tokens or --limit-mm-per-prompt. On CUDA and ROCm, vLLM sizes the KV cache from memory measured after warmup, so leave --gpu-memory-utilization unset unless the GPU is shared (details).
  • Out of memory while loading: enable N-gram Embedding CPU offload, increase TP size, or reduce --max-model-len to reserve less KV cache. On 4x H100 80GB, plain TP4 OOMs at engine startup without PLE CPU offload — keep the default --engram-config '{"cpu_offload":true}'.
  • XPU/TPU startup error: these platforms are not supported by the initial implementation.
  • Pipeline-parallel startup error: N-gram Embedding does not initially support pipeline parallelism; use single-node TP or TEP instead.
  • DEP startup failure: DEP requires PLE CPU offload (on by default); DEP without it is not supported.
  • MTP memory pressure: reduce num_speculative_tokens below 3.
  • PLE: a network layer that injects N-gram Embeddings into the main model.

KV cache offloading

Offloading is available upstream since vLLM v0.30.0 (vllm-project/vllm#57145). Validation used Qwen/Qwen3.8-Flash-Next-FP8 on 4×H200 (TP4), vLLM commit d1b4028d7e, the Python frontend, --enforce-eager, --max-model-len 16384, --max-num-seqs 16 and --max-num-batched-tokens 8192. Qwen validation used the FP8 variant with --limit-mm-per-prompt '{"image":0,"video":0}'. Validation used TieringOffloadingSpec: 8 GiB total CPU tier, blocks_per_chunk: 1, a persistent filesystem root_dir, eight read/write threads and PYTHONHASHSEED=0. Three CPU-tier reloads and three filesystem reloads after restarting the server passed. Reloaded responses matched the cold output, including the reasoning field. The five-shot GSM8K diagnostic scored 31/32; this is a small sample, not the full benchmark. These results cover this text-only configuration, not the builder's larger tier/chunk defaults or other variants.

References

Ascend deployment

Two-node 1P1D, verified end-to-end on two Atlas A2 servers (Atlas 800T A2 with 8 x Ascend 910B3, Atlas 800I A2 with 8 x Ascend 910B4-1; 64 GB HBM per NPU) with vLLM Ascend 0.32.0rc1 from quay.io/ascend/vllm-ascend:v0.32.0rc1. Prefill runs TP4 x PP2 x DP1 x EP4 in one vllm serve process; decode runs TP2 x DP4 x EP8 in vLLM's multi-port external load-balancer mode, where one vllm serve supervisor process on the decode node spawns four child API servers, one per DP rank, each owning 2 NPUs. KV moves over MooncakeConnectorV2 in p2p mode — no HBM/DRAM/SSD KV pool. MTP (3 speculative tokens) is on for both pools; engram keeps the 51B N-gram embedding table in host memory, which is what lets the checkpoint fit in 8 x 64 GB per node.

The weights are the ModelScope build Eco-Tech/Qwen3.8-Flash-Next-w4a8. VLLM_USE_MODELSCOPE=True with the repo id works, and so does a local copy — mount it into the container and pass the in-container path to vllm serve.

If you pull from ModelScope, mount its cache out of the container: -v ~/.cache/modelscope:/root/.cache/modelscope, or set MODELSCOPE_CACHE to a mounted path. The site's Docker command only mounts ~/.cache/huggingface, which ModelScope does not use — without this the ~181 GiB land in the container's writable layer and are downloaded again whenever the container is recreated.

--shm-size 128g is required — the Docker command on this page already sets it, and any hand-written docker run must pass it too. The decode pool's Engram table (51B rows) lives in /dev/shm as two TP shards of 47.7 GiB each, 95.4 GiB in total, so at 64g the second shard already fails to register (vLLM error 107017). The prefill pool keeps its Engram copy in anonymous pinned host memory instead and does not consume /dev/shm. /etc/hccn.conf carries the per-NPU RoCE address/netmask the PD path uses, and the image ships no copy of its own. The site's Docker tab does not mount it — if you take that command, add -v /etc/hccn.conf:/etc/hccn.conf:ro.

If the router exits with RuntimeError: can't start new thread, check the host's seccomp profile. Docker Engine 20.10.10 added clone3 support to its default profile; upgrade older versions or update a custom profile to allow the required syscall while keeping seccomp enabled.

The generated commands carry the recipe's environment as -e flags. Only if you start vllm serve from a shell instead, prepare it first:

source /usr/local/Ascend/ascend-toolkit/set_env.sh
[ -f /usr/local/Ascend/nnal/atb/set_env.sh ] && source /usr/local/Ascend/nnal/atb/set_env.sh
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY all_proxy ALL_PROXY
unset CPLUS_INCLUDE_PATH CPATH C_INCLUDE_PATH
unset VLLM_PP_LAYER_PARTITION
cd /workspace          # static-kernel cache root is <cwd>/static_kernel_compile_outputs

vLLM-Ascend reads ASCEND_RT_VISIBLE_DEVICES only — change it (the recipe sets all eight devices) to run the engines on a subset; a generic CUDA_VISIBLE_DEVICES is ignored.

The recipe leaves the six communication variables below unset; vLLM and CANN infer them. If the pools start but the two sides never connect — requests hang and the logs show a cross-node handshake / connect timeout — set them explicitly on each node (as -e flags on the Docker command, or exports before vllm serve), pointing at that node's business interface and address:

  • VLLM_HOST_IP — the address this engine advertises to its peer over the KV handshake channel; the peer connects back to exactly this address.
  • HCCL_IF_IP — the address HCCL binds for inter-node collectives; it has to be an address of the NIC named below.
  • HCCL_SOCKET_IFNAME — the NIC HCCL opens its sockets on.
  • GLOO_SOCKET_IFNAME — the NIC PyTorch Gloo uses for host-side collectives.
  • TP_SOCKET_IFNAME — the NIC torch's own socket layer binds; the vLLM Ascend multi-node PD tutorial exports it on every node.
  • no_proxy / NO_PROXY — both node addresses, so the two engines' traffic to each other never goes through an HTTP proxy the host may set.

Unset, vLLM probes the default-route address and CANN picks a NIC by itself. On a multi-homed node the two choices are not unique and can disagree with the NIC the peer actually reaches — the mismatch then shows up as the handshake timeout above, not as a startup error. One node's values, to be replaced with that node's own:

export VLLM_HOST_IP=<this-node-ip> HCCL_IF_IP=<this-node-ip>
export HCCL_SOCKET_IFNAME=<business-nic>
export GLOO_SOCKET_IFNAME=<business-nic> TP_SOCKET_IFNAME=<business-nic>
export no_proxy=localhost,127.0.0.1,<prefill-ip>,<decode-ip>
export NO_PROXY=$no_proxy

Both engines run --max-model-len 141312; the model supports up to 262144 tokens.

Placeholders in the generated commands. The rendered commands carry four shell variables: the two node addresses, the DP RPC port and the router port. The page fills in the router port; the other three must be substituted before anything runs:

  • $PREFILL_NODE_1 — the prefill node. Set it to that node's address on the interface the decode node and the router can reach; it becomes the router's --prefiller-hosts.
  • $DECODE_NODE_1 — the decode node. Set it to that node's own IP. Three uses: the decode pool's --data-parallel-address, the DP coordination endpoint its supervisor binds, and the router's --decoder-hosts, repeated once per child API server. 127.0.0.1 happens to work here only because the whole decode pool is one node; it fails as soon as the pool spans two, and the node's IP is never wrong.
  • $DECODE_DP_RPC_PORT — the port of that DP coordination endpoint. Set it to any free TCP port on the decode node that no other pool or service binds (for example 13345).
  • $ROUTER_PORT — the port the frontend listens on. Set it to any free TCP port on the node that runs the router; the page fills in 30000.

Every other port in the generated commands (8001, 8002-8005, 55220, 56010) is already literal; the decode supervisor's aggregated /health stays on vLLM's default port 9256.

Prefill node. The generated command runs TP4 x PP2 x DP1 x EP4 in one vllm serve process, serves HTTP on :8001 and produces KV on :55220, with HCCL_BUFFSIZE=8192 and the NPU socket range 61400-61499.

Decode node. The generated command runs one vllm serve supervisor that starts four child API servers, one per local DP rank and 2 NPUs each — child HTTP :8002-:8005, DP coordination on $DECODE_DP_RPC_PORT, KV consumer :56010 — with HCCL_BUFFSIZE=512 and the NPU socket range 61500-61599. This is the only pool that captures graphs, so it is also the only one that compiles static kernels.

In multi-port external LB mode the four children listen on the decode pool's --port plus their local DP rank; the supervisor itself publishes aggregated /health on vLLM's default supervisor port 9256 — setting --data-parallel-supervisor-port moves only that port. Substitute $DECODE_NODE_1 and $DECODE_DP_RPC_PORT as described under Placeholders. Do not add --data-parallel-rank, --data-parallel-external-lb or --data-parallel-hybrid-lb: the supervisor assigns the rank per child and rejects those flags.

The generated commands carry the same kv_connector_extra_config; it advertises the pool shapes (prefill dp1/tp4/pp2, decode dp4/tp2), so keep it in sync with the tp/pp/dp flags on both sides if you change them.

Start decode first: its static-kernel compile makes it the slow node — about 60-70 minutes from a fresh container, against about 10-15 for prefill. A restart inside the same container can reuse part of the compile cache; a new container starts cold.

Put the Ascend Router in front, on either node, and send requests to its port.

The router needs one decode endpoint per child API server — four here, on 8002-8005 — because each child serves one DP rank; a single --decoder-ports 8002 leaves the other three ranks idle. Both endpoint lists are derived from the pools' --port, so if you change the decode --port, move the four decoder endpoints with it (port + rank 0..3). The Ascend Router takes no --intra-node-data-parallel-size; that flag exists only in the vllm-router frontend. The generated command carries $PREFILL_NODE_1 and $DECODE_NODE_1 (the last once per decode child); see Placeholders for the values.

curl -s http://127.0.0.1:30000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"qwen38-flash-next-a2-pd","messages":[{"role":"user","content":"Hello"}],"max_tokens":16}'

--reasoning-parser qwen3 matters: thinking mode is the default and the chat template seeds the assistant turn with <think>, so without the parser the reasoning block lands in message.content.

Single-host PD configurations

A3 uses devices 0–7 for Prefill and 8–15 for Decode with 128g of container shared memory. 950DT uses devices 0–3 for Prefill and 4–7 for Decode with 500g of container shared memory. Choose Tensor Parallel and the Single-host PD preset for your hardware. Under Point, select Prefill and then Decode for the same workload. Run the commands in separate terminals on that host. The table links directly to each pair. For the A3 image-and-text point, expand A3 image-and-text 10K launch scripts above the command to launch all four Decode ranks, start the proxy and send the image request.

The 950DT Basic PD presets use the tutorial's VLLM_VERSION=0.32.0 override with the v0.32.0rc1-a5 image. If you switch images, unset this override so vLLM Ascend detects the installed vLLM version.

For basic, image or long-context serving, prepare the hardware-specific container using the A3 Docker script or the 950DT Docker script in Section 4.1. Set LOCAL_SERVICE_IP and SERVICE_NIC to the service address and interface. In each role shell, initialize CANN/ATB, unset proxy variables and any inherited VLLM_PP_LAYER_PARTITION, and add Mooncake to the library path:

export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"

Run the two generated serve commands with their respective environments in separate shells inside that container. Start the proxy from the vLLM-Ascend repository root once both role endpoints respond at /v1/models.

Basic PDPrefill HTTPDecode HTTPProxy HTTP
A3255682556925570
950DT808880928087
# A3. For 950DT, set these ports to 8088, 8092 and 8087.
PREFILL_PORT=25568
DECODE_PORT=25569
PROXY_PORT=25570
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
    --host 0.0.0.0 --port "${PROXY_PORT}" \
    --prefiller-hosts "${LOCAL_SERVICE_IP}" --prefiller-ports "${PREFILL_PORT}" \
    --decoder-hosts "${LOCAL_SERVICE_IP}" --decoder-ports "${DECODE_PORT}"

Use the proxy ports in the linked procedure for each workload point. Both long-context roles use YaRN and a 1,010,000-token service limit.

MemCache three-tier pooling on A3 and 950DT

Use the model deployment tutorial for the complete pooling procedure, including the Prefill and Decode commands.

  1. Before starting the container, prepare the SSD or loop devices and mount them together with the MemCache configuration directory as shown in Section 4.3, Docker for three-tier PD pooling.
  2. In Section 5.5, PD separation with a MemCache three-tier KV cache pool, select your hardware. For a new pool, configure the MetaService and LocalService files and start MetaService. For an existing pool, use its endpoints and LocalService files and preserve its disk initialization settings.
  3. Confirm the MetaService and ConfigStore endpoints are reachable, then use the service environment and P/D launch commands in the same hardware tab.