Welcome Qwen 4: Cutting-edge intelligence on-device

In this articleArchitecture and capabilitiesBenchmark performanceInference support Alibaba releases Qwen4-35B-A3B on Hugging Face The Alibaba Qwen Team has published Qwen4-35B-A3B on Hugging…

By Vane December 4, 2026 6 min read
Welcome Qwen 4: Cutting-edge intelligence on-device


Alibaba releases Qwen4-35B-A3B on Hugging Face

The Alibaba Qwen Team has published Qwen4-35B-A3B on Hugging Face. This is a natively multimodal Mixture-of-Experts model with approximately 35 billion main parameters, 3.8 billion active parameters per token, and 20.5 billion Per-Layer N-gram Embedding parameters, bringing the total count to roughly 56 billion. It accepts text, image, and video inputs, maintains a 1 million token context window, and uses an Apache-2.0 license.

Development included day-0 support for transformers, llama.cpp, Llama App, vLLM, SGLang, MLX, Inference Providers, and Inference Endpoints. The release details the architecture, deployment methods, and fine-tuning options.

Architecture and capabilities

The model uses a multimodal mixture-of-experts design with a 1M-token context window. The text decoder follows a four-layer pattern repeated ten times. The first three layers employ Gated DeltaNet, which updates a fixed-size memory as it processes each token. The fourth layer uses Qwen Sparse Attention (QSA), allowing the current token to access specific tokens from anywhere in the context. An indexer groups tokens into sets of four and averages their keys. For each query, it selects up to 512 groups. The attention layer then reads the individual tokens in those groups, plus any remaining tokens in the final unfinished group, providing access to up to 2,048 selected tokens and a maximum of three additional tokens at the end.

Information flow between layers has changed. Each token begins with four copies of its 2,048-dimensional embedding, forming four residual streams. Before every attention or MoE block, learned gates mix these streams into a single input. Eight selected experts and a shared expert process this input to produce one combined output. Each stream then adds a scaled copy of that output to its own state, with a learned gate setting the scale separately for each stream.

A significant component resides in the second decoder layer. This layer contains a per-layer embedding table (PLE) with 20.5 billion parameters. Each token reads 16 rows of the PLE table. Eight lookups encode the last two tokens, while the other eight lookups encode the current token and the two tokens immediately preceding it. The layer joins these 16 embeddings into one, gates their contribution to each residual stream, and applies a short convolution to mix in nearby patterns.

The model uses a vision transformer to encode images and video. The ViT divides images into 16 × 16 patches and merges each 2 × 2 group of spatial patches into a single visual token passed to the text decoder. For video, the processor samples two frames per second and groups consecutive sampled frames into pairs. The vision transformer then allows every patch to attend to every other patch within that frame pair.

Benchmark performance

The Qwen team published model benchmarks in the model card. We have selected community-favourite results across various tasks. Qwen4-35B-A3B performs comparably to the larger Qwen 3.8 Flash Next model, or outperforms it in specific tasks.

Inference support

Qwen4-35B-A3B includes day-0 support in transformers, llama.cpp, vLLM, SGLang, Inference Providers, and Inference Endpoints.

Transformers integration

The quickest method to run the model is the

any-to-any

pipeline:

from transformers import pipeline

pipe = pipeline("image-text-to-text", model="Qwen/Qwen4-35B-A3B", processor="huggingface/Qwen4-35B-A3B-processor", device_map="auto")

messages = [{"role": "user", "content": "Who are you?"}]
outputs = pipe(messages, max_new_tokens=2048, return_full_text=False)
print(outputs[0]["generated_text"])

For lower-level control, you can load the model and processor with the

AutoModelForMultimodalLM

and

AutoProcessor

classes. You can control reasoning effort directly using four values (

"xhigh"

,

"high"

,

"low"

, or

"off"

). The default is

"high"

if no value is provided.

from transformers import AutoModelForMultimodalLM, AutoProcessor

model_id = "Qwen/Qwen4-35B-A3B"

processor = AutoProcessor.from_pretrained("huggingface/Qwen4-35B-A3B-processor")
model = AutoModelForMultimodalLM.from_pretrained(
    model_id,
    device_map="auto"
)

messages = [{"role": "user", "content": "Who are you?"}]
inputs = processor.apply_chat_template(
    messages,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
    reasoning_effort="off"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=512)
print(processor.batch_decode(outputs, skip_special_tokens=True))

Handling different modalities

The following sections demonstrate running inference on different input types. A common setup for all sections involves loading the model and the processor.

from transformers import AutoModelForMultimodalLM, AutoProcessor

model_id = "Qwen/Qwen4-35B-A3B"

processor = AutoProcessor.from_pretrained("huggingface/Qwen4-35B-A3B-processor")
model = AutoModelForMultimodalLM.from_pretrained(
    model_id,
    device_map="auto"
)

Text-only inference

messages = [
    {"role": "system", "content": "You should only answer with a number."},
    {"role": "user", "content": "What is 17 * 23?"},
]

inputs = processor.apply_chat_template(
    messages,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
    reasoning_effort="off"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=512)
print(processor.batch_decode(outputs, skip_special_tokens=True))

Images and text

To run inference with images and text, you can add images to the messages and pass them to

apply_chat_template

.

messages = [
    {
    "role": "user",
    "content": [
        {"type": "image", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/llama.cpp/pills.jpg"},
        {"type": "text", "text": "Do the components of these drugs interact with each other?"},
    ],
    }
]

inputs = processor.apply_chat_template(
    messages,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
    reasoning_effort="off"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=512)
print(processor.batch_decode(outputs, skip_special_tokens=True))

Video inference

You can also add videos to the messages and pass them to

apply_chat_template

. Note that you need to have

torchcodec

and

ffmpeg

installed.

messages = [
    {
        "role": "user",
        "content": [
            {"type": "video", "video": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/llama.cpp/pf.mp4"},
            {"type": "text", "text": "What is this video about?"},
        ],
    }
]

inputs = processor.apply_chat_template(
    messages,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
    reasoning_effort="off"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=512)
print(processor.batch_decode(outputs, skip_special_tokens=True))

Tool calling

You can provide tools that the model uses to solve requests. This is how you would configure it:

def get_current_temperature(location: str, unit: str):
    """
    Get the current temperature at a location.

    Args:
        location: The location to get the temperature for, in the format "City, Country"
        unit: The unit to return the temperature in. (choices: ["celsius", "fahrenheit"])
    """
    return 22.0  # A real function would call a weather API here

messages = [{"role": "user", "content": "Hey, what's the temperature in Paris right now?"}]
inputs = processor.apply_chat_template(
    messages,
    tools=[get_current_temperature],
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
    reasoning_effort="off"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=512)
print(processor.batch_decode(outputs, skip_special_tokens=True))

llama.cpp support

Qwen4-35B-A3B includes day-0 support for llama.cpp and Llama App. We ship three quantized versions to the Hub:

Q4_K_M

4-bit,

Q6_K

6-bit, and

Q8_0

8-bit. You can find them in the GGUF repository.

# llama serve  
llama serve -hf ggml-org/Qwen4-35B-A3B-GGUF:Q6_K
# llama cli  
llama cli -hf ggml-org/Qwen4-35B-A3B-GGUF:Q6_K

MTP speculative decoding is supported out of the box. Enable it using the

--spec-type

and

--spec-draft-n-max

options. Testing with three draft tokens increased generation speed by 22% on an Apple Silicon M5 using Q4 quantization.

llama serve -hf ggml-org/Qwen4-35B-A3B-GGUF:Q4_K_M --spec-type draft-mtp --spec-draft-n-max 3
Source Read original →
Scroll to Top