> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/models/qwen4.md). Agents can also search and read this documentation through its [MCP server](https://unsloth.ai/docs/~gitbook/mcp).

# Qwen4 35B-A3B: How to Run Locally

Guide to running Qwen4-35B-A3B locally with Unsloth.

**Qwen4-35B-A3B** is Qwen’s new 35B (3B active) MoE model built for agentic coding and vision. It has a native **1M-token context** window and scores **61.8** on **DeepSWE v1.1** and **21.2** on **Terminal-Bench 4.1**. Run Qwen4 locally with Unsloth [Dynamic v3.1 GGUFs](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs.md). 3-bit GGUF use about **18GB RAM,** with engram on SSD. Run and train Qwen4 via the open-source [Unsloth Desktop](https://github.com/unslothai/unsloth) GUI.

{% columns %}
{% column width="50%" %} <a href="https://unsloth.ai/docs/models/qwen4.md#run-qwen4-guide" class="button primary">Run Qwen4 Guide</a><a href="https://unsloth.ai/download" class="button secondary">Download Unsloth</a>

Qwen4 Unsloth quants: [**GGUF**](https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF) • [**MLX**](https://huggingface.co/unsloth/Qwen4-35B-A3B-MLX-4bit)

* [MTP enabled](https://unsloth.ai/docs/models/mtp.md) for fast inference
* Start with `UD-IQ4_XS` on **24 GB** devices and leave room for context
* Unsloth supports running **MLX**, GGUF and **NVFP4**. Unsloth auto chooses the best engram settings for optimal performance

Thank you Qwen for day zero access.
{% endcolumn %}

{% column width="50%" %}

<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FLMvt9omb7163dDoHqkQP%2FSnowbound_10s.gif?alt=media&amp;token=67a6de43-a24c-4539-9264-3eac9d07dfd4" alt=""><figcaption><p>Qwen4 35B GGUF in Unsloth Desktop</p></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

##### ⚙️ Usage Guide

Qwen4 uses Engram, a lookup table that retrieves text patterns when needed instead of storing everything in memory. This means you can run larger + smarter models on hardware with less RAM/VRAM like [Qwen3.8-Flash-Next](https://unsloth.ai/docs/models/qwen3.8-next.md) by storing engram on SSD.

[**Unsloth**](#run-qwen4-in-unsloth-desktop) **manages Engram automatically:** it keeps the table in RAM for faster access when memory is available and offloads it to SSD when memory is tight. This frees RAM and VRAM for model weights and context while balancing speed and memory usage.

Every quant is **two files** in its own folder: `-00001-of-00002.gguf` holds the model and its built-in MTP head, and `-00002-of-00002.gguf` holds only the engram (the per-layer n-gram table, `per_layer_token_embd`). The engram is a lookup table, so it can be memory mapped from SSD and only the rows needed are read. Budget your RAM / VRAM with the **Weights with engram on disk** size, and leave room for the KV cache, compute buffers and the vision projector if you use it.

**Qwen4-35B-A3B Requirements**

**Table: Weights with engram on disk** (RAM + VRAM, or unified memory), full download size in brackets:

| 1-bit       | 2-bit        | 3-bit        | 4-bit        | 5-bit        | 6-bit        | 8-bit             |
| ----------- | ------------ | ------------ | ------------ | ------------ | ------------ | ----------------- |
| 9.8-10.8 GB | 11.9-16.2 GB | 17.2-19.4 GB | 20.5-24.7 GB | 25.9-27.8 GB | 29.2-30.5 GB | 40.5 GB (62.3 GB) |

{% hint style="success" %}
Sizes are GB (10^9 bytes). The first file includes the MTP head (0.49 to 1.72 GB), which llama.cpp only loads with `--spec-type draft-mtp`. See [the vision results](#vision) for which quants were tested.
{% endhint %}

Start with `UD-IQ4_XS` on a 24 GB device or `UD-IQ3_XXS` on an 18 GB device with short context. These are starting points, not full runtime memory requirements. [See every quant's size](#quantization-analysis).

**Recommended Settings**

Qwen4-35B-A3B is a **hybrid thinking** model with different sampling settings for each mode. Use thinking for coding and agentic tasks, and non-thinking for quick replies. Unsloth sets all these parameters automatically but you can change it yourself.

**Native context length:** up to `1,048,576` tokens

| Parameter            | Thinking Mode | Non-thinking Mode |
| -------------------- | ------------: | ----------------: |
| `temperature`        |           1.0 |               0.7 |
| `top_p`              |          0.95 |              0.80 |
| `top_k`              |            20 |                20 |
| `min_p`              |           0.0 |               0.0 |
| `presence_penalty`   |           0.0 |               1.5 |
| `repetition_penalty` |           1.0 |               1.0 |

* Context length = up to `1,048,576` tokens natively.
* Output length: Qwen suggests up to `262,144` tokens for reasoning and `131,072` for the final response on agentic tasks.

**Thinking effort**

Qwen4 supports `reasoning_effort` levels `xhigh` (complex tasks where quality matters most), `high` (default, common tasks), `low` (fast responses with minimal thinking) and `off` (no thinking). `enable_thinking=false` is the same as `reasoning_effort="off"`, and **preserve thinking** (keeping earlier thinking traces in multi-turn chats) is on by default. The model may still answer directly without thinking when it judges a task simple. In multi-turn agentic tasks a lower effort is not always faster overall, since it can lead to more failures and retries.

With `llama-server`:

* Use the **top-level** OpenAI field, for example `{"reasoning_effort": "low"}`, or `{"reasoning_effort": "off"}` to disable thinking.
* Or disable thinking with `{"chat_template_kwargs": {"enable_thinking": false}}`, or start the server with `--reasoning off`.

{% hint style="warning" %}
Do **not** send `{"chat_template_kwargs": {"reasoning_effort": "off"}}` on its own. llama-server keeps its default `enable_thinking: true`, so the request fails with **HTTP 500** (`Conflicting thinking settings`). Use the top-level `reasoning_effort` field instead, or add `"enable_thinking": false`. We reproduced this on an RTX 5090, a Mac M5 Max and an RTX Spark.
{% endhint %}

#### Run Qwen4 Guide <a href="#run-qwen4-guide" id="run-qwen4-guide"></a>

You can run Qwen4-35B-A3B in [Unsloth Desktop](#run-qwen4-in-unsloth-desktop) and llama.cpp. Unsloth will automatically load all parameters, optimal hardware settings etc. but you can still change it later. GGUF: [Qwen4-35B-A3B-GGUF](https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF)

<a href="https://unsloth.ai/docs/models/qwen4.md#run-qwen4-in-unsloth-desktop" class="button primary">Run in Unsloth Desktop</a><a href="https://unsloth.ai/docs/models/qwen4.md#run-qwen4-in-llama-cpp" class="button secondary">Run in llama.cpp</a>

##### 🦥 Run Qwen4 in Unsloth Desktop <a href="#run-qwen4-in-unsloth-desktop" id="run-qwen4-in-unsloth-desktop"></a>

Qwen4 can run in Unsloth Desktop, an open-source app for local AI on **macOS, Windows and Linux**. **Unsloth automatically configures engram** and also **offloads to RAM** and **detects multi-GPU setups.**

{% columns %}
{% column %}

* Search, download, [run GGUFs](https://unsloth.ai/docs/new/studio.md#run-models-locally), MLX, NVFP4 and safetensor models
* [**Self-healing** tool calling](https://unsloth.ai/docs/new/studio/chat.md#auto-healing-tool-calling) + **web search**
* [**Code execution**](https://unsloth.ai/docs/desktop.md#code-execution) (Python, Bash)
* [Automatic inference](https://unsloth.ai/docs/desktop#feature-deep-dive) parameter tuning (temp, top-p, etc.)
* [Train LLMs](https://unsloth.ai/docs/new/studio.md#no-code-training) 2x faster with 70% less VRAM
  {% endcolumn %}

{% column %}

<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F1VHa8LHpRz3B3rPYFyS6%2Fqwen4%20unsloth%20another.gif?alt=media&amp;token=3e6993f8-8159-4cc8-9287-082cf7ac6609" alt="Unsloth Desktop interface"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% stepper %}
{% step %}
**Install Unsloth**

The easiest way to get started is by downloading the [Unsloth Desktop app](https://unsloth.ai/docs/desktop.md). The app works on [macOS](https://unsloth.ai/docs/get-started/install/mac.md), [Windows](https://unsloth.ai/docs/get-started/install/windows-installation.md), and [Linux](https://unsloth.ai/docs/get-started/install/linux.md).

<a href="https://unsloth.ai/download" class="button primary" data-icon="down-to-bracket">Download Unsloth</a>

* <i class="fa-apple">:apple:</i> [Download for macOS](https://unsloth.ai/download/mac)
* <i class="fa-windows">:windows:</i> [Download for Windows](https://unsloth.ai/download/windows)
* <i class="fa-linux">:linux:</i> [Download for Linux](https://unsloth.ai/download/linux)

You can also install Unsloth manually.

{% tabs %}
{% tab title="Native install" %}
**macOS, Linux, WSL**

```bash
curl -fsSL https://unsloth.ai/install.sh | sh
```

**Windows**

```powershell
irm https://unsloth.ai/install.ps1 | iex
```

{% endtab %}

{% tab title="Docker" %}
The [Unsloth Docker image](https://hub.docker.com/r/unsloth/unsloth) `unsloth/unsloth` is available on Docker. [Read the Docker guide.](https://unsloth.ai/docs/get-started/install/docker)
{% endtab %}

{% tab title="Homebrew" %}
Install Unsloth Desktop.

{% code collapsedlinecount="10" %}

```bash
brew install --cask unsloth
```

{% endcode %}

Update Unsloth Desktop.

```bash
brew upgrade --cask unsloth
```

{% endtab %}

{% tab title="WinGet" %}
Install Unsloth Desktop.

```powershell
winget install --id UnslothAI.Unsloth -e
```

Update Unsloth Desktop.

```powershell
winget upgrade --id UnslothAI.Unsloth -e
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}
**Search and download Qwen4**

Go to [Unsloth Chat](https://unsloth.ai/docs/new/studio/chat.md) or the Model hub, search for `unsloth/Qwen4-35B-A3B-GGUF`, and download a quant from the [requirements table](#qwen4-35b-a3b-requirements). You can also [download the GGUF with the Hugging Face CLI](#run-qwen4-in-llama-cpp) and select the local file.
{% endstep %}

{% step %}
**Run Qwen4**

Select the GGUF in **Chat** and start with `32,768` context. Unsloth automatically chooses where to keep the engram. On Mac, you can also [use the text-only MLX quant](#run-qwen4-on-mac-with-mlx).

If your bundled runtime needs an update for Qwen4, build the latest llama.cpp using the [llama.cpp guide](#run-qwen4-in-llama-cpp) and select that folder under **Settings → Resources → Custom llama.cpp folder**. See our [Unsloth inference guide](https://unsloth.ai/docs/new/studio/chat.md) for model settings.
{% endstep %}

{% step %}
**Serve Qwen4 with Unsloth API**

Use `unsloth run` to serve Qwen4 via an API. From the directory where you built llama.cpp and [downloaded the GGUF with the CLI](#run-qwen4-in-llama-cpp), point Unsloth at the llama.cpp server you built. It prints the endpoint URL and API key. See our [API docs](https://unsloth.ai/docs/basics/api.md).

{% code overflow="wrap" %}

```bash
LLAMA_SERVER_PATH="$PWD/llama.cpp/build/bin/llama-server" \
    unsloth run --model "$PWD/Qwen4-35B-A3B-GGUF/UD-Q4_K_XL/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf" \
    --temp 1.0 \
    --top-p 0.95 \
    --top-k 20 \
    --min-p 0.0
```

{% endcode %}
{% endstep %}

{% step %}
**Unsloth is now ready**

Chat with Qwen4 locally or use it with your coding agent. See the [Unsloth start guide](https://unsloth.ai/docs/integrations/unsloth-start.md).

<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F8EJBW1lJVmB7E7l2J1VD%2Fqwen4%20unsloth%202.gif?alt=media&amp;token=6ec922dd-aa32-47ed-ac48-2f0aa78b7d4d" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**When the model does not fit in VRAM:** Unsloth Desktop keeps the spilled MoE experts in a GPU cache with llama.cpp's `--moe-cache-mib`. In these tests, decode was roughly **1.8–2.0× faster** than the default fit split.

| VRAM  | Decode with `--moe-cache-mib` (tokens/s) | Decode with the fit split (tokens/s) |
| ----- | ---------------------------------------: | -----------------------------------: |
| 24 GB |                                  131-138 |                                69-72 |
| 16 GB |                                      127 |                                   70 |
| 8 GB  |                                       95 |                                   53 |

A 4-bit quant (two-file layout) on a machine with 128 GB of system RAM.
{% endhint %}

##### Run Qwen4 in llama.cpp <a href="#run-qwen4-in-llama-cpp" id="run-qwen4-in-llama-cpp"></a>

{% stepper %}
{% step %}
**Install llama.cpp**

Qwen4 support is in mainline llama.cpp from [ggml-org/llama.cpp#33626](https://github.com/ggml-org/llama.cpp/pull/33626) onwards, so build the latest `master`. Use `-DGGML_CUDA=OFF` for CPU only or Apple Mac / Metal devices (Metal is on by default). If CMake stops with `CUDA::cuda_driver` not found (for example on some CUDA 13 images), add `-DGGML_CUDA_NO_VMM=ON`. See the [llama.cpp build guide](https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md) for Windows and other GPU backends.

{% code overflow="wrap" %}

```bash
git clone https://github.com/ggml-org/llama.cpp
cmake -S llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --target llama-cli llama-server
```

{% endcode %}
{% endstep %}

{% step %}
**Run Qwen4**

`-hf` downloads the quant (both files) and the vision projector. `--load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU` reads the engram from SSD on demand.

Thinking mode (default):

```bash
./llama.cpp/build/bin/llama-server -hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XL \
    -ngl 999 -fa on --jinja -c 32768 \
    --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU \
    --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0
```

Non-thinking mode:

```bash
./llama.cpp/build/bin/llama-server -hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XL \
    -ngl 999 -fa on --jinja -c 32768 \
    --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU \
    --reasoning off \
    --temp 0.7 --top-p 0.8 --top-k 20 --min-p 0.0 --presence-penalty 1.5
```

Open `http://localhost:8080` to chat or use `llama-cli` for terminal chat. You can also [connect llama.cpp to Unsloth Desktop](https://unsloth.ai/docs/integrations/connections/connect-llama.cpp-to-unsloth-run-ggufs-with-llama-server.md).
{% endstep %}

{% step %}
**Vision and manual downloads**

The vision projector ships as `mmproj-BF16.gguf`, `mmproj-F16.gguf` and `mmproj-F32.gguf`. With `-hf`, llama.cpp downloads one automatically (disable it with `--no-mmproj`). See [the vision results](#vision) for lower-bit quants. To download a quant and pick the projector yourself:

```bash
pip install -U huggingface_hub
hf download unsloth/Qwen4-35B-A3B-GGUF --include "UD-Q4_K_XL/*" "mmproj-BF16.gguf" --local-dir Qwen4-35B-A3B-GGUF
./llama.cpp/build/bin/llama-server -m Qwen4-35B-A3B-GGUF/UD-Q4_K_XL/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf \
    --mmproj Qwen4-35B-A3B-GGUF/mmproj-BF16.gguf \
    -ngl 999 -fa on --jinja -c 32768 \
    --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU \
    --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0
```

Keep both files of the quant in the same folder and point `-m` at the first one. `-hf` always downloads both files of a quant.

`llama-mtmd-cli` has no `--reasoning` or `--chat-template-kwargs` option, so it prints the thinking text and a stray `</think>` before the answer. This is cosmetic; `llama-server` separates the reasoning correctly.
{% endstep %}
{% endstepper %}

##### MTP Speculative Decoding

Every Qwen4 GGUF includes the [MTP](https://unsloth.ai/docs/models/mtp.md) head, so there is **no separate MTP file** and no `-md` flag. Add `--spec-type draft-mtp`:

```bash
./llama.cpp/build/bin/llama-server -hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XL \
    --spec-type draft-mtp --spec-draft-n-max 2 \
    -ngl 999 -fa on --jinja -c 32768 \
    --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU \
    --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0
```

The MTP head is one extra layer that shares the model's token embedding and output layer. Its precision follows the quant:

| Quants                       | MTP head precision | Head size |
| ---------------------------- | ------------------ | --------: |
| UD-IQ1\_S up to UD-Q3\_K\_XL | Q4\_K              |   0.49 GB |
| UD-IQ4 and UD-Q4 quants      | Q5\_K              |   0.59 GB |
| UD-Q5 quants                 | Q6\_K              |   0.71 GB |
| UD-Q6\_K, UD-Q6\_K\_XL       | Q8\_0              |   0.92 GB |
| UD-Q8\_K\_XL                 | BF16               |   1.72 GB |

Without `--spec-type draft-mtp` the head is not loaded, so memory use and outputs are the same as a file without it (llama.cpp logs one `unused tensor` line per MTP tensor, which is expected). The previous separate head is still available as `MTP/mtp-Qwen4-35B-A3B-Q8_0.gguf`. It is only needed for older commands that pass it with `-md`, since the head is built into every quant.

**Acceptance rate** (greedy, share of drafted tokens accepted): about **0.89** at `--spec-draft-n-max 1`, **0.68** at n-max 2 and **0.48-0.51** at n-max 3. With n-max 1 and n-max 3 this held across UD-IQ1\_S, UD-Q4\_K\_XL, UD-Q6\_K\_XL and UD-Q8\_K\_XL, the same as the previous separate Q8\_0 head within run-to-run noise.

**Speed on consumer devices** (`UD-Q4_K_XL`, greedy, thinking off, decode tokens/s, mainline llama.cpp):

| Device              | No draft (code / prose) |      n-max 1 code |     n-max 1 prose |  n-max 3 code | n-max 3 prose |
| ------------------- | ----------------------: | ----------------: | ----------------: | ------------: | ------------: |
| RTX 5090 (32 GB)    |           174.9 / 168.6 | 224.0 (**1.28x**) | 205.3 (**1.22x**) | 221.2 (1.27x) | 174.9 (1.04x) |
| Mac M5 Max (128 GB) |             91.2 / 91.2 | 118.5 (**1.30x**) | 111.1 (**1.22x**) | 118.8 (1.30x) |  95.9 (1.05x) |
| RTX Spark (128 GB)  |             62.8 / 62.8 |  81.3 (**1.29x**) |  75.1 (**1.20x**) |  84.9 (1.35x) |  65.8 (1.05x) |

**Draft depth 2 is the recommended default** (`--spec-draft-n-max 2`), and it is the Qwen4 default in [Unsloth builds that include #21300](https://github.com/unslothai/unsloth/pull/21300):

* **A100:** 216-219 tokens/s at depth 2 vs 195-196 at depth 1; at 8K context, 188 vs 175.
* **Mac M5 Max** (built-in head, separate run from the table above): code **1.40x** at depth 2 vs 1.33x at depth 1; prose 1.21x vs 1.24x.
* Depth 3 and 4 were slower than depth 2 everywhere we measured.

When experts spill to CPU (the model does not fit in VRAM), use depth **1**: depth 2 measured slower in that setup. Speed-ups depend on your hardware, so compare with and without `--spec-type draft-mtp` on your setup.

**First prompt after loading is slower.** With `-ot per_layer_token_embd=CPU` the engram table is memory-mapped from disk, so the first prompts read it from SSD. On an RTX 5090, `UD-Q4_K_XL` prompt processing (pp512) measured about 750 tokens/s on a cold first run vs about 8,300 tokens/s once the table is in the page cache (decode 155 vs 190 tokens/s). Send a short warm-up prompt after loading, or discard the first run when benchmarking.

##### Engram Table Swaps

Each quant ships its engram in its second file: **IQ4\_NL** up to UD-Q4\_K\_XL, **Q5\_1** for the UD-Q5 quants and **Q8\_0** for UD-Q6\_K, UD-Q6\_K\_XL and UD-Q8\_K\_XL. The [`engram/`](https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF/tree/main/engram) folder has the same table at other precisions, so any quant can use a more precise or a smaller table:

<details>

<summary>Click to reveal full engram breakdown table:</summary>

| File                                    | Table type |     Size | Relative RMSE vs BF16 | KLD vs BF16 with UD-Q4\_K\_XL | Notes                                                 |
| --------------------------------------- | ---------- | -------: | --------------------: | ----------------------------: | ----------------------------------------------------- |
| `Qwen4-35B-A3B-engram-BF16.gguf_file`   | BF16       | 40.96 GB |                     0 |                        0.0319 | lossless                                              |
| `Qwen4-35B-A3B-engram-Q8_0.gguf_file`   | Q8\_0      | 21.76 GB |                0.0053 |                        0.0325 | same table as in UD-Q6\_K, UD-Q6\_K\_XL, UD-Q8\_K\_XL |
| `Qwen4-35B-A3B-engram-Q5_1.gguf_file`   | Q5\_1      | 15.36 GB |                0.0377 |                        0.0321 | same table as in the UD-Q5 quants                     |
| `Qwen4-35B-A3B-engram-IQ4_NL.gguf_file` | IQ4\_NL    | 11.52 GB |                0.0758 |                        0.0334 | same table as in UD-IQ1\_S up to UD-Q4\_K\_XL         |

</details>

The table holds 20.5B values (`per_layer_token_embd.weight`, 128 x 160,003,584). Relative RMSE is the root-mean-square error of a dequantized row divided by the RMS of the same BF16 row, median over 3,000 random rows. The Q8\_0, Q5\_1 and IQ4\_NL files are byte for byte the second file of the quants in the notes column, except for three split-numbering header integers, so for example UD-Q4\_K\_XL with the IQ4\_NL file gives exactly the same output as UD-Q4\_K\_XL alone. The files end in `.gguf_file` so tools that scan the repo for models do not pick them up.

The KLD column is UD-Q4\_K\_XL run with each table (llama-perplexity `--kl-divergence` on 8,192 tokens of WikiText-2, about ±0.0014 each; UD-Q4\_K\_XL alone measures 0.0334, the same as with the IQ4\_NL table). The four tables are within that noise of each other on this text: most of UD-Q4\_K\_XL's error comes from the rest of the model, so a more precise table helps at most slightly. The table rows are 128 values wide and K-quants need multiples of 256, so the table cannot be stored as Q5\_K or Q6\_K; Q5\_1 and Q8\_0 are the types llama.cpp itself falls back to.

The most useful swaps are a more precise table for a small quant (for example UD-Q4\_K\_XL with the Q8\_0 or BF16 table), or a smaller table for a large quant when system RAM is tight (for example UD-Q8\_K\_XL with the IQ4\_NL table). **Unsloth Desktop** picks up these tables automatically, lets you choose the table precision for each quant, and skips the quant's own table file when you choose another one.

**Switch the engram with `--ple`**

Any llama.cpp build with Qwen4 support (#33626 onwards) has `--ple`. Download the quant without its table file, download the table you want, and add `--ple`. Example: UD-Q4\_K\_XL with the Q8\_0 table (skips the 11.5 GB IQ4\_NL table file):

```bash
hf download unsloth/Qwen4-35B-A3B-GGUF --include "UD-Q4_K_XL/*" "engram/*Q8_0*" \
    --exclude "UD-Q4_K_XL/*-00002-of-00002.gguf" --local-dir Qwen4-35B-A3B-GGUF
./llama.cpp/build/bin/llama-server -m Qwen4-35B-A3B-GGUF/UD-Q4_K_XL/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf \
    --ple Qwen4-35B-A3B-GGUF/engram/Qwen4-35B-A3B-engram-Q8_0.gguf_file \
    -ngl 999 -fa on --jinja -c 32768 \
    --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU \
    --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0
```

With `--ple` the quant's own table file may be missing (with `-v`, the log shows `GGUF split ... not found, assuming it only holds the per-layer embedding table`; if the file is present, it is skipped). Without `--ple`, the quant needs its own table file and fails to start if it is gone. `-ot per_layer_token_embd=CPU` places the table on the CPU side. With mmap and lazy loading, rows can be read on demand from disk instead of allocating VRAM for the entire table.

**Switch the engram by hand with `set_split.py`**

For builds without `--ple`, stamp the table as file **2 of 2** and put it in the table file's place. `set_split.py` (in the `engram/` folder, plain Python, no dependencies) changes the two split header values in place in milliseconds. Example: UD-Q6\_K\_XL with the lossless BF16 table:

{% code expandable="true" %}

```bash
# 1. the quant without its table file, the BF16 table and the script
hf download unsloth/Qwen4-35B-A3B-GGUF --include "UD-Q6_K_XL/*" "engram/*BF16*" "engram/set_split.py" \
    --exclude "UD-Q6_K_XL/*-00002-of-00002.gguf" --local-dir Qwen4-35B-A3B-GGUF
cd Qwen4-35B-A3B-GGUF

# 2. stamp it as file 2 of 2
python engram/set_split.py engram/Qwen4-35B-A3B-engram-BF16.gguf_file 2 2

# 3. put it in the table file's place
mv engram/Qwen4-35B-A3B-engram-BF16.gguf_file UD-Q6_K_XL/Qwen4-35B-A3B-UD-Q6_K_XL-00002-of-00002.gguf

# 4. run as usual
../llama.cpp/build/bin/llama-server -m UD-Q6_K_XL/Qwen4-35B-A3B-UD-Q6_K_XL-00001-of-00002.gguf
```

{% endcode %}

If you already downloaded the quant's own table file, move it aside first (for example to `UD-Q6_K_XL/engram-Q8_0.bak`). Every quant uses slot `2 2`.

### MLX Run on Mac

[**unsloth/Qwen4-35B-A3B-MLX-4bit**](https://huggingface.co/unsloth/Qwen4-35B-A3B-MLX-4bit) is a **34.0 GB** MLX 4-bit quant: routed experts and the engram tables in 4-bit (the experts' down projection in 5-bit), every other layer in 8-bit, and the MoE router kept in BF16. It is text only (no vision encoder and no MTP head); use the GGUF for images or MTP.

**Unsloth Desktop on Mac** loads this repo directly: its MLX backend registers Qwen4 MoE (`model_type` `qwen4_moe`) on the `qwen4_exp` implementation that mlx-lm and mlx-vlm already ship. With plain **mlx-lm**, which does not know the `qwen4_moe` model type yet, use Unsloth's patch module `mlx_qwen4_moe.py` (in the Unsloth repo under `studio/backend/core/inference/`, it only needs mlx-lm). Put it next to your script, then:

{% code expandable="true" %}

```python
from mlx_qwen4_moe import patch_qwen4_moe
patch_qwen4_moe()

from mlx_lm import load, generate
from mlx_lm.sample_utils import make_sampler

model, tokenizer = load("unsloth/Qwen4-35B-A3B-MLX-4bit")
messages = [{"role": "user", "content": "Give me a short introduction to large language models."}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=True)
sampler = make_sampler(temp=1.0, top_p=0.95, top_k=20, min_p=0.0)
print(generate(model, tokenizer, prompt=prompt, max_tokens=4096, sampler=sampler, verbose=True))
```

{% endcode %}

Set `enable_thinking=False` for non-thinking mode. Loaded with mlx-lm, the same weights answered math, code, tool-calling and long-form prompts correctly with thinking on and off in our checks.

**Speed on a MacBook Pro M5 Max** (128 GB, mlx 0.32.5, 128 generated tokens):

| Prompt length | Prefill (tokens/s) | Decode (tokens/s) | Peak memory |
| ------------: | -----------------: | ----------------: | ----------: |
|           512 |              2,711 |                75 |     35.0 GB |
|         4,096 |              3,977 |                69 |     36.2 GB |

##### MLX quantization analysis

![Mean KLD vs size for Unsloth MLX 4-bit and standard MLX 4-bit](https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FRalqHdzHJFl6NUhMxjiR%2Fqwen4-mlx-kld-vs-gguf-r2.png?alt=media)

The plot compares Unsloth MLX 4-bit with a standard `mlx_lm.convert -q` conversion. All 21 Unsloth Dynamic GGUFs are shown for reference, with their MTP head excluded from file size.

Same 11 evaluation sets, BF16 reference outputs and scoring as the GGUF results below (chat sets score the assistant turns). 99th pct KLD is over all scored tokens, and PPL vs BF16 is the mean change in perplexity on the same text. The MLX card reports only these averages, not per-set numbers. Our MLX 4-bit has **87% lower mean KLD** than a standard `mlx_lm.convert -q` 4-bit conversion, beats `UD-IQ4_NL` at a similar size and is on par with `UD-Q4_K_S`.

<details>

<summary>Click to reveal full MLX quant breakdown table:</summary>

| Model                              | Format |    Size |   Mean KLD | 99th pct KLD | Top-1 agreement | PPL vs BF16 |
| ---------------------------------- | ------ | ------: | ---------: | -----------: | --------------: | ----------: |
| **Unsloth MLX 4-bit**              | MLX    | 34.0 GB | **0.0432** |    **0.620** |      **92.80%** |  **+3.94%** |
| Standard `mlx_lm.convert -q` 4-bit | MLX    | 31.3 GB |     0.3356 |        3.316 |          79.44% |     +21.04% |
| GGUF UD-IQ4\_NL (reference)        | GGUF   | 32.5 GB |     0.0474 |        0.689 |          92.34% |      +3.83% |
| GGUF UD-Q4\_K\_S (reference)       | GGUF   | 33.6 GB |     0.0429 |        0.632 |          92.72% |      +3.56% |
| GGUF UD-Q4\_K\_M (reference)       | GGUF   | 34.6 GB |     0.0387 |        0.574 |          93.20% |      +3.59% |
| GGUF UD-Q4\_K\_XL (reference)      | GGUF   | 35.6 GB |     0.0375 |        0.543 |          93.20% |      +3.49% |

</details>

GGUF sizes in this table exclude the MTP head. The MLX rows were scored with llama.cpp on a GGUF copy of each MLX pack that carries the pack's 4-bit codes, scales and offsets unchanged (rounded to fp16) and its 8-bit layers dequantized to F16. Our MLX loader also matches the reference transformers implementation on a tiny random model (fp32 mean KL 2.9e-11, 100% top-1 agreement).

### Qwen4 Benchmarks

#### Quantization Benchmarks

Our 4-bit `UD-Q4_K_XL` scored **95.0%** across GSM8K, MATH-500, CRUXEval-O and MMLU-Pro, compared with **95.3%** for BF16. We tested 300 questions with four samples per question and thinking enabled. Differences of about one percentage point are within run-to-run noise.

![Top-1 agreement versus GGUF download size](https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FxywviZDEPXkNThXieoQG%2Fqwen4-top1-vs-size.png?alt=media)

| Quant        | Accuracy | Top-1 agreement | Mean KLD | Prefill (tok/s) | Decode (tok/s) |
| ------------ | -------: | --------------: | -------: | --------------: | -------------: |
| `UD-IQ1_S`   |    89.6% |          80.10% |   0.3008 |           6,887 |          168.2 |
| `UD-IQ2_XS`  |    93.8% |          85.42% |   0.1616 |           6,647 |          162.4 |
| `UD-Q3_K_XL` |    94.0% |          91.39% |   0.0569 |           6,606 |          170.6 |
| `UD-IQ4_XS`  |    95.2% |          91.83% |   0.0532 |           6,148 |          172.3 |
| `UD-Q4_K_XL` |    95.0% |          93.20% |   0.0375 |           7,533 |          167.3 |
| `UD-Q6_K_XL` |    94.9% |          94.52% |   0.0247 |           7,119 |          167.9 |
| `UD-Q8_K_XL` |    94.8% |          95.49% |   0.0171 |           7,727 |          152.5 |

Top-1 agreement measures how often the quant and BF16 pick the same next token. Lower mean KLD means the quant’s next-token probabilities are closer to BF16. Speed was measured with `llama-bench` on one NVIDIA B200 with the engram on CPU, using a 4,096-token prompt for prefill and 128 generated tokens for decode. See the [GGUF model card](https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF#quants) for all quant results.

#### Quantization Analysis

Mean KLD is the KL divergence from the BF16 model averaged over **11 evaluation sets** (Wikipedia, chat, code, math, agentic tool use, Chinese, Japanese, French, mixed web text, multilingual chat and 32K-token documents). Top-1 agreement is the share of positions where the quant's most likely next token matches BF16, averaged over the same 11 sets. Lower KLD and higher top-1 are better. The first two plots use the download size (both files, including the MTP head).

![Mean KLD vs GGUF download size](https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FXZGhV47EU6H5cWpgYtID%2Fqwen4-kld-vs-size.png?alt=media)

![Top-1 agreement vs GGUF download size](https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FxywviZDEPXkNThXieoQG%2Fqwen4-top1-vs-size.png?alt=media)

![Mean KLD vs GGUF size without the engram](https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FD61HFcbMnjadLQDftcmt%2Fqwen4-kld-vs-size-no-engram.png?alt=media)

![Top-1 agreement vs GGUF size without the engram](https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FkqeDrc96PPtGTo6pMQdJ%2Fqwen4-top1-vs-size-no-engram.png?alt=media)

The last two plots use only the first file (model weights and the MTP head). This is closer to what must fit in memory when the engram stays on disk.

**Accuracy** is mean correctness on 300 questions from GSM8K, MATH-500, CRUXEval-O and MMLU-Pro, 4 samples each, thinking on, official sampling settings, run with llama.cpp. BF16 scores **95.3%**; the value in brackets is the difference from BF16 in points. Differences smaller than about 1 point are within run-to-run noise. Speed is llama-bench (`-fa on`, engram on CPU, 5 repeats) on one NVIDIA B200; repeated runs vary by about 2% for tg128 and up to about 20% for pp4096.

<details>

<summary>Click for the full quant table</summary>

**Engram table** is the precision and size of the table in the quant's second file. **MoE total size** counts routed experts, shared experts and routers. **Download size** is both files. **Weights with engram on disk** is the first file, including the MTP head that llama.cpp only loads with `--spec-type draft-mtp`.

| Quant        | Engram table      | MoE total size | Download size | Weights with engram on disk | Mean KLD | Top-1 agreement | Accuracy (vs BF16) | pp4096 (t/s) | tg128 (t/s) |
| ------------ | ----------------- | -------------: | ------------: | --------------------------: | -------: | --------------: | -----------------: | -----------: | ----------: |
| UD-IQ1\_S    | IQ4\_NL / 11.5 GB |         7.6 GB |       21.3 GB |                      9.8 GB |   0.3008 |          80.10% |       89.6% (-5.8) |         6887 |       168.2 |
| UD-IQ1\_M    | IQ4\_NL / 11.5 GB |         8.6 GB |       22.3 GB |                     10.8 GB |   0.2458 |          81.99% |       93.4% (-1.9) |         6697 |       165.9 |
| UD-IQ2\_XXS  | IQ4\_NL / 11.5 GB |         9.5 GB |       23.4 GB |                     11.9 GB |   0.1935 |          84.00% |       93.6% (-1.8) |         6942 |       165.0 |
| UD-IQ2\_XS   | IQ4\_NL / 11.5 GB |        10.4 GB |       24.5 GB |                     13.0 GB |   0.1616 |          85.42% |       93.8% (-1.6) |         6647 |       162.4 |
| UD-IQ2\_S    | IQ4\_NL / 11.5 GB |        11.6 GB |       25.5 GB |                     14.0 GB |   0.1312 |          86.80% |       94.7% (-0.7) |         6431 |       157.3 |
| UD-IQ2\_M    | IQ4\_NL / 11.5 GB |        12.6 GB |       26.6 GB |                     15.1 GB |   0.1084 |          88.00% |       94.3% (-1.0) |         6511 |       156.9 |
| UD-Q2\_K\_XL | IQ4\_NL / 11.5 GB |        13.4 GB |       27.7 GB |                     16.2 GB |   0.0928 |          88.98% |       94.8% (-0.6) |         6588 |       159.0 |
| UD-IQ3\_XXS  | IQ4\_NL / 11.5 GB |        14.4 GB |       28.7 GB |                     17.2 GB |   0.0760 |          89.96% |       94.8% (-0.5) |         6881 |       163.1 |
| UD-IQ3\_S    | IQ4\_NL / 11.5 GB |        15.7 GB |       29.8 GB |                     18.3 GB |   0.0664 |          90.66% |       94.7% (-0.7) |         6561 |       168.0 |
| UD-Q3\_K\_XL | IQ4\_NL / 11.5 GB |        16.4 GB |       30.9 GB |                     19.4 GB |   0.0569 |          91.39% |       94.0% (-1.3) |         6606 |       170.6 |
| UD-IQ4\_XS   | IQ4\_NL / 11.5 GB |        17.7 GB |       32.0 GB |                     20.5 GB |   0.0532 |          91.83% |       95.2% (-0.1) |         6148 |       172.3 |
| UD-IQ4\_NL   | IQ4\_NL / 11.5 GB |        18.5 GB |       33.1 GB |                     21.6 GB |   0.0474 |          92.34% |       95.0% (-0.3) |         7075 |       171.8 |
| UD-Q4\_K\_S  | IQ4\_NL / 11.5 GB |        19.5 GB |       34.2 GB |                     22.7 GB |   0.0429 |          92.72% |       94.5% (-0.8) |         6159 |       171.4 |
| UD-Q4\_K\_M  | IQ4\_NL / 11.5 GB |        20.4 GB |       35.2 GB |                     23.7 GB |   0.0387 |          93.20% |       94.4% (-0.9) |         7450 |       169.7 |
| UD-Q4\_K\_XL | IQ4\_NL / 11.5 GB |        21.6 GB |       36.2 GB |                     24.7 GB |   0.0375 |          93.20% |       95.0% (-0.3) |         7533 |       167.3 |
| UD-Q5\_K\_S  | Q5\_1 / 15.4 GB   |        22.3 GB |       41.3 GB |                     25.9 GB |   0.0319 |          93.78% |        95.3% (0.0) |         6503 |       168.7 |
| UD-Q5\_K\_M  | Q5\_1 / 15.4 GB   |        23.8 GB |       42.4 GB |                     27.0 GB |   0.0292 |          94.00% |       95.2% (-0.2) |         6849 |       169.1 |
| UD-Q5\_K\_XL | Q5\_1 / 15.4 GB   |        24.4 GB |       43.2 GB |                     27.8 GB |   0.0278 |          94.20% |       95.0% (-0.3) |         6698 |       168.7 |
| UD-Q6\_K     | Q8\_0 / 21.8 GB   |        25.5 GB |       50.9 GB |                     29.2 GB |   0.0259 |          94.35% |        95.3% (0.0) |         6816 |       167.0 |
| UD-Q6\_K\_XL | Q8\_0 / 21.8 GB   |        26.6 GB |       52.2 GB |                     30.5 GB |   0.0247 |          94.52% |       94.9% (-0.4) |         7119 |       167.9 |
| UD-Q8\_K\_XL | Q8\_0 / 21.8 GB   |        34.6 GB |       62.3 GB |                     40.5 GB |   0.0171 |          95.49% |       94.8% (-0.5) |         7727 |       152.5 |

</details>

The importance matrix used for the quants is included in the repo as `imatrix_unsloth.gguf_file`.

**Choosing a quant:** `UD-IQ4_XS` and larger are within about 1 point of BF16 on accuracy. Every quant tested for vision from `UD-IQ2_M` up measured within noise of `UD-Q4_K_XL` (`UD-Q2_K_XL`, `UD-IQ3_S`, `UD-IQ4_NL` and `UD-Q4_K_S` not yet tested; 1-bit quants not tested). `UD-Q4_K_XL` is a good default. The 1-bit `UD-IQ1_S` is the smallest but loses 5.8 points of accuracy, is weaker at tool calling and thinks longer on average than the larger quants.

##### Tool Calling and Long Context

**Tool calling** is BFCL v3 AST (200 items x 2 samples, thinking on, official sampling) on an A100 80GB, compared with `UD-Q8_K_XL` paired by item (95% bootstrap CI). Tool-calling CIs are about ±3 points, so smaller differences are not resolvable.

<details>

<summary>Click for the full tool calling and long context analysis table</summary>

| Quant        | Score | vs UD-Q8\_K\_XL (points) | 95% CI        |
| ------------ | ----: | -----------------------: | ------------- |
| UD-IQ1\_S    | 0.818 |                 **-5.2** | \[-9.2, -1.8] |
| UD-IQ1\_M    | 0.840 |                     -3.0 | \[-6.5, +0.2] |
| UD-IQ2\_XXS  | 0.860 |                     -1.0 | \[-4.0, +2.0] |
| UD-IQ2\_XS   | 0.875 |                     +0.5 | \[-2.5, +3.8] |
| UD-IQ2\_S    | 0.873 |                     +0.2 | \[-2.2, +2.8] |
| UD-IQ2\_M    | 0.868 |                     -0.2 | \[-3.0, +2.5] |
| UD-Q2\_K\_XL | 0.873 |                     +0.2 | \[-2.5, +2.8] |
| UD-IQ3\_XXS  | 0.868 |                     -0.2 | \[-2.5, +1.8] |
| UD-IQ3\_S    | 0.863 |                     -0.8 | \[-3.0, +1.5] |
| UD-Q3\_K\_XL | 0.868 |                     -0.2 | \[-3.2, +2.8] |
| UD-IQ4\_XS   | 0.868 |                     -0.2 | \[-3.0, +2.2] |
| UD-IQ4\_NL   | 0.885 |                     +1.5 | \[-0.8, +4.0] |
| UD-Q4\_K\_XL | 0.863 |                     -0.8 | \[-4.0, +2.3] |
| UD-Q8\_K\_XL | 0.870 |                reference |               |

</details>

Only `UD-IQ1_S` is clearly below `UD-Q8_K_XL` (it loses on multiple and parallel calls; simple calls hold).

`UD-Q4_K_S` and `UD-Q4_K_M` were measured separately on a B200, paired against `UD-Q8_K_XL` on the same GPU (0.848), with no clear difference in this test:

| Quant       | Score | vs UD-Q8\_K\_XL (points) | 95% CI        |
| ----------- | ----: | -----------------------: | ------------- |
| UD-Q4\_K\_S | 0.853 |                     +0.5 | \[-1.2, +2.2] |
| UD-Q4\_K\_M | 0.855 |                     +0.8 | \[-1.8, +3.2] |

**Long context** is a RULER-style set (needle retrieval and variable tracking, thinking off, greedy) at 32K, 64K and 128K. `UD-Q8_K_XL` scores 1.000 at all three lengths. `UD-Q3_K_XL`, `UD-IQ4_XS` and `UD-Q4_K_XL` also score 1.000 at all three lengths, and every other quant tested at 128K scores 0.980 to 1.000. Only `UD-IQ1_S` is clearly lower when pooled over lengths (0.983, -1.7 points \[-3.9, -0.1]): at 64K it answered 3 of 13 variable-tracking chains with only the first variable, while all needle tasks were perfect. This set is at ceiling for `UD-Q8_K_XL`, so it detects breakage, not small shifts. At 128K, `UD-IQ1_M` and `UD-IQ4_NL` both score 1.000 (50/50), the same as `UD-Q8_K_XL` on the same GPU.

##### Vision

300 items (100 ChartQA relaxed accuracy, 100 DocVQA ANLS, 100 TextVQA VQA accuracy), greedy, thinking off, `mmproj-BF16`, on an A100 80GB:

<details>

<summary>Click for the full vision analysis table</summary>

| Quant        | Score | ChartQA | DocVQA | TextVQA | vs UD-Q8\_K\_XL (points) | 95% CI        |
| ------------ | ----: | ------: | -----: | ------: | -----------------------: | ------------- |
| UD-Q4\_K\_M  | 0.880 |   0.840 |  0.953 |   0.848 |                     +0.8 | \[-1.2, +2.8] |
| UD-Q4\_K\_XL | 0.880 |   0.850 |  0.942 |   0.848 |                     +0.7 | \[-1.6, +3.1] |
| UD-Q5\_K\_S  | 0.877 |   0.830 |  0.952 |   0.848 |                     +0.4 | \[-1.7, +2.5] |
| UD-Q5\_K\_M  | 0.888 |   0.840 |  0.968 |   0.855 |                     +1.5 | \[-0.5, +3.7] |
| UD-Q5\_K\_XL | 0.868 |   0.830 |  0.939 |   0.835 |                     -0.4 | \[-2.9, +2.0] |
| UD-Q6\_K     | 0.883 |   0.850 |  0.954 |   0.844 |                     +1.0 | \[-1.1, +3.1] |
| UD-Q6\_K\_XL | 0.874 |   0.830 |  0.933 |   0.859 |                     +0.2 | \[-1.9, +2.2] |
| UD-Q8\_K\_XL | 0.873 |   0.830 |  0.947 |   0.841 |                reference |               |

</details>

All 4-bit and larger quants tested are within noise of `UD-Q8_K_XL` on vision.

**Below 4-bit** (same 300 items, on a T4, each quant paired against `UD-Q4_K_XL` on the same machine):

| Quant        | Score | vs UD-Q4\_K\_XL (points)          |
| ------------ | ----: | --------------------------------- |
| UD-IQ2\_M    | 0.877 | +0.6                              |
| UD-IQ3\_XXS  | 0.891 | +1.5                              |
| UD-Q3\_K\_XL | 0.876 | +1.6                              |
| UD-IQ4\_XS   | 0.855 | -2.4 (a repeat run measured +0.1) |

The `UD-Q4_K_XL` reference itself varied from 0.860 to 0.879 across machines, so these results don't establish a consistent difference from `UD-Q4_K_XL`. `UD-Q2_K_XL`, `UD-IQ3_S`, `UD-IQ4_NL` and `UD-Q4_K_S` vision results are **pending**.

##### Speed on Consumer Devices

llama-bench tg128 (decode tokens/s, `-fa 1 -ngl 999 -ot per_layer_token_embd=CPU`, 3 repeats) on mainline llama.cpp:

<details>

<summary>Click for the full speed analysis table</summary>

| Quant        | RTX 5090 (32 GB) | Mac M5 Max (128 GB) | RTX Spark (128 GB) |
| ------------ | ---------------: | ------------------: | -----------------: |
| UD-IQ1\_S    |            200.2 |             pending |            pending |
| UD-IQ1\_M    |            211.7 |               110.7 |            pending |
| UD-IQ2\_XXS  |            203.6 |               103.7 |               78.5 |
| UD-IQ2\_M    |            186.7 |             pending |            pending |
| UD-Q2\_K\_XL |            185.8 |                93.0 |               68.4 |
| UD-IQ3\_XXS  |            197.7 |             pending |            pending |
| UD-Q3\_K\_XL |            195.7 |                92.4 |            pending |
| UD-IQ4\_XS   |   165.4 (note 1) |                98.8 |               69.6 |
| UD-Q4\_K\_M  |            190.0 |             pending |            pending |
| UD-Q4\_K\_XL |            192.3 |                91.7 |               65.5 |
| UD-Q5\_K\_XL |            186.1 |                90.5 |            pending |
| UD-Q6\_K\_XL |   160.4 (note 2) |                89.2 |            pending |

</details>

1. One of the three RTX 5090 repeats for `UD-IQ4_XS` was slow (199.2 / 100.3 / 196.7).
2. `UD-Q6_K_XL` does not fit in 32 GB of VRAM, so part of it runs from system RAM.

On the RTX 5090 most rows ran while the next quant was downloading. `UD-Q8_K_XL` does not fit the RTX 5090's 32 GB and was not run. The RTX Spark ran on battery. Prompt processing numbers on consumer devices are **pending** a clean re-run.

All three devices passed text with thinking on and off, tool calls (streaming and round trip), vision with `mmproj-BF16`, MTP and `--load-mode mmap --lazy-mode on` on mainline llama.cpp.

##### Official Benchmarks

These are Qwen's official results, separate from the GGUF tests above.

<figure><img src="https://content.gitbook.com/content/xhOjnexMCB3dmuQFQ2Zq/blobs/L1Dq9mZ0L4mKS1U691oz/qwen4-35b-a3b-official-benchmarks.png" alt="" width="563"><figcaption></figcaption></figure>

| Benchmark           | Qwen4-35B-A3B | Qwen3.8-Flash-Next | Qwen3.8-27B | Inkling2 Mini |
| ------------------- | ------------: | -----------------: | ----------: | ------------: |
| Terminal Bench 4.1  |      **21.2** |               24.2 |         5.6 |           5.6 |
| DeepSWE v1.1        |      **61.8** |               58.7 |        42.2 |          48.2 |
| FrontierCode-AA 2.0 |      **16.1** |               27.1 |        14.9 |          15.1 |
| NL2Repo             |      **51.7** |               48.1 |        42.3 |          41.8 |
| APEX Agents v1.1    |      **59.0** |               61.0 |        47.5 |          50.9 |

<details>

<summary>Show more benchmarks</summary>

| Benchmark                | Qwen4-35B-A3B | Qwen3.8-Flash-Next | Qwen3.8-27B | Inkling2 Mini |
| ------------------------ | ------------: | -----------------: | ----------: | ------------: |
| Work360                  |      **42.9** |               43.7 |        37.1 |          30.4 |
| AA-Briefcase v1.1 (Elo)  |      **1486** |               1567 |        1391 |          1263 |
| AutomationBench-AA       |      **57.9** |               55.9 |        48.2 |          41.8 |
| HealthBench Professional |      **47.4** |               34.8 |        29.8 |          45.7 |
| GPQA                     |      **86.9** |               91.7 |        89.2 |          86.9 |
| Chartography             |      **27.8** |               24.6 |        27.8 |          22.1 |
| VideoIndex               |      **52.9** |               51.4 |        51.9 |          44.0 |

</details>

Source scores and evaluation notes are in the [Qwen4 benchmark results](https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF#benchmark-results).

##### About Qwen4-35B-A3B

From Qwen's model card:

* **Architecture:** 40 layers in a hybrid of Gated DeltaNet linear attention and Qwen Sparse Attention (10 x (3 x Gated DeltaNet + 1 x Sparse Attention), each followed by MoE), hidden size 2048, 248,320 token vocabulary.
* **MoE:** 256 experts, 8 routed + 1 shared active, expert intermediate size 512.
* **Parameters:** 35B with 3B active, plus a 20B n-gram embedding (10,000,000 bigram / trigram entries at layer 2) and a 2B MTP layer trained with multiple steps.
* **Context:** 1,048,576 tokens natively. Inputs: text, image and video.
* **Long video:** Qwen recommends raising `longest_edge` in `video_preprocessor_config.json` to 469,762,048 (about 224K video tokens) for hour-scale videos.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/models/qwen4.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
