Who this is for
This guide is for developers who already call chat model APIs and want to run Qwen4-35B-A3B on their own machines or servers. By the end you should be able to send a request through an OpenAI-compatible endpoint, choose an inference engine, and set thinking effort and sampling parameters.
What Qwen4-35B-A3B is
Qwen4-35B-A3B is a causal language model with a vision encoder. It has 35B parameters in total, with 3B activated[1]. The model card also lists 20B n-gram embedding parameters and 2B MTP parameters[1]. The model is released under the Apache-2.0 license[1].
The native context length is 1,048,576 tokens[1]. The architecture combines linear attention with sparse attention across 40 layers[1]. Its mixture-of-experts layers contain 256 experts, and the model activates 8 routed experts and 1 shared expert[1].
The model card says this architecture makes long-sequence inference faster and sharply reduces the cache footprint. The n-gram embeddings improve model quality without extra compute or accelerator memory overhead[1].
Choosing an inference engine
The model repository is compatible with Hugging Face Transformers, vLLM, SGLang and TokenSpeed[1]. For production workloads or high-throughput scenarios, the model card recommends dedicated serving engines such as SGLang, vLLM and TokenSpeed[1]. It also recommends the latest framework versions for the best performance and compatibility[1].
Each engine has its own deployment guide. SGLang has a cookbook, and vLLM and TokenSpeed each have a recipe[1].
For local use, llama.cpp, ollama, unsloth, mlx-vlm and LiteRT-LM support the Qwen4 architecture[1].
Calling the model through an OpenAI-compatible API
The Chat Completions API is available in most inference frameworks. The hosted Qwen Cloud service also serves the model, under the name qwen4-35b-a3b[1].
Install the OpenAI Python library and set the endpoint and key. The example below uses a local server on port 8000[1]:
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL="http://localhost:8000/v1"
export OPENAI_API_KEY="EMPTY"Next, create the client and a user message[1]:
from openai import OpenAI
# Configured by environment variables
client = OpenAI()
# Text-only Input
messages = [
{"role": "user", "content": "Write a Python function to merge two sorted linked lists."},
]Then send a streaming request. The model name is Qwen/Qwen4-35B-A3B, and preserve_thinking is on by default[1]:
completion = client.chat.completions.create(
model="Qwen/Qwen4-35B-A3B",
messages=messages,
extra_body={
"chat_template_kwargs": {
"preserve_thinking": True, # on by default
"reasoning_effort": "high", # optional; supported levels: "xhigh", "high", "low", "off" (default: high)
},
},
stream=True,
stream_options={"include_usage": True},
)Setting thinking effort
reasoning_effort accepts xhigh, high, low and off, and the default is high[1]. enable_thinking=False is equivalent to reasoning_effort="off"[1]. Even when the effort is not off, the model may decide a task is simple enough to answer directly[1].
In multi-turn agentic tasks, lower effort does not always finish the task faster. Responses may be quicker turn by turn, but insufficient analysis, more failures and repeated retries can raise total latency and token use[1].
Setting sampling parameters
For thinking mode, the recommended settings are temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0 and repetition_penalty=1.0[1]. For non-thinking mode, use temperature=0.7, top_p=0.80, top_k=20, min_p=0.0, presence_penalty=1.5 and repetition_penalty=1.0[1]. Support for sampling parameters depends on the inference framework[1].
The model card suggests setting presence_penalty between 0 and 2 to reduce endless repetition. Higher values can cause language mixing and slightly lower performance[1].
Long outputs and video input
Within the 1M context length, the model card recommends a maximum reasoning output of 262,144 tokens and a maximum final response of 131,072 tokens[1].
Video frame sampling is supported only in vLLM. Launch vLLM with --media-io-kwargs '{"video": {"num_frames": -1}}', and then set sampling options such as fps through extra_body. The defaults are fps=2 and do_sample_frames=True[1]. Images and videos are passed with the image_url and video_url content types[1].
Common problems
- The tokenizer needs
trust_remote_code=True, and the reference implementation depends on tiktoken[1]. - If your stack relies on Jinja chat templates, use the one in
tokenizer-compat/. It produces the same formatted text, but the token IDs can differ from the reference implementation[1]. - Performance differences often come from framework versions and sampling settings. Update the framework first, then tune against the model card[1].
Next steps
For production, deploy with the framework guide you chose above, then point your client at your server address[1].
Adapted from the Qwen4-35B-A3B model card on Hugging Face[1], released under the Apache-2.0 License.
Sources
- 1Qwen4-35B-A3BHugging Face (Qwen)
Cite this page: Running Qwen4-35B-A3B locally with Transformers, vLLM and SGLang. TellWorld, https://www.tellworld.net/practice/practice-qwen4-35b-a3b-local. Updated 2026-12-04