Skip to content

Serve Qwen3 dense or Qwen3 30B-A3B ​

Use these recipes to serve unquantized Qwen3-0.6B on one Ascend NPU or Qwen3 30B-A3B with mixture-of-experts (MoE) and expert parallelism.

Model and hardware prerequisites ​

Qwen2, dense Qwen3, and Qwen3 MoE checkpoints use different architecture names. Choose the recipe that matches your checkpoint and hardware:

  • Qwen3-0.6B on Ascend NPU: Use one Ascend NPU and the prepared ARM64/Python 3.12 stack described in the NPU kernel setup. Load the CANN environment, allocate one NPU to the process, and pre-stage the checkpoint before starting. The task does not download the model.
  • Qwen3 30B-A3B: Use the Qwen/Qwen3-30B-A3B checkpoint and hardware supported by the flashinfer_cutlass MoE backend. The example uses tensor parallel size 2 and expert parallelism. The checkpoint's Hugging Face configuration advertises the model type qwen3_moe and the architecture Qwen3MoeForCausalLM, so launch it as an MoE model.

Serve Qwen3-0.6B on Ascend NPU ​

The NPU model CI task runs unquantized Qwen3-0.6B on one NPU with BF16 weights, paged MHA, eager prefill and decode, and greedy sampling. To reproduce this serving configuration, follow these steps:

  1. From the repository root, install the runtime and its pinned dependencies:

    bash
    bash test/ci_system/install_deps_npu.sh

    The source installer builds the native engine and installs the runtime's pinned dependencies, including SMG, while preserving the image's accelerator packages.

  2. Set the runtime environment for the NPU process:

    bash
    export PYTHONPATH="$PWD/python:$PWD/tokenspeed-kernel/python:$PWD/tokenspeed-kernel-npu/python:$PWD/tokenspeed-scheduler/python${PYTHONPATH:+:$PYTHONPATH}"
    export TORCH_DEVICE_BACKEND_AUTOLOAD=1
    export PYTORCH_NPU_ALLOC_CONF=expandable_segments:False
    export TORCH_HCCL_ZERO_COPY=0
    export TASK_QUEUE_ENABLE=1
    export ASCEND_LAUNCH_BLOCKING=0
  3. Set MODEL_PATH to the pre-staged Qwen3-0.6B checkpoint and verify that its configuration is readable. CI mounts /data/weights/Qwen3-0.6B read-only; replace this path with your local checkpoint path outside CI:

    bash
    # CI mounts this checkpoint read-only; use your local checkpoint path otherwise.
    MODEL_PATH=/data/weights/Qwen3-0.6B
    test -r "$MODEL_PATH/config.json"
  4. Start the server with paged MHA, eager execution, and greedy sampling:

    bash
    python3 -m tokenspeed.cli serve \
      --model "$MODEL_PATH" \
      --served-model-name Qwen3-0.6B \
      --device npu --tensor-parallel-size 1 --dtype bfloat16 \
      --attention-backend mha --sampling-backend greedy \
      --disable-prefill-graph --enforce-eager --disable-pdl \
      --max-model-len 4096 --max-num-seqs 4 --max-total-tokens 16384 \
      --host 127.0.0.1 --port 8000

    The standard mha backend selects registered Ascend kernels. --enforce-eager disables decode ACL Graphs in this CI configuration; it is intentional. ACL Graph capture is a separate mode with its own capture-size and capacity validation, and this task does not exercise it.

  5. After /readiness succeeds, verify the chat endpoint with the served model name. Because --sampling-backend greedy performs argmax, use temperature=0; request-level top_p and top_k do not turn it into stochastic sampling:

    bash
    curl http://127.0.0.1:8000/v1/chat/completions \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "Qwen3-0.6B",
        "messages": [{"role": "user", "content": "What is 2 + 2?"}],
        "temperature": 0,
        "max_tokens": 64,
        "chat_template_kwargs": {"enable_thinking": false}
      }'

    A successful request returns a chat completion for Qwen3-0.6B, confirming that the server is ready and the served model name matches the request.

CI evaluation scope ​

The separate GSM8K task uses the same server configuration and evaluates the first 100 examples with four concurrent requests, thinking disabled, and a 1,024-token generation limit. Its 0.60 accuracy floor is a bounded regression check, not a full benchmark claim. For triggers, installation behavior, and reports, see NPU CI.

Multi-NPU and ACL Graph configurations need their own validation; the single-NPU eager task does not establish their coverage.

Serve Qwen3 30B-A3B with expert parallelism ​

  1. Start Qwen3 30B-A3B as an MoE model with tensor parallel size 2, expert parallelism, the flashinfer_cutlass MoE backend, and the qwen3 reasoning parser. The command serves the model as qwen3-30b-a3b on port 8000; no placeholder values need replacement:

    bash
    tokenspeed serve Qwen/Qwen3-30B-A3B \
      --served-model-name qwen3-30b-a3b \
      --tensor-parallel-size 2 \
      --enable-expert-parallel \
      --moe-backend flashinfer_cutlass \
      --max-model-len 40960 \
      --reasoning-parser qwen3 \
      --host 0.0.0.0 \
      --port 8000
  2. After /readiness succeeds, verify the chat endpoint with the served model name:

    bash
    curl --fail http://127.0.0.1:8000/v1/chat/completions \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "qwen3-30b-a3b",
        "messages": [{"role": "user", "content": "What is 2 + 2?"}],
        "max_tokens": 64,
        "chat_template_kwargs": {"enable_thinking": false}
      }'

    A successful request returns a chat completion for qwen3-30b-a3b, confirming that the server is ready and the served model name matches the request.

TokenSpeed documentation