# Qwen/Qwen4-35B-A3B — vLLM serving recipe

> Qwen4 multimodal MoE (35B with 3B active, plus 20B N-gram embeddings and 2B MTP) with a native NVFP4 KV cache, built-in MTP and a 1M-token context window

Configuration: hardware `b300` (8× B300) · strategy `single_node_tp` (Tensor Parallel) · variant `default` (FP8) · features `tool_calling`, `reasoning`, `spec_decoding` · frontend `rust`

- Interactive page: https://recipes.vllm.ai/Qwen/Qwen4-35B-A3B
- This configuration as JSON: https://recipes.vllm.ai/Qwen/Qwen4-35B-A3B.json?hardware=b300

The commands below were rendered for exactly this configuration and take precedence over any example in the guide.

## Other configurations

Change the query string (the same parameters as the page URL) and fetch this URL again. Unknown or incompatible values fall back to the recipe default, so check the Configuration line.

- `hardware`: `h100`, `h200`, `b200`, `gb200`, `b300`, `gb300`, `rtx_pro_6000`, `mi350x`, `mi355x`
- `variant`: `default`, `bf16`
- `strategy`: `single_node_tp` (multi-node strategies also need `nodes=<n>`)
- `features`: comma-separated list of `tool_calling`, `reasoning`, `spec_decoding`, `text_only` (default: `tool_calling`, `reasoning`, `spec_decoding`). Use `features=none` to turn them all off.

## Install

Docker image: `vllm/vllm-openai:qwen4`

## Serve

```bash
export VLLM_USE_RUST_FRONTEND=1
vllm serve Qwen/Qwen4-35B-A3B-FP8 \
  --trust-remote-code \
  --enable-prefix-caching \
  --tensor-parallel-size 1 \
  --max-model-len auto \
  --disable-flashinfer-autotune \
  --kv-cache-dtype nvfp4 \
  --attention-config.indexer_kv_dtype fp8 \
  --enable-auto-tool-choice \
  --tool-call-parser qwen4 \
  --reasoning-parser qwen4 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3,"index_share_for_mtp_iteration":true}'
```

Docker equivalent:

```bash
docker run --gpus all \
  --privileged --ipc=host -p 8000:8000 \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  -e VLLM_USE_RUST_FRONTEND=1 \
  vllm/vllm-openai:qwen4 Qwen/Qwen4-35B-A3B-FP8 \
  --trust-remote-code \
  --enable-prefix-caching \
  --tensor-parallel-size 1 \
  --max-model-len auto \
  --disable-flashinfer-autotune \
  --kv-cache-dtype nvfp4 \
  --attention-config.indexer_kv_dtype fp8 \
  --enable-auto-tool-choice \
  --tool-call-parser qwen4 \
  --reasoning-parser qwen4 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3,"index_share_for_mtp_iteration":true}'
```

## Guide

> Background reference. Commands in it are examples and may target another configuration — use the Serve section above.

### Overview

[Qwen4-35B-A3B](https://huggingface.co/Qwen/Qwen4-35B-A3B) is a multimodal
Mixture-of-Experts model: 35B parameters with 3B activated, plus 20B N-gram
embeddings and a 2B MTP module, with a native 1,048,576-token context
window. Highlights from the model card:

- **Efficient architecture:** the Qwen4 architecture, introduced in
  [Qwen3.8-Flash-Next](../Qwen3.8-Flash-Next), interleaves Gated DeltaNet
  linear attention with Qwen Sparse Attention (3:1) for fast long-context
  inference and a small cache. N-gram embeddings add quality without extra
  compute or GPU memory.
- **Long-horizon agentic work:** stronger sustained, multi-step task
  delivery, and stronger coding for visual and creative deliverables.
- **Token efficiency:** more concise thinking at every effort level and
  fewer rounds per task.

### Native NVFP4 KV cache

The model is trained with quantization-aware training for a native NVFP4 KV
cache (`--kv-cache-dtype nvfp4`), about 3.6x smaller than BF16 K/V; the QSA
indexer cache uses FP8 (`--attention-config.indexer_kv_dtype fp8`).

### Prerequisites

- **Hardware:** one NVIDIA GPU, such as H200 or datacenter Blackwell (B200,
  B300, GB200, GB300), one AMD MI350X or MI355X, one Zhenwu M890 PPU, or two Zhenwu
  810E PPUs (TP2 with expert parallelism); H100 fits the FP8 checkpoint.
  GPU-resident weights take 39.7 GB (FP8) or 72.7 GB (BF16).
- **Host memory:** 20.5 GB (FP8) or 41 GB (BF16) for the N-gram table, which
  is offloaded to host RAM by default, plus runtime headroom.
- **vLLM:** the `vllm/vllm-openai:qwen4` Docker image on NVIDIA,
  `vllm/vllm-openai-rocm:qwen4` on AMD MI350X and MI355X, and the Zhenwu PPU image on
  M890 and 810E.

### Serving notes

- **Context length:** `--max-model-len auto` uses the full window when KV
  cache allows and otherwise lowers it to fit (logged at startup); pass an
  explicit `--max-model-len` to pin a limit.
- **Features:** tool calling and reasoning use the `qwen4` parsers on both
  the Rust and Python frontends; MTP drafts 3 tokens; enable **Text only**
  to skip the vision encoder for text-only workloads.
- **Startup speed:** on NVIDIA, `--disable-flashinfer-autotune` speeds up
  startup; remove it for the best prefill speed.
- **MI350X / MI355X:** both checkpoints serve the routed experts as MXFP4. The
  default command serves the BF16 checkpoint with `--quantization mxfp4`,
  which quantizes them at load; its `--quantization-config` keeps attention
  and the other linear layers in BF16. The FP8 command re-quantizes its
  block-FP8 experts (`--quantization-config '{"moe":"mxfp4"}'`) and keeps
  the other layers FP8 as shipped. AITER kernels are on
  (`VLLM_ROCM_USE_AITER=1`). MTP drafts with an FP8 `lm_head`
  (`draft_lm_head_quantization`). `--monokernel` runs decode steps of up to
  16 rows (4 requests with MTP) as persistent kernel launches, -22% per
  decode step at concurrency 1; larger steps and prefill take the standard
  path, so it stays on for every workload.
- **Zhenwu:** M890 (TP1) and 810E (TP2 with expert parallelism) serve the
  BF16 checkpoint on the Zhenwu PPU image.

### Client usage

- **Thinking:** set `reasoning_effort` to `xhigh`, `high` (default),
  `low`, or `none` to turn thinking off.
- **Sampling:** thinking mode uses `temperature=1.0`, `top_p=0.95`,
  `top_k=20` (the checkpoint default); with thinking off, use
  `temperature=0.7`, `top_p=0.8`, `top_k=20`, `presence_penalty=1.5`.

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
resp = client.chat.completions.create(
    model=client.models.list().data[0].id,
    messages=[{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {"url": "https://example.com/chart.png"}},
            {"type": "text", "text": "Summarize this chart."},
        ],
    }],
    reasoning_effort="high",  # xhigh / high / low; "none" (not "off") disables thinking
)
print(resp.choices[0].message.content)
```

### References

- [Qwen4-35B-A3B model card](https://huggingface.co/Qwen/Qwen4-35B-A3B)
- [Qwen4-35B-A3B-FP8](https://huggingface.co/Qwen/Qwen4-35B-A3B-FP8)
