Welcome Qwen 4: Cutting-edge intelligence on-device Alibaba's Qwen Team released Qwen4-35B-A3B on Hugging Face, a natively multimodal Mixture-of-Experts model with roughly 35B main parameters, about 3.8B active parameters per token, and roughly 20.5B Per-Layer N-gram Embedding parameters (~56B total), licensed under Apache-2.0. The model accepts text, image, and video inputs with a 1M token context window, uses 256 routed experts, and shipped with day-0 support across transformers, llama.cpp, Llama App, vLLM, SGLang, MLX, Inference Providers, and Inference Endpoints, with BF16, FP8, OMLX, and GGUF checkpoints. Its text decoder repeats a four-layer pattern ten times, alternating Gated DeltaNet layers with Qwen Sparse Attention, which selects up to 512 groups of four tokens for up to 2,048 selected tokens per query. Image-Text-to-Text • 57B • Updated • 12 • 108 https://huggingface.co/Qwen/Qwen4-35B-A3B Welcome Qwen 4: Cutting-edge intelligence on-device Update on GitHub https://github.com/huggingface/blog/blob/main/qwen4.md Qwen4-35B-A3B https://huggingface.co/Qwen/Qwen4-35B-A3B/ by the Alibaba Qwen Team is out on Hugging Face Following the architectural preview in Qwen3.8-Flash-Next, Qwen4-35B-A3B brings Qwen's full next-generation hybrid design into production. It is a natively multimodal Mixture-of-Experts MoE model with ~35B main parameters and ~3.8B active parameters per token and ~20.5B Per-Layer N-gram Embedding PLE parameters ~56B total . It supports native text, image, and video inputs, a 1M token context window , and is licensed under Apache-2.0 . We collaborated with the Qwen Team to ship day-0 support across transformers, llama.cpp, Llama App, vLLM, SGLang, MLX, Inference Providers, and Inference Endpoints. This post walks through the salient features of the architecture, how to run it, and how to fine-tune it for your own tasks. TL;DR - Architecture: Multimodal MoE with 256 routed experts, ~35B parameters with ~3.8B active, plus ~20.5B per-layer n-gram embeddings. - Modalities & Context: Native text, image, and video inputs → text output, with a 1M token native context window. - Checkpoints: BF16, FP8, OMLX, GGUF quantized versions - Inference: Multi-Token Prediction MTP drafter for GGUF and OMLX, adjustable reasoning effort levels "xhigh", "high", "low", "off" . - Day-0 Ecosystem support: transformers, llama.cpp / Llama App, vLLM, SGLang, TRL, Inference Providers, and Inference Endpoints. What is new with Qwen4? Qwen4-35B-A3B is a multimodal mixture-of-experts model with 1M-token context window. The text decoder repeats the same four-layer pattern ten times. The first three layers use Gated DeltaNet, which updates a fixed-size memory as it reads each token. The fourth uses Qwen Sparse Attention QSA , which lets the current token look back at individual tokens from anywhere in the context. To decide where to look, a small indexer groups tokens in groups of four tokens and averages their keys. For each query, it picks up to 512 groups. The attention layer then reads the individual tokens in those groups, plus any tokens in the last unfinished group. That gives it up to 2,048 selected tokens and at most three more at the end. Qwen4-35B-A3B also changes how information moves between layers. Each token starts with four copies of its 2,048-dimensional embedding. These become four residual streams. Before each attention or MoE block, learned gates mix the streams into a single input. The eight selected experts and the shared expert process that input and produce one combined output. Each stream then adds a scaled copy of that same output to its own state. A learned gate sets the scale separately for each stream. One of the biggest pieces of the model sits in the second decoder layer. This layer has a per-layer embedding table PLE , which consists of 20.5B parameters. Each token reads just 16 rows of the PLE table. Eight lookups encode the last two tokens and the other eight lookups encode the last three tokens the current token and two tokens immediately before that . The layer joins those 16 embeddings into one, gates their contribution to each residual stream, and uses a short convolution to mix in nearby patterns. The model employs a vision transformer to encode images and video. The ViT reads images into 16 × 16 patches and merges each 2 × 2 group of spatial patches into one visual token, which is passed to the text decoder. For video, the processor samples 2 frames per second and groups consecutive sampled frames into pairs. The vision transformer then lets every patch attend to every other patch within that frame pair. Benchmark Results Qwen team has published the model benchmarks in the model card, we have picked community favorites across different tasks below. Qwen4-35B-A3B punches way above its size and class across various benchmarks. For example, it is comparable to the much larger Qwen 3.8 Flash Next, or even better in some tasks. For example, it is comparable to the much larger Qwen 3.8 Flash Next, or even better in some tasks. Inference Support Qwen4-35B-A3B ships with day-0 support in transformers, llama.cpp, vLLM, SGLang, Inference Providers, and Inference Endpoints. Transformers The quickest way to run the model is the any-to-any pipeline: python 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" Going one level lower, you can load the model and processor with the auto classes, AutoModelForMultimodalLM and AutoProcessor . You can control reasoning effort directly, it takes four values "xhigh" , "high" , "low" , or "off” and defaults to high if no value is provided. python 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", "xhigh", "high", "low", or "off .to model.device outputs = model.generate inputs, max new tokens=512 print processor.batch decode outputs, skip special tokens=True Inference with different modalities In the following sections we will showcase how to run inference on different modalities. A common setup for all the sections will be to load the model and the processor. python 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", "xhigh", "high", "low", or "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 image and text you can simply 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 Similarly, 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 We can also provide tools that the model can use to solve the request. This is how you would do it. python 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 Qwen4-35B-A3B comes with day-0 llama.cpp and Llama App support. We ship 3 quantized versions to the Hub, specifically Q4 K M 4-bit, Q6 K 6-bit and Q8 0 8-bit. You can find them in this GGUF repository https://huggingface.co/ggml-org/Qwen4-35B-A3B-GGUF . 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. You simply need to enable it using the --spec-type and --spec-draft-n-max options. We got great results using 3 draft tokens: generation speed increased 22% on an Apple Silicon M5 with the Q4 quant. llama serve -hf ggml-org/Qwen4-35B-A3B-GGUF:Q4 K M --spec-type draft-mtp --spec-draft-n-max 3 MLX Qwen4-35B-A3B runs on Apple Silicon with oMLX and mlx-lm. oMLX uses custom Metal kernels for QSA and the gated residual. It also supports image input, MTP and PLE offloading to SSD, with oQ quants https://huggingface.co/mlx-community/Qwen4-35B-A3B-oQ4e optimized for oMLX and mlx-lm. mlx-lm support for the language model is on its way to the official repository. Pass --chat-template-config '{"reasoning effort": "low"}' to change the reasoning effort. mlx lm.generate --model mlx-community/Qwen4-35B-A3B-4bit-text \ --prompt "Explain sparse attention like I am 5" \ --max-tokens 4096 SGLang and vLLM We recommend going to SGLang docs https://docs.sglang.io/cookbook/autoregressive/Qwen/Qwen4-35B-A3B and vLLM docs https://recipes.vllm.ai/Qwen/Qwen4-35B-A3B to see how to run the model effectively on their inference engine. Reinforcement Learning of Qwen 4 for cyber defense with TRL Use the Qwen4 harness-adapter recipe https://huggingface.co/spaces/trl-lib/trl-recipes-qwen4 /harness-adapters/Qwen4-35B-A3B to train a model that triages security alerts and cites the evidence behind each decision. The pipeline We will use AsyncGRPOTrainer https://huggingface.co/docs/trl/en/async grpo trainer in TRL to train Qwen4-35B-A3B to label vulnerabilities and cite evidence from the code base. First, we send a case to Qwen4 . Give it a sanitized alert and its evidence records. For example, in a case with repeated sign-in failures and incomplete device data, the analyst’s expected reply might be to escalate and cite events like “A17”. Next, we sample and score replies . vLLM samples several replies for the same alert. Each reply earns a reward of 1 when its triage label and citations match the analyst’s criteria, and 0 otherwise. Then we update the adapter. TRL’s asynchronous GRPO trainer uses the relative rewards within each group of replies to update the LoRA adapter. Finally, we evaluate held-out incidents. Give the base model and saved adapters the same cases and decoding settings. Compare triage label accuracy, citation accuracy, and missed escalations. Run the pipeline on Hugging Face Jobs Use a two-GPU Job and a CUDA image with the trainer, vLLM, and the triage verifier. The bucket has a script that runs vLLM on one GPU and training on the other. Sign in with hf auth login, then replace