Run this model with HF Jobs

Run palmfuture/Qwen4-35B-A3B-GPTQ-Int4 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/palmfuture/Qwen4-35B-A3B-GPTQ-Int4. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/palmfuture/Qwen4-35B-A3B-GPTQ-Int4 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/palmfuture/Qwen4-35B-A3B-GPTQ-Int4. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Qwen4-35B-A3B-GPTQ-Int4

GPTQ INT4 build of Qwen/Qwen4-35B-A3B (image + text, 35B parameters, 3B active), tested on 4x RTX 3060 12 GB with stock vLLM 0.34.0: 500K-token context, 8 concurrent requests, vision on, MTP speculative decoding, about 6.2 GiB of weights per card.

  • Only the routed experts are INT4 (GPTQ, 4 bit, group 128, symmetric). Everything else is the released BF16.
  • The n-gram (PLE) table, 20B parameters, is not quantized. vLLM reads it from the checkpoint files on disk (--engram-config '{"disk_offload":true}'), so it costs no GPU memory and no pinned host RAM. Keep the files on an NVMe.
  • Serving scripts and full test results: github.com/palmfuture/Qwen4-35B-A3B-GPTQ-Int4 (start.sh / stop.sh, the all-reduce patch, benchmark scripts, raw results).

Unofficial community build, not affiliated with Qwen / Alibaba or vLLM.

What is quantized

Part Params In this build
Routed experts, 40 layers x 256 experts (gate/up/down) 32.2B INT4, GPTQ, group 128, symmetric, per-expert tensors
N-gram embedding table (PLE, layer 1, 128 shards) 20.5B BF16, unchanged (read from disk at run time)
Attention (Qwen Sparse Attention + indexer), Gated DeltaNet, shared experts, routers, hyper-connections, PLE projections, embeddings, lm_head ~2.8B BF16, unchanged
MTP layer (incl. its 256 experts) ~2B by Qwen's count BF16, unchanged
Vision encoder ~0.4B BF16, unchanged

Files: about 25 GB of quantized and BF16 model tensors (model-0000*-of-00008.safetensors) plus 41 GB of n-gram table shards (ple-*.safetensors). GPU-resident weights at TP4: 6.2 GiB per card.

Quality

Per-token log-probabilities on held-out text (43 samples, 39,870 positions; 13,887 of them Thai: Thai instructions and Thai Wikipedia, plus agent and tool sessions, C4, code, math, reasoning, Tulu), compared with the BF16 model served by vLLM 0.34.0 on a DGX Spark. The quantized builds ran on 4x RTX 3060 (TP4, expert parallel, --max-num-batched-tokens 256). Lower NLL change and higher top-1 agreement are better.

Build All: NLL change All: top-1 agreement Thai: NLL change Thai: mean abs. log-prob diff Thai: top-1 agreement
This repo (GPTQ experts, BF16 n-gram table) -0.006 88.7% +0.007 0.312 87.2%
GPTQ experts, FP8 n-gram table -0.001 88.9% +0.011 0.317 87.4%
RTN experts (no calibration), BF16 n-gram table -0.008 87.3% +0.038 0.371 84.9%
RTN experts, FP8 n-gram table -0.015 87.3% +0.041 0.372 84.9%
  • GPTQ against plain round-to-nearest matters most for Thai: about 5x smaller NLL change and 2.3 points more top-1 agreement. In side-by-side Thai answers the RTN build mixed in Chinese / English / Vietnamese words now and then; this build did not in our (few) samples.
  • The n-gram table in FP8 (Qwen's own FP8 encoding, as in Qwen/Qwen4-35B-A3B-FP8) is within the noise of BF16 here. This repo keeps BF16.
  • The reference ran on a different GPU at TP1, the builds on TP4, so part of every difference is the platform; the agent/tool samples use a Qwen3.8 chat format and are the noisiest. Compare the rows with each other.

Serving on 4x RTX 3060 12 GB with vLLM 0.34.0

docker run -d --name qwen4 --gpus all --ipc host --network host \
  -e VLLM_SPARSE_INDEXER_MAX_LOGITS_MB=128 \
  -v /path/to/Qwen4-35B-A3B-GPTQ-Int4:/model:ro \
  vllm/vllm-openai:v0.34.0 \
  --model /model --served-model-name Qwen4-35B-A3B \
  --tensor-parallel-size 4 --enable-expert-parallel --disable-custom-all-reduce \
  --max-model-len 500000 --max-num-seqs 8 --max-num-batched-tokens 1024 \
  --gpu-memory-utilization 0.94 --kv-cache-dtype fp8 --disable-extensible-kv-cache \
  --engram-config '{"disk_offload":true}' \
  --mm-processor-kwargs '{"max_pixels":1048576}' \
  --speculative-config '{"method":"mtp","num_speculative_tokens":1,"index_share_for_mtp_iteration":true}' \
  --enable-auto-tool-choice --tool-call-parser qwen3_coder --reasoning-parser qwen3

Why each non-default flag (all measured on this box; start.sh in the GitHub repo runs exactly this):

Flag Why
--enable-expert-parallel Required at TP4. Sliced four ways (128 rows a card, one 128-group), vLLM 0.34's 4-bit Marlin MoE gives wrong results: on a 4-layer test the per-token log-prob error was 0.099 against 0.014-0.021 for TP1 or expert parallel, and over 40 layers Thai output fell apart. With expert parallel every card holds 64 whole experts.
--engram-config '{"disk_offload":true}' The 41 GB n-gram table stays on disk; each step reads only its rows.
--kv-cache-dtype fp8 1.75x the KV pool of BF16; works on Ampere (Triton path), quality within noise in our checks.
--disable-extensible-kv-cache vLLM 0.34's extensible KV cache kept 1.55 GiB a card back for activations; the KV pool got 2.2 of 4.6 free GiB. Off: 357K โ†’ 663K tokens (util 0.97 vs 0.96, vision off, 65K context).
VLLM_SPARSE_INDEXER_MAX_LOGITS_MB=128 The sparse-attention indexer takes this buffer (512 MiB by default) on every prefill step and scores in chunks under it. 512 MiB at util 0.96 ran out of memory on a 250K prompt; 128 gives 384 MiB a card back.
--gpu-memory-utilization 0.94, --max-num-batched-tokens 1024 Tested limits with the two items above.
MTP=1 with index_share_for_mtp_iteration +45% single-stream speed over no MTP; 3 draft tokens was slower under load (only ~1.2 of 3 accepted).
--mm-processor-kwargs '{"max_pixels":1048576}' Smaller profiling image, less activation memory reserved for vision.

Measured with this build (thinking off, 400 output tokens, sampled 0.7 / 0.8 / top-k 20):

KV pool 572,938 tokens (MTP=1). Without MTP: about 740K. The pool is shared: one 500K request plus ~70K of others at once.
Decode, 1 / 4 / 8 requests 131-137 / 305-323 / 496-504 tok/s with the PCIe all-reduce patch below; 119-126 / 303-305 / 443-469 with stock NCCL over P2P (measured on an RTN build of the same tensor sizes)
MTP 75% of drafts accepted
Needle in a 490,090-token prompt 3 of 3 found, 233 s, while 8-request batches ran; peak 11,647 of 12,288 MiB a card, no errors
Prefill about 2,100 tok/s over the whole 490K prompt
Vision 2 of 2 synthetic images described correctly

Notes for this hardware:

  • GeForce cards need peer-to-peer enabled (we use a patched libcuda and NCCL_P2P_LEVEL=SYS); without P2P use NCCL_P2P_DISABLE=1 and expect lower multi-request throughput.
  • patches/vllm-0.34-pcie-ipc-allreduce.patch (GitHub repo; AR=pcie ./start.sh) turns on FlashInfer's PCIe IPC all-reduce (VLLM_ALLREDUCE_USE_FLASHINFER_PCIE_IPC=1, mounted over vLLM's wrapper) for decode-size batches: +9% at 1 request, +7% at 8. Set VLLM_PCIE_IPC_AR_PREFILL_MAX=0: tuning a 1024-token prefill workspace never finished on our cards. Its kernels spin without a timeout, so a hang leaves the container "Up"; watch it.

Config naming

config.json declares Qwen4ExpForConditionalGeneration / qwen4_exp (Qwen's release says Qwen4MoeForConditionalGeneration / qwen4_moe). The two configs differ only in sizes and these names, and vLLM 0.34.0 serves the Qwen4-Exp network (as for Qwen3.8-Flash-Next) but does not know the qwen4_moe name yet. The tokenizer at the top level is Qwen's Hugging Face-compatible one (tokenizer-compat/ in the original repo).

Known limits

  • /v1/systemone, /v1/decisions, /generative_scoring: not supported for this architecture in vLLM 0.34 (501 / 404).
  • reasoning_effort takes xhigh, high, low, off; none is refused. Thinking is on by default (high). "chat_template_kwargs": {"enable_thinking": false} also turns it off.
  • A request with prompt_logprobs on a long prompt can run a 12 GB card out of memory at util 0.94 (full-vocab logits for the whole prefill chunk); use --max-num-batched-tokens 256 for that kind of scoring.
  • While a very long prompt prefills, other requests slow down a lot (8 streams fell to ~14 tok/s total during the 490K prefill); a smaller --max-num-batched-tokens interleaves better and prefills slower.
  • Tested only on RTX 3060 (sm_86) with the stock vllm/vllm-openai:v0.34.0 image.

Qwen4-35B-A3B (official model card)

Below is Qwen's model card for Qwen/Qwen4-35B-A3B, text unchanged; headings are one level lower and two relative links point to Qwen's repository. Its serving commands load the original BF16 weights; for this INT4 build use the commands above.

This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format.

These artifacts are compatible with Hugging Face Transformers, vLLM, SGLang, TokenSpeed, etc.

For users seeking managed, scalable inference without infrastructure maintenance, the official Qwen API service is provided by Qwen Cloud.

In particular, Qwen4-35B-A3B is served under the model name qwen4-35b-a3b, with more production features, e.g., official built-in tools. The APIs will be avaible at Qwen Cloud soon.

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 Highlights

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.

Model Overview

  • Type: Causal Language Model with Vision Encoder
  • Training Stage: Pre-training & Post-training
  • Language Model
    • Number of Parameters: 35B with 3B activated, plus 20B n-gram embedding and 2B MTP
    • Hidden Dimension: 2048
    • Token Embedding: 248320 (Padded)
    • N-gram Embedding: 10,000,000 (bigrams/trigrams at layer 2)
    • Number of Layers: 40
    • Hidden Layout: 10 ร— (3 ร— (Gated DeltaNet โ†’ MoE) โ†’ 1 ร— (Qwen Sparse Attention โ†’ MoE))
    • Gated DeltaNet:
      • Number of Linear Attention Heads: 32 for V and 16 for QK
      • Head Dimension: 128
    • Qwen Sparse Attention:
      • Number of Attention Heads: 16 for Q and 2 for KV
      • Head Dimension: 256
      • Rotary Position Embedding Dimension: 64
      • Indexer Structure: MQA with 4 Query Heads and 1 Shared Key Head
      • Indexer Head Dimension: 128
      • Budget: 512 blocks or 2048 tokens
    • Mixture Of Experts
      • Number of Experts: 256
      • Number of Activated Experts: 8 Routed + 1 Shared
      • Expert Intermediate Dimension: 512
    • Gated Residual:
      • Number of Branches: 4
      • Bottleneck Rank: 256
    • LM Output: 248320 (Padded)
    • MTP: 1 layer, trained with multi-steps
  • Context Length: 1,048,576 natively.

Benchmark Results

Qwen4-35B-A3B Benchmark Results

1. Terminal Bench 4.1, FrontierCode-AA 2.0, AA-Briefcase v1.1 and AutomationBench-AA: Scores are cited from Artificial Analysis.
2. APEX-Agents v1.1: Scores are cited from the Mercor leaderboard.
3. Work360: Our built-in benchmark for evaluating models' capabilities across industrial and professional workflows.
4. ChartoGraphy: The scores of our models were obtained with min_pixels set to 4096ร—32ร—32.

Quickstart

For streamlined integration, we recommend using Qwen4-35B-A3B via APIs.

Serving Qwen4-35B-A3B

Inference efficiency and throughput vary significantly across frameworks. We recommend using the latest framework versions to ensure optimal performance and compatibility. For production workloads or high-throughput scenarios, dedicated serving engines such as SGLang, vLLM, and TokenSpeed are strongly recommended.

Qwen4-35B-A3B can be deployed with popular inference frameworks for production-level serving, e.g.:

For local deployment, model repositories in compatible formats can be found in the model tree on the right. The Qwen4 architecture is supported by general-purpose inference engines such as llama.cpp, ollama, unsloth, mlx-vlm, and LiteRT-LM as well as by specialized inference engines for Qwen4.

Qwen4 Tokenizer

Along with the model weights, we release a reference implementation of the Qwen4 Tokenizer/Processor. It ships with the original BPE vocabulary and provides methods for formatting messages into token sequences and parsing messages from generated token sequences. The implementation additionally depends on tiktoken, and trust_remote_code=True is required when creating the tokenizer instance. We recommend using this implementation.

For ecosystems that rely on Jinja chat templates, we include one in tokenizer-compat/ for backward compatibility only. Please note that although it produces the same formatted text, the resulting token IDs can be different, since the reference implementation distinguishes control tokens from regular tokens at the ID level.

See README-tokenizer.md for details.

API Usage

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.0

Please note that the support for sampling parameters varies according to inference frameworks.

Thinking Control

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 most
  • high: for common tasks (default)
  • low: for fast responses with minimal thinking
  • off: disables thinking entirely

The 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.

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.

Chat Completions API

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,
})

Best Practices

To achieve optimal performance, we recommend the following settings:

  1. Sampling Parameters: We suggest using the following sets of sampling parameters:

    • 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.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.

  2. 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:

    • Reasoning Content: Set the maximum output length to 262,144 tokens.
    • Final Response: Set the maximum output length to 131,072 tokens.

    These settings provide the necessary capacity for complex reasoning while ensuring ample space for high-quality final deliverables.

  3. 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.

  4. 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},
        }, 
    )
    

Citation

If you find our work helpful, feel free to give us a cite.

@techreport{qwen2026design,
    title       = {On the Design of {Qwen3.8-Next} Architecture: Evaluation, Efficiency, and Training Stability},
    author      = {{Qwen Team}},
    institution = {Alibaba Group},
    month       = {August},
    year        = {2026}
}

@misc{qwen4-35ba3b,
    title  = {{Qwen4-35B-A3B}},
    author = {{Qwen Team}},
    month  = {December},
    year   = {2026},
    url    = {https://huggingface.co/Qwen/Qwen4-35B-A3B}
}
Downloads last month
452
Safetensors
Model size
57B params
Tensor type
BF16
ยท
I32
ยท
I64
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for palmfuture/Qwen4-35B-A3B-GPTQ-Int4

Quantized
(602)
this model

Collection including palmfuture/Qwen4-35B-A3B-GPTQ-Int4