7 min read

How to run Qwen4-35B-A3B locally

Unsloth suggests its 4-bit GGUF for 24 GB devices with the embedding table on SSD. Qwen4 leads the dense Qwen3.8-27B by 19.6 points on DeepSWE v1.1.
Qwen4-35B-A3B 4-bit GGUF on an example 24 GB machine: the 20.52 GB model shard stays in memory, and the 11.52 GB embedding table is read from SSD on demand.

Qwen released Apache 2.0 weights for Qwen4-35B-A3B on December 4. The 4-bit GGUF used here takes about 32 GB on disk before the vision projector. Unsloth suggests starting with that quant on a 24 GB GPU or a Mac with 24 GB of unified memory. Reading the embedding table from SSD on demand reduces the amount that needs to stay in memory.

The guide covers which quant fits your machine, how Qwen4 compares with Qwen3.8, and how to connect Qwen Code to the local server.

What goes on disk and what goes in memory?

Qwen's model card lists 35 billion parameters in the main mixture-of-experts (MoE) model, with about 3 billion active per token. It also lists a 20-billion-parameter n-gram embedding table and a 2-billion-parameter multi-token prediction (MTP) component. The first GGUF shard contains the main weights and the optional MTP draft head. The second holds the embedding table. A compatible runtime can keep the table in RAM or read the entries it needs from SSD.

The 20.52 GB first UD-IQ4_XS shard holds the 35B model and optional 2B MTP head. The 11.52 GB second shard holds the 20B embedding table, which can stay in RAM or be read from SSD on demand.

Both shards count toward the download, even when the second stays on disk.

The official checkpoint repository is 114 GB. The quantized GGUFs below are smaller and each ships in two shards, including the same 11.52 GB embedding table. For UD-IQ4_XS, the first shard is 20.52 GB. The download totals come from adding the file sizes in bytes and converting to decimal GB.

Unsloth quant Disk for both shards When to try it
3-bit UD-IQ3_XXS 28.74 GB Unsloth suggests 18 GB total memory with a short context
4-bit UD-IQ4_XS 32.04 GB Unsloth's starting point for a 24 GB GPU or 24 GB of Apple unified memory
4-bit UD-Q4_K_XL 36.24 GB Try with more memory headroom. The first shard alone is 24.72 GB on disk

Unsloth uses UD-Q4_K_XL in its general llama.cpp example. For the 24 GB setup here, use UD-IQ4_XS. In Unsloth's 300-question test across math, code and knowledge benchmarks with thinking enabled, UD-IQ4_XS scored 95.2%, UD-Q4_K_XL scored 95.0%, and BF16 scored 95.3%. Unsloth puts those differences within run-to-run noise.

The BF16 vision projector adds another 0.90 GB to the download. A discrete GPU also needs system RAM for the runtime and any tensors placed there. Unsloth's 34.0 GB MLX 4-bit package is text-only and omits the MTP head. On a 24 GB Mac, start with the GGUF setup below because Unsloth documents its memory requirements. On Apple Silicon, oMLX is another option for image input and MTP, and can offload the per-layer embedding (PLE) table to SSD.

How does it compare with earlier Qwen models?

Qwen4 scored higher than the dense Qwen3.8-27B on all four coding tests in Qwen's release chart. It led the larger Qwen3.8-Flash-Next on DeepSWE and NL2Repo and trailed it on Terminal Bench and FrontierCode, which Qwen credits to Artificial Analysis. The last row gives the Artificial Analysis Intelligence Index for Qwen4 and the two earlier models, checked December 4. Artificial Analysis lists Qwen4 at xhigh, above the model card's default high effort.

Grouped bar chart of four coding benchmarks. Qwen4-35B-A3B leads on DeepSWE and NL2Repo and trails Qwen3.8-Flash-Next on Terminal Bench and FrontierCode.

Four coding benchmarks. The table adds Artificial Analysis's broader Intelligence Index.

Benchmark Qwen4-35B-A3B Qwen3.8-Flash-Next Qwen3.8-27B
DeepSWE v1.1 61.8 58.7 42.2
NL2Repo 51.7 48.1 42.3
Terminal Bench 4.1 21.2 24.2 5.6
FrontierCode-AA 2.0 16.1 27.1 14.9
Artificial Analysis Intelligence Index 25 (xhigh) 28 20 (xhigh)

The DeepSWE result gives you a reason to try Qwen4 on repository tasks if you already use Qwen3.8-27B. If you run Flash-Next comfortably, test both on your own terminal workflows before switching. The Transformers integration names a separate dense checkpoint, Qwen/Qwen4-27B. Its repository was not publicly accessible on December 4.

Run the 4-bit model in llama.cpp

The first llama.cpp release with Qwen4 support is b12969. Use a binary from that release or newer, or build llama.cpp from source. Start with one server slot and an 8,192-token context. Qwen lists a native limit of 1,048,576 tokens. Raise the context after measuring memory at the shorter setting, since longer contexts increase attention-cache memory.

llama-server \
  -hf unsloth/Qwen4-35B-A3B-GGUF:UD-IQ4_XS \
  --alias qwen4-local --host 127.0.0.1 --port 8080 \
  --ctx-size 8192 --parallel 1 --no-mmproj \
  --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 first run downloads both GGUF shards. --no-mmproj skips the vision projector for this text-only baseline. The memory-mapped, lazy-load settings read the embedding table on demand, with the tensor override placing it on the CPU side.

In the b12969 server defaults, GPU layer placement and Flash Attention are set to auto, and Jinja chat templates are enabled. Check the startup log to see where your build placed the layers. Once the server loads, open http://127.0.0.1:8080 and try a short prompt. On an 18 GB machine, try the same setup with UD-IQ3_XXS.

For a manual download, put both shards in one directory and pass the first to --model in place of -hf. To test image inputs, remove --no-mmproj and pass the projector with --mmproj. For a graphical setup, search for unsloth/Qwen4-35B-A3B-GGUF in Unsloth Desktop's model hub and select the quant in Chat. The app manages embedding-table placement.

Connect a coding agent and tune speed

The server exposes an OpenAI-compatible API at http://127.0.0.1:8080/v1. Point Qwen Code at that endpoint using the model alias from the server command. The placeholder key below is for the unauthenticated loopback server in this example.

qwen --auth-type openai --model qwen4-local \
  --openai-api-key local \
  --openai-base-url http://127.0.0.1:8080/v1

In Qwen Code's settings.json, set model.generationConfig.contextWindowSize to 8192 to match the server's --ctx-size. If you defined qwen4-local in modelProviders, put the setting in that entry's generationConfig. System instructions, tool definitions and tool results all share the window. Qwen Code's default compaction ceiling is 85%, with earlier compaction possible on smaller windows. Once the connection test works and leaves memory headroom, try restarting llama.cpp with --ctx-size 32768 for longer agent runs and set contextWindowSize to 32768 as well.

Start with a small task that needs a tool call, such as reading a file or running an existing test. In Unsloth's BFCL v3 AST tool-calling test, run with thinking on and two samples per item across 200 items on an A100 80 GB, UD-IQ4_XS scored 0.868, UD-Q4_K_XL scored 0.863 and UD-Q8_K_XL scored 0.870. The paired confidence intervals for the two 4-bit quants' differences from the 8-bit reference included zero.

Qwen defaults to thinking at high effort. Its model card also lists xhigh, low and off. To use the model's off mode for one llama.cpp request, send "reasoning_effort": "none" at the top level of the Chat Completions body. To run a non-thinking server, add --reasoning off and switch the sampling flags to --temp 0.7 --top-p 0.8 --top-k 20 --min-p 0.0 --presence-penalty 1.5.

Once the baseline works, try the GGUF's bundled draft head with --spec-type draft-mtp --spec-draft-n-max 2. The second flag overrides the three-token default in llama.cpp b12969. Unsloth recommends starting at two, or trying one when experts spill to the CPU. In Unsloth's 32 GB RTX 5090 test with UD-Q4_K_XL, greedy decoding and thinking off, depth 1 produced 224.0 code tokens per second, up from 174.9 with MTP off. Unsloth also reports 216–219 tokens per second at depth 2 on an A100, compared with 195–196 at depth 1. Measure both depths on the 24 GB UD-IQ4_XS setup before choosing.

You can replace the embedding shard with --ple. The Q5_1, Q8_0 and BF16 tables take 15.36 GB, 21.76 GB and 40.96 GB respectively, compared with the 11.52 GB IQ4_NL table. In Unsloth's embedding tests with UD-Q4_K_XL, switching from the stock IQ4_NL table to Q8_0 reduced mean KL divergence from BF16 by about 6%. The BF16 table showed no further improvement on that metric. Start with the stock table and compare results on your own tasks before switching.

Run the same coding task before and after changing the quant, embedding shard or MTP depth. Record whether the agent finishes the task, peak memory and generation speed.

Serve it on a shared machine

For a shared endpoint, use Qwen's official checkpoint with its vLLM recipe or SGLang cookbook. As of December 4, the cookbook directs SGLang users to install from a pull-request branch because Qwen4 support has yet to ship in a release. Qwen also documents Transformers compatibility and links a TokenSpeed recipe. The Apache 2.0 license permits commercial use under its terms.

Size the shared service by measuring it at the prompt lengths and concurrency you expect in use.