Unsloth Dynamic v3.1 GGUFs achieve superior accuracy for local inference.
Since the release of Qwen3.8-Flash-Next, the community has embraced the Qwen4 architecture with remarkable creativity. Built for efficient inference, the Qwen4 architecture has already found its way into a wide range of new use cases through community-driven work, especially in local, self-hosted deployment.
Meanwhile, we've been pushing hard to unlock the full potential of this next-generation architecture, culminating in Qwen4-Max, the flagship of the Qwen4 series: an ultra-sparse model designed for long-horizon agentic applications, with cost-effectiveness optimized across the board.
Building on the same architecture and training techniques, the Qwen4 open model series is now on its way, making the latest advances in Qwen's frontier AI available to an ever-wider community.
Qwen4 features the following enhancement:
Efficient model architecture design: Built on a hybrid of linear attention and sparse attention, the Qwen4 architecture delivers outstanding efficiency in long-sequence scenarios — with faster inference and a drastically reduced cache footprint, enabling a native 1,000,000-token context window. Combined with n-gram embeddings, the architecture improves model quality without extra compute or accelerator memory overhead.
Significantly enhanced long-horizon agentic capabilities: Real-world productivity spans virtually every industry and profession. Throughout Qwen4's development, we went deep into the workflows of knowledge work, continually expanding the model's knowledge and capability boundaries, and achieved substantial progress in scenarios that demand sustained, long-term task delivery, with the goal of becoming a truly capable work assistant. Qwen4 also delivers stronger performance in coding for visual and creative deliverables, such as frontend development, 3D modeling, and game development with professional software & tools.
Improved token efficiency: Qwen4 substantially lowers the overall cost of task completion. Tasks require fewer interaction rounds, and within each round, thinking is markedly more concise across all effort levels, with the levels now clearly better separated. Paired with the architectural gains in inference efficiency, tasks complete faster and at lower cost.
For more details, please refer to our blog post Qwen4-35B-A3B.
[!Note] Benchmark results for Qwen4-35B-A3B are being finalized and will be updated in this section.
[!Tip] We recommend using the following sets of sampling parameters for generation:
- Thinking Mode:
temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=0.0,repetition_penalty=1.0- Non-thinking Mode:
temperature=0.7,top_p=0.80,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0Please note that the support for sampling parameters varies according to inference frameworks.
Qwen4 supports controlling thinking behavior via reasoning_effort and preserve_thinking. By default, Qwen4 operates in thinking mode reasoning_effort=high and preserve_thinking enabled.
The supported reasoning effort levels are:
xhigh: for complex tasks where quality matters mosthigh: for common tasks (default)low: for fast responses with minimal thinkingoff: disables thinking entirelyThe enable_thinking switch can still be used and enable_thinking=False is equivalent to reasoning_effort=off. Please also note that the model may judge a task simple enough to answer directly without thinking, even at non-off reasoning effort levels.
[!Tip] In multi-turn agentic tasks, lower reasoning effort does not always reduce overall task completion time. Although it may produce faster per-turn responses, it can also lead to insufficient analysis, more failures, and repeated retries, which may increase total latency and token consumption.
The Chat Completions API is available in most inference frameworks, as well as on Qwen Cloud. You can call the API directly from your application, or connect it to agentic tools such as Qoder CLI and Qwen Code.
Below we show an example of calling the API directly. For connecting agentic applications, please refer to the respective guides for each tool.
Before starting, make sure it is installed and the API key and the API base URL is configured, e.g.:
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL="http://localhost:8000/v1"
export OPENAI_API_KEY="EMPTY"
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."},
]
# Image Input
# messages = [
# {
# "role": "user",
# "content": [
# {
# "type": "image_url",
# "image_url": {
# "url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/CI_Demo/mathv-1327.jpg"
# }
# },
# {
# "type": "text",
# "text": "The centres of the four illustrated circles are in the corners of the square. The two big circles touch each other and also the two little circles. With which factor do you have to multiply the radii of the little circles to obtain the radius of the big circles?\nChoices:\n(A) $\\frac{2}{9}$\n(B) $\\sqrt{5}$\n(C) $0.8 \\cdot \\pi$\n(D) 2.5\n(E) $1+\\sqrt{2}$"
# }
# ]
# }
# ]
# Video Input
# messages = [
# {
# "role": "user",
# "content": [
# {
# "type": "video_url",
# "video_url": {
# "url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/video/N1cdUjctpG8.mp4"
# }
# },
# {
# "type": "text",
# "text": "How many porcelain jars were discovered in the niches located in the primary chamber of the tomb?"
# }
# ]
# }
# ]
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},
)
reasoning_content = ""
answer_content = ""
is_answering = False
print("\n" + "=" * 20 + "Reasoning" + "=" * 20 + "\n")
for chunk in completion:
if not chunk.choices:
print("\nUsage:")
print(chunk.usage)
continue
delta = chunk.choices[0].delta
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
if not is_answering:
print(delta.reasoning_content, end="", flush=True)
reasoning_content += delta.reasoning_content
elif hasattr(delta, "reasoning") and delta.reasoning is not None:
if not is_answering:
print(delta.reasoning, end="", flush=True)
reasoning_content += delta.reasoning
if hasattr(delta, "content") and delta.content:
if not is_answering:
print("\n" + "=" * 20 + "Answer" + "=" * 20 + "\n")
is_answering = True
print(delta.content, end="", flush=True)
answer_content += delta.content
messages.append({
"role": "assistant",
"content": answer_content,
"reasoning_content": reasoning_content,
})
To achieve optimal performance, we recommend the following settings:
Sampling Parameters: We suggest using the following sets of sampling parameters:
temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0, repetition_penalty=1.0temperature=0.7, top_p=0.80, top_k=20, min_p=0.0, presence_penalty=1.5, repetition_penalty=1.0 For supported frameworks, you can adjust the presence_penalty parameter between 0 and 2 to reduce endless repetition. However, using a higher value may occasionally result in language mixing and a slight decrease in model performance.
Adequate Output Length: To optimize performance on agentic tasks, we recommend allocating sufficient output length to allow the model to generate detailed and comprehensive responses. For frameworks that support separate token limits for internal reasoning and final outputs, we suggest the following configuration within the 1M context length:
These settings provide the necessary capacity for complex reasoning while ensuring ample space for high-quality final deliverables.
Long Video Understanding: To optimize inference efficiency for plain text and images, the size parameter in the released video_preprocessor_config.json is conservatively configured. It is recommended to set the longest_edge parameter in the video_preprocessor_config file to 469,762,048 (corresponding to 224k video tokens) to enable higher frame-rate sampling for hour-scale videos and thereby achieve superior performance. For example,
{"longest_edge": 469762048, "shortest_edge": 4096}
Alternatively, override the default values via engine startup parameters. For implementation details, refer to: vLLM / SGLang.
Video Frame Sampling: When vLLM is launched with --media-io-kwargs '{"video": {"num_frames": -1}}', video frame sampling can be configured via extra_body (e.g., by setting fps). This feature is currently supported only in vLLM. By default, fps=2 and do_sample_frames=True.
# With `do_sample_frames=True`, you can customize the `fps` value to set your desired video sampling rate.
chat_response = client.chat.completions.create(
model="Qwen/Qwen4-35B-A3B",
messages=messages,
extra_body={
"mm_processor_kwargs": {"fps": 2, "do_sample_frames": True},
},
)
At Alibaba, we embed model governance—guided by our six principles for AI development (human-centeredness, inclusivity and integrity, privacy protection, safety and reliability, trustworthiness and controllability, and open co-governance)—throughout the entire model lifecycle—from initial design and research through development, training, deployment, and real-world application—ensuring responsible AI is built in by design, not added on as an afterthought. For software engineering training tasks, we have added code security checks on top of functionality checks to strengthen the model’s intrinsic secure-coding capabilities. For cybersecurity, we filter data according to the specific purpose of each task, retaining data for defensive tasks such as vulnerability verification, detection, and remediation, while removing data for offensive tasks aimed at enhancing attack capabilities. For CBRN, we designed dedicated safety data and enhanced Qwen4's safety during the safety post-training stage.
Qwen is intended for lawful, constructive purposes and must not be used to cause harm. It cannot be used to exploit or endanger people, including children, or to promote violence, hate, discrimination, or abuse, or to develop or use CBRN weapons; nor may it be used to infringe privacy, carry out fraud or deception, spread disinformation, engage in cybersecurity abuse, or bypass security safeguards. Qwen is designed to assist people in their work, not to replace professional judgment in high-impact scenarios. Where decisions may carry serious consequences, human expertise and oversight remain essential. Users of Qwen must ensure that all input data is obtained and used lawfully, and that authorization has been obtained from the individuals concerned for any images or videos used. Users must not infringe individuals’ rights in their own images or videos or other personality rights, and must comply with applicable laws and regulations.
If you find our work helpful, feel free to give us a cite.
@misc{qwen4-35ba3b,
title = {{Qwen4-35B-A3B}},
author = {{Qwen Team}},
month = {November},
year = {2026},
url = {https://qwen.ai/blog?id=qwen4-35b-a3b}
}
UD-IQ1_S/Qwen4-35B-A3B-UD-IQ1_S-00002-of-00002.gguf 11 GiBUD-IQ1_S/Qwen4-35B-A3B-UD-IQ1_S-00001-of-00002.gguf 9.1 GiBUD-IQ1_M/Qwen4-35B-A3B-UD-IQ1_M-00002-of-00002.gguf 11 GiBUD-IQ1_M/Qwen4-35B-A3B-UD-IQ1_M-00001-of-00002.gguf 10 GiBUD-IQ2_XXS/Qwen4-35B-A3B-UD-IQ2_XXS-00001-of-00002.gguf 11 GiBUD-IQ2_XXS/Qwen4-35B-A3B-UD-IQ2_XXS-00002-of-00002.gguf 11 GiBUD-IQ2_XS/Qwen4-35B-A3B-UD-IQ2_XS-00001-of-00002.gguf 12 GiBUD-IQ2_XS/Qwen4-35B-A3B-UD-IQ2_XS-00002-of-00002.gguf 11 GiBUD-IQ2_S/Qwen4-35B-A3B-UD-IQ2_S-00001-of-00002.gguf 13 GiBUD-IQ2_S/Qwen4-35B-A3B-UD-IQ2_S-00002-of-00002.gguf 11 GiBUD-IQ3_XXS/Qwen4-35B-A3B-UD-IQ3_XXS-00001-of-00002.gguf 16 GiBUD-IQ3_XXS/Qwen4-35B-A3B-UD-IQ3_XXS-00002-of-00002.gguf 11 GiBUD-IQ3_S/Qwen4-35B-A3B-UD-IQ3_S-00001-of-00002.gguf 17 GiBUD-IQ3_S/Qwen4-35B-A3B-UD-IQ3_S-00002-of-00002.gguf 11 GiBUD-Q3_K_XL/Qwen4-35B-A3B-UD-Q3_K_XL-00001-of-00002.gguf 18 GiBUD-IQ4_XS/Qwen4-35B-A3B-UD-IQ4_XS-00001-of-00002.gguf 19 GiBUD-IQ4_XS/Qwen4-35B-A3B-UD-IQ4_XS-00002-of-00002.gguf 11 GiBUD-IQ4_NL/Qwen4-35B-A3B-UD-IQ4_NL-00001-of-00002.gguf 20 GiBUD-IQ4_NL/Qwen4-35B-A3B-UD-IQ4_NL-00002-of-00002.gguf 11 GiBUD-Q4_K_S/Qwen4-35B-A3B-UD-Q4_K_S-00001-of-00002.gguf 21 GiBUD-Q5_K_S/Qwen4-35B-A3B-UD-Q5_K_S-00001-of-00002.gguf 24 GiBUD-Q5_K_S/Qwen4-35B-A3B-UD-Q5_K_S-00002-of-00002.gguf 14 GiBUD-Q5_K_M/Qwen4-35B-A3B-UD-Q5_K_M-00001-of-00002.gguf 25 GiBUD-Q5_K_M/Qwen4-35B-A3B-UD-Q5_K_M-00002-of-00002.gguf 14 GiBUD-Q5_K_XL/Qwen4-35B-A3B-UD-Q5_K_XL-00001-of-00002.gguf 26 GiBUD-Q6_K/Qwen4-35B-A3B-UD-Q6_K-00001-of-00002.gguf 27 GiBUD-Q6_K/Qwen4-35B-A3B-UD-Q6_K-00002-of-00002.gguf 20 GiBUD-Q6_K_XL/Qwen4-35B-A3B-UD-Q6_K_XL-00001-of-00002.gguf 28 GiBUD-Q6_K_XL/Qwen4-35B-A3B-UD-Q6_K_XL-00002-of-00002.gguf 20 GiBQ8_0/Qwen4-35B-A3B-Q8_0-00001-of-00002.gguf 36 GiBQ8_0/Qwen4-35B-A3B-Q8_0-00002-of-00002.gguf 20 GiBUD-Q8_K_XL/Qwen4-35B-A3B-UD-Q8_K_XL-00001-of-00002.gguf 38 GiBUD-Q8_K_XL/Qwen4-35B-A3B-UD-Q8_K_XL-00002-of-00002.gguf 20 GiBBF16/Qwen4-35B-A3B-BF16-00003-of-00003.gguf 38 GiBBF16/Qwen4-35B-A3B-BF16-00001-of-00003.gguf 34 GiBBF16/Qwen4-35B-A3B-BF16-00002-of-00003.gguf 33 GiBUD-IQ2_M/Qwen4-35B-A3B-UD-IQ2_M-00001-of-00002.gguf 14 GiBUD-IQ2_M/Qwen4-35B-A3B-UD-IQ2_M-00002-of-00002.gguf 11 GiBUD-Q2_K_XL/Qwen4-35B-A3B-UD-Q2_K_XL-00001-of-00002.gguf 15 GiBUD-Q2_K_XL/Qwen4-35B-A3B-UD-Q2_K_XL-00002-of-00002.gguf 11 GiBUD-Q3_K_XL/Qwen4-35B-A3B-UD-Q3_K_XL-00002-of-00002.gguf 11 GiBUD-Q4_K_S/Qwen4-35B-A3B-UD-Q4_K_S-00002-of-00002.gguf 11 GiBUD-Q4_K_M/Qwen4-35B-A3B-UD-Q4_K_M-00001-of-00002.gguf 22 GiBUD-Q4_K_M/Qwen4-35B-A3B-UD-Q4_K_M-00002-of-00002.gguf 11 GiBUD-Q4_K_XL/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf 23 GiBUD-Q4_K_XL/Qwen4-35B-A3B-UD-Q4_K_XL-00002-of-00002.gguf 11 GiBUD-Q5_K_XL/Qwen4-35B-A3B-UD-Q5_K_XL-00002-of-00002.gguf 14 GiBb70_engine --model Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf --cards 0,1,2,3 --ctx 4096 --kv f16 --mtp 5 --mtp-adaptive --serveView run on LocalMaxxing
llama-server --host 127.0.0.1 --port 8014 --n-gpu-layers all --fit off --no-context-shift --flash-attn on --batch-size 512 --threads 8 --threads-batch 8 --parallel 1 --cache-ram 0 --jinja --reasoning on --model Qwen4-35B-A3B-UD-IQ4_XS-00001-of-00002.gguf --ctx-size 196608 --cache-type-k q8_0 --cache-type-v q8_0 --ubatch-size 512 --ctx-checkpoints 8 --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0 --presence-penalty 0.0 --repeat-penalty 1.0 --lazy-mode on --spec-type draft-mtp --spec-draft-n-max 2 --spec-draft-n-ubatch 16 --spec-draft-type-k q8_0 --spec-draft-type-v q8_0View run on LocalMaxxing
b70_engine --model Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf --cards 0,1 --ctx 4096 --kv f16 --mtp 5 --mtp-adaptive --serveView run on LocalMaxxing
/mnt/nvme8tb/llama-build/llama.cpp-qwen4/build/bin/llama-server --host 127.0.0.1 --port ${PORT} -ngl 999 --flash-attn on --jinja --threads 8 -m /mnt/nvme8tb/llama-models/Qwen4-35B-A3B-GGUF/UD-Q8_K_XL/Qwen4-35B-A3B-UD-Q8_K_XL-00001-of-00002.gguf --ctx-size 262144 --parallel 8 --kv-unified --batch-size 2048 --ubatch-size 512 --spec-type draft-mtp --spec-draft-n-max 2 --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0 --presence-penalty 0.0View run on LocalMaxxing llama-server -m Qwen4-35B-A3B-UD-Q3_K_XL-00001-of-00002.gguf -np 1 -ngl 99 -fa on -c 32768 -ctk q8_0 -ctv q8_0 --load-mode mmap --lazy-mode auto -ot per_layer_token_embd=CPU --fit off --jinja -b 2048 -ub 512 -t 4 -tb 12 --cache-ram 0 --no-context-shift -md dflash2-Qwen4-35B-A3B-Q8_0.gguf -ngld 99 --spec-type draft-dflash2 --spec-draft-n-max 5 --spec-draft-p-min 0 -ctkd q8_0 -ctvd q8_0View run on LocalMaxxing
python3 serve/server.py --engine strata --port 8098 --host 0.0.0.0 --config q4lite-8098.json # strata q4_lite tree @22a9714 (Strata PR #7774 port of qwen4exp 35B-A3B); engine args: --pack pack-trunk40-iq4xs --native trunk40-iq4xs.gguf --ple-gguf Qwen4-35B-A3B-UD-IQ4_XS-00002-of-00002.gguf --expert-cache auto --prefill 4096 --max-context 262144 --kv q4_0 --spec 4 --mtp MTP/rt --vram-reserve-mib 512 --gpu 0,1,2 --serve --layer-split 12,26 --split-device 1,2View run on LocalMaxxing
Median of 25 community runs on 8 setups, from LocalMaxxing.
Run it yourself: setup guideQwen/Qwen4-35B-A3B