# How to run Qwen 4 locally with llama.cpp, Unsloth or vLLM

> Qwen4-35B-A3B keeps a 20B lookup table on your SSD, so a 4-bit build needs 21 to 25 GB of memory and a 3-bit one about 18 GB.

URL: https://claudegpt.si/news/qwen-4-how-to-run-locally  
Published: 2026-12-04T02:58:25.985Z  
Author: ClaudeGPT Si Newsroom  
Section: Guides  
Topics: Qwen, Alibaba, Open-weight models, Local AI, Hugging Face, How to  
Publisher: ClaudeGPT Si

## Key takeaways

- Qwen4-35B-A3B is on Hugging Face under the Apache 2.0 license, published December 3, 2026.
- Its 20B n-gram table can stay on SSD, so Unsloth's 4-bit GGUF builds need 20.5 to 24.7 GB of memory for weights and its 3-bit build 17.2 GB.
- llama.cpp, Unsloth Desktop, MLX and vLLM all have documented commands; the Ollama page the model card links to returned a 404 on December 4.

To run Qwen 4 locally, download a GGUF build of Qwen4-35B-A3B from Hugging Face and start it with llama.cpp or the Unsloth Desktop app. A 4-bit file needs about 21 to 25 GB of memory, and Unsloth says its 3-bit build runs in about 18 GB. Qwen published the weights on December 3, 2026 under the Apache 2.0 license, so the download is free and needs no sign-up.

This guide follows the [Qwen4-35B-A3B model card](https://huggingface.co/Qwen/Qwen4-35B-A3B), the [Hugging Face launch post](https://huggingface.co/blog/qwen4), [Unsloth's run guide](https://unsloth.ai/docs/models/qwen4) and the [vLLM recipe](https://recipes.vllm.ai/Qwen/Qwen4-35B-A3B), as read on December 4, 2026. The commands were not run for this guide. They are copied from those pages. What the release means is in [our news article on the open weights](https://claudegpt.si/news/qwen4-35b-a3b-open-weights).

## Why a 56B-parameter model fits on a 24 GB machine

The name says 35B, but the files hold more. The model card lists 35B parameters with 3B active for each token, plus a 20B n-gram embedding table and a 2B multi-token prediction (MTP) head, a small extra layer that drafts tokens ahead to speed up output. Hugging Face counts about 56B in total.

The 20B table is what makes the memory numbers odd. It is a lookup table: each token reads 16 rows of it, according to the Hugging Face post. So the table can stay on your SSD and be read row by row, and only the rest of the model has to sit in RAM or VRAM. Unsloth calls the table the "engram". The Hugging Face post calls it PLE, for per-layer embedding. They are the same thing.

That is why every size below comes as two numbers: what you download, and what has to fit in memory. Budget for the second one, and put the files on a fast SSD.

## Which Qwen 4 file to download

| Build | Download | Memory for weights | Source says it fits |
| --- | --- | --- | --- |
| Unsloth UD-IQ3_XXS (3-bit GGUF) | 28.7 GB | 17.2 GB | an 18 GB device, short context |
| Unsloth UD-IQ4_XS (4-bit GGUF) | 32.0 GB | 20.5 GB | a 24 GB device |
| Unsloth UD-Q4_K_XL (4-bit GGUF) | 36.2 GB | 24.7 GB | Unsloth's "good default" |
| ggml-org Q4_K_M (GGUF) | 36.0 GB | 21.9 GB | a 32 GB Mac |
| ggml-org Q6_K (GGUF) | 51.0 GB | 29.2 GB | a 48 GB Mac |
| ggml-org Q8_0 (GGUF) | 59.4 GB | 37.6 GB | a 64 GB Mac |
| Unsloth MLX 4-bit (text only) | 34.0 GB | about 35 to 36 GB peak, measured on an M5 Max | Apple Silicon |
| Qwen FP8 (safetensors, for vLLM) | about 60 GB | 39.7 GB on the GPU plus 20.5 GB of host RAM | one H100 |
| Qwen BF16 (safetensors) | about 114 GB | 72.7 GB on the GPU plus 41 GB of host RAM | the recipe lists H200 and Blackwell cards |

The GGUF figures come from [Unsloth's repository](https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF) and the [ggml-org repository](https://huggingface.co/ggml-org/Qwen4-35B-A3B-GGUF), the vLLM figures from the recipe, and the two safetensors download sizes from the file lists of Qwen's own repositories. Unsloth warns that its memory column is a starting point. Context, compute buffers and the vision projector need room on top.

Quality drops slowly until the smallest files. In Unsloth's own test of 300 questions, the full BF16 model scored 95.3%, UD-Q4_K_XL scored 95.0% and UD-IQ4_XS 95.2%. The 1-bit UD-IQ1_S fell to 89.6% and was weaker at tool calling. Unsloth says gaps of about one point are noise.

## Option 1: llama.cpp, for most desktops and laptops

You need a current build. Unsloth's guide says Qwen4 support is in mainline llama.cpp, and tells you to build the latest `master`:

```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
```

Use `-DGGML_CUDA=OFF` for a CPU-only machine or a Mac. Metal is on by default there.

Then start the server. The `-hf` flag downloads both files of the build and the vision projector:

```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
```

The third line is the part that keeps the 20B table on disk and reads it on demand. On a 24 GB machine, swap `UD-Q4_K_XL` for `UD-IQ4_XS`. On 18 GB, use `UD-IQ3_XXS` and a shorter context.

Open `http://localhost:8080` to chat.

The Hugging Face post gives a shorter route through the Llama App command line, using the ggml-org files:

```bash
llama serve -hf ggml-org/Qwen4-35B-A3B-GGUF:Q6_K
```

The ggml-org card says that under llama.cpp's default lazy mode the table stays on disk without extra flags.

### Turn on MTP for more speed

Every Unsloth GGUF has the MTP head built in. Add two flags to the server command:

```bash
--spec-type draft-mtp --spec-draft-n-max 2
```

Unsloth measured about 1.2x to 1.3x faster output on an RTX 5090 and an M5 Max, and recommends a draft depth of 2. If the model doesn't fit in VRAM and part of it runs from system RAM, it recommends depth 1. Hugging Face used depth 3 with the ggml-org files and reports a 22% gain on an M5 Mac. The ggml-org repository ships the head as a separate file, which the same flags download.

## Option 2: Unsloth Desktop, if you don't want a terminal

Unsloth Desktop is an open-source app for macOS, Windows and Linux. Its guide gives three steps:

1. Install the app from [unsloth.ai/download](https://unsloth.ai/download), or with `brew install --cask unsloth` on a Mac or `winget install --id UnslothAI.Unsloth -e` on Windows.
2. Search the model hub for `unsloth/Qwen4-35B-A3B-GGUF` and download a build from the table above.
3. Select it in Chat and start with a context of 32,768 tokens.

Unsloth says the app decides by itself whether the table goes in RAM or stays on the SSD, and sets the sampling values.

## Option 3: MLX on a Mac

Unsloth's `Qwen4-35B-A3B-MLX-4bit` is a 34.0 GB build for Apple's MLX framework. It is text only, with no vision encoder and no MTP head. On a MacBook Pro M5 Max with 128 GB it decoded at 69 to 75 tokens per second in Unsloth's test. Plain mlx-lm doesn't know the model type yet, so Unsloth's guide has you load a patch module first. If you want images, use a GGUF.

The Hugging Face post also points to oMLX builds from mlx-community and says mlx-lm support is "on its way to the official repository".

## Option 4: vLLM, for a server GPU

This is the route for serving several users or a coding agent, and it needs data center hardware. The vLLM recipe says the FP8 checkpoint fits on one H100. It takes 39.7 GB on the GPU and 20.5 GB of host RAM for the table.

```bash
export VLLM_USE_RUST_FRONTEND=1
vllm serve Qwen/Qwen4-35B-A3B-FP8 \
  --trust-remote-code \
  --enable-prefix-caching \
  --tensor-parallel-size 1 \
  --max-model-len auto \
  --disable-flashinfer-autotune \
  --kv-cache-dtype nvfp4 \
  --attention-config.indexer_kv_dtype fp8 \
  --enable-auto-tool-choice \
  --tool-call-parser qwen4 \
  --reasoning-parser qwen4 \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3,"index_share_for_mtp_iteration":true}'
```

The recipe names the `vllm/vllm-openai:qwen4` Docker image for NVIDIA cards. `--max-model-len auto` uses the full 1M-token window if the cache fits and lowers it if not.

## Check that it works

Both servers speak the OpenAI API. The model card's test uses the OpenAI Python SDK:

```bash
pip install -U openai
export OPENAI_BASE_URL="http://localhost:8000/v1"
export OPENAI_API_KEY="EMPTY"
```

Port 8000 is vLLM's. For llama.cpp, use 8080. Then call `client.chat.completions.create` with a short message.

## Settings Qwen recommends

Thinking is on by default at `reasoning_effort="high"`. The other levels are `xhigh`, `low` and `off`.

| Setting | Thinking | Non-thinking |
| --- | --- | --- |
| temperature | 1.0 | 0.7 |
| top_p | 0.95 | 0.80 |
| top_k | 20 | 20 |
| presence_penalty | 0.0 | 1.5 |

The card warns that a lower effort is not always faster in agent work, because it can cause more failures and retries.

## Common problems

### HTTP 500 when you turn thinking off in llama-server

Unsloth reproduced this on three machines. Sending `reasoning_effort: "off"` inside `chat_template_kwargs` conflicts with the server's default and fails with "Conflicting thinking settings". Send `reasoning_effort` as a top-level field, or start the server with `--reasoning off`.

### vLLM wants "none", not "off"

The vLLM recipe uses `reasoning_effort="none"` to disable thinking.

### The first prompt is slow

The table is read from disk the first time. Unsloth measured prompt processing at about 750 tokens per second on a cold run and about 8,300 once the table was cached, on an RTX 5090. Send a short warm-up prompt.

### Only one of the two files is there

Each Unsloth build is two files in one folder. Keep both together and point `-m` at the one ending `-00001-of-00002.gguf`.

## What isn't confirmed yet

Ollama is the open question. The model card links to `ollama.com/library/qwen4`, but that page returned a 404 error on December 4, so there is no tag to give here. The card also says the hosted API will come to Qwen Cloud "soon" under the name `qwen4-35b-a3b`, with no date. [Qwen Cloud's page for the model](https://www.qwencloud.com/models/qwen4-35b-a3b) already listed a price on December 4: $0.06 per million input tokens and $0.36 per million output tokens.

One number differs between sources. Qwen's card says 3B parameters are active per token. The Hugging Face post says about 3.8B.

If you ran the previous model, the setup in [our Qwen 3.8 guide](https://claudegpt.si/news/qwen-3-8-how-to-run-locally) still applies to that one. The new parts here are the on-disk table and the built-in MTP head. Start with UD-IQ4_XS or UD-Q4_K_XL, 32,768 tokens of context, and check the Ollama page again in a few days.

## Frequently asked questions

### Is Qwen 4 open weight?

Qwen4-35B-A3B is. Qwen published its weights on Hugging Face on December 3, 2026 under the Apache 2.0 license, and the repository is not gated. The model card describes Qwen4-Max as the flagship of the series and links no weights for it.

### Is Qwen 4 free?

The Qwen4-35B-A3B weights are free to download and run on your own hardware under Apache 2.0. The model card says a hosted API will come to Qwen Cloud soon and gives no date.

### How much RAM or VRAM does Qwen4-35B-A3B need?

With the n-gram table left on disk, Unsloth lists 17.2 GB for its 3-bit UD-IQ3_XXS build, 20.5 GB for UD-IQ4_XS and 24.7 GB for UD-Q4_K_XL, before context. The ggml-org card says its Q4_K_M file runs on a 32 GB Mac. For vLLM, the FP8 checkpoint takes 39.7 GB on the GPU plus 20.5 GB of host RAM.

### Where is Qwen 4 on Hugging Face?

The original weights are at Qwen/Qwen4-35B-A3B, with an FP8 version at Qwen/Qwen4-35B-A3B-FP8. GGUF files for llama.cpp are at unsloth/Qwen4-35B-A3B-GGUF and ggml-org/Qwen4-35B-A3B-GGUF.

## Sources

- [Qwen4-35B-A3B model card](https://huggingface.co/Qwen/Qwen4-35B-A3B), Qwen
- [Qwen4-35B-A3B-FP8 model card](https://huggingface.co/Qwen/Qwen4-35B-A3B-FP8), Qwen
- [Welcome Qwen 4: Cutting-edge intelligence on-device](https://huggingface.co/blog/qwen4), Hugging Face
- [Qwen4 35B-A3B: How to Run Locally](https://unsloth.ai/docs/models/qwen4), Unsloth
- [unsloth/Qwen4-35B-A3B-GGUF](https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF), Unsloth
- [ggml-org/Qwen4-35B-A3B-GGUF](https://huggingface.co/ggml-org/Qwen4-35B-A3B-GGUF), ggml-org
- [Qwen/Qwen4-35B-A3B vLLM recipe](https://recipes.vllm.ai/Qwen/Qwen4-35B-A3B), vLLM
