Serve Qwen4
Serve Qwen4-35B-A3B with FP8 or BF16 weights on NVIDIA, or with MXFP4 weights on AMD.
Prerequisites
- Complete the TokenSpeed environment setup and make the
tscommand available. - Make the
curlcommand available for the readiness checks. - Use a TokenSpeed build that supports Qwen4 mixture-of-experts (MoE) models. The NVIDIA commands also require NVFP4 key-value (KV) cache support.
- Use a checkpoint with QSA in both the target model and its multi-token prediction (MTP) head.
- Provide one of the following supported GPUs:
- One NVIDIA Blackwell or Hopper GPU for FP8 or BF16 weights.
- One AMD MI350X or MI355X (
gfx950) GPU for MXFP4 weights.
TokenSpeed enables Host KVStore by default.
Serve on NVIDIA
Serve FP8 weights
Use flashinfer_trtllm on Blackwell. On Hopper, replace --moe-backend flashinfer_trtllm with --moe-backend flashinfer_cutlass in the command. To use a local checkpoint, replace Qwen/Qwen4-35B-A3B-FP8 with the directory containing the FP8 checkpoint.
Start the server with the FP8 checkpoint:
bashts serve \ --model Qwen/Qwen4-35B-A3B-FP8 \ --trust-remote-code \ --tensor-parallel-size 1 \ --quantization fp8 \ --moe-backend flashinfer_trtllm \ --kv-cache-dtype nvfp4 \ --speculative-algorithm MTP \ --speculative-num-steps 3Confirm that the engine has registered with the gateway. If you changed the server's port, replace
8000with that port:bashcurl --fail http://127.0.0.1:8000/readinessThe request returns HTTP
200 OKwhen the server is ready.
Serve BF16 weights
To use a local checkpoint, replace Qwen/Qwen4-35B-A3B with the directory containing the BF16 checkpoint.
Start the server with the BF16 checkpoint:
bashts serve \ --model Qwen/Qwen4-35B-A3B \ --trust-remote-code \ --tensor-parallel-size 1 \ --moe-backend flashinfer_cutlass \ --kv-cache-dtype nvfp4 \ --speculative-algorithm MTP \ --speculative-num-steps 3Confirm that the engine has registered with the gateway. If you changed the server's port, replace
8000with that port:bashcurl --fail http://127.0.0.1:8000/readinessThe request returns HTTP
200 OKwhen the server is ready.
Serve on AMD
Prepare the checkpoint for an AMD MI350X or MI355X (
gfx950) GPU. Quantize the routed and shared experts to MXFP4 with AMD Quark, using the same quantization layout as the Qwen3.8 Flash Next AMD Quark MXFP4 checkpoint. Keep the rest of the checkpoint, including the MTP layer, in BF16.Start one replica on the GPU with
--tensor-parallel-size 1. Replace/path/to/Qwen4-35B-A3B-Quark-MXFP4with the directory containing the AMD Quark MXFP4 checkpoint:bashts serve \ --model /path/to/Qwen4-35B-A3B-Quark-MXFP4 \ --trust-remote-code \ --tensor-parallel-size 1 \ --quantization mxfp4 \ --max-num-seqs 16 \ --max-cudagraph-capture-size 16 \ --mamba-ssm-dtype bfloat16 \ --speculative-algorithm MTP \ --speculative-num-steps 3 \ --speculative-eagle-topk 1 \ --speculative-num-draft-tokens 4 \ --speculative-draft-lm-head-quantization fp8_weight_only \ --speculative-draft-moe-quantization mxfp4The draft quantization flags change only the draft steps: the FP8 LM head copy and MXFP4 draft experts. They don't change the target's verify.
Confirm that the engine has registered with the gateway. If you changed the server's port, replace
8000with that port:bashcurl --fail http://127.0.0.1:8000/readinessThe request returns HTTP
200 OKwhen the server is ready.