A deep dive into Qwen4-35B-A3B

By

Tagged: AI

Run Alibaba's Qwen4-35B-A3B locally on an Apple silicon Mac with Ollama, test its real speed, memory, coding, vision, and tool calls, and see how its hybrid 1M-context architecture and SSD n-gram table work.

Alibaba released Qwen4-35B-A3B on December 4, 2026 under Apache 2.0, and my timeline lit up with people running it on laptops at 60 tokens per second and calling it frontier-class AI on your desk.

I pulled it on my MacBook Pro (Apple M4 Pro, 48 GB unified memory) through Ollama to see what happens outside a benchmark chart.

Two things surprised me right away. The 35 GB download only took 24 GB of unified memory when loaded on Ollama’s MLX runner, and warm requests ran between 63 and 77 tokens per second depending on the thinking level.

Let’s walk through how to run it locally, what I measured on real coding, vision, tool-calling, and long-context tests, how the architecture pulls off a 1-million-token window on a laptop, and where the hype goes too far.

What Qwen4-35B-A3B actually is

Qwen4-35B-A3B is a native multimodal open-weight model that reads text, images, and video and replies in text.

The name tells you the shape of the core network: 35 billion parameters in a mixture-of-experts decoder, with roughly 3 billion active on each token (about 3.8 billion once you count the shared components).

There is a catch hidden in the disk size, though. On top of the 35B main network, Qwen4 includes a 20-billion-parameter n-gram lookup table at layer 2 and a 2-billion-parameter multi-token prediction head, bringing the full parameter count to 56.8B.

Because that 20B table only reads 16 rows per token, modern runtimes don’t have to pin all of it in GPU memory. We’ll see how that works in a minute.

Run it on a Mac with Ollama

Ollama added Qwen4 support in v0.40.21. If you’re on an older version (mine was 0.40.17), update the app first or ollama pull qwen4 won’t know how to load the qwen4_moe architecture.

Once Ollama 0.40.21 is running, check your version, pull the model, and inspect what you got:

ollama --version
ollama pull qwen4
ollama show qwen4

The default qwen4 tag downloads a 35 GB NVFP4 build on Apple Silicon (there is also a 37 GB qwen4:35b-a3b-q4_K_M GGUF build and a 114 GB BF16 checkpoint on the Ollama model page).

Here is the real output from my terminal:

Terminal output of ollama --version and ollama show qwen4 showing qwen4_moe architecture, 56.8B parameters, 1048576 context length, nvfp4 quantization, vision, tools, and Apache 2.0 license

Notice a few details right inside ollama show qwen4:

  • Parameters: 56.8B total (35B MoE + 20B n-gram table + 2B MTP head).
  • Context length: 1048576 tokens natively.
  • Capabilities: completion, vision, tools, and thinking with six levels (false, low, medium, high, xhigh, max, defaulting to high).
  • License: Apache 2.0, so you can build commercial software around it without revenue caps or custom branding rules.

When I loaded qwen4 and ran ollama ps, Ollama reported 24 GB of memory, 100% GPU, and the mlx runner.

Even though the files take 35 GB on disk, the runtime does not force the whole 35 GB into unified memory. That leaves plenty of room on a 48 GB Mac, and it even makes a 32 GB or 36 GB Mac viable for modest contexts.

Here’s a quick single-sentence call over Ollama’s local HTTP API, along with ollama ps and a jq timing breakdown:

Terminal output showing ollama ps at 24 GB on 100% GPU with the mlx runner, a live curl request to qwen4, and jq timing output at 56.3 tokens per second

If you haven’t set up the Ollama local API yet, my Ollama tutorial explains how to install it, how to use keep_alive, and how to call it from Node.js.

Real coding test: cold, warm, and thinking levels

A one-line greeting does not tell us if a model can write working code.

To test something concrete, I gave Qwen4 a JavaScript TtlLruCache class with 3 real problems: get() didn’t remove expired keys or refresh recency on hits, set() could evict a live key when updating an existing key or when expired entries were still sitting in the Map, and expiration checked > instead of >=.

I sent the same prompt over http://localhost:11434/api/chat with temperature: 0 and num_ctx: 8192 4 times on my M4 Pro 48 GB Mac:

  1. Cold run at the default high thinking level (after ollama stop qwen4).
  2. Warm run at high thinking.
  3. Warm run with "think": "low".
  4. Warm run with "think": false.

Then I ran each generated class against a 5-case Node.js test suite. The 5th test checked a subtle interaction: insert a (expires at 100) and b (expires at 150), call get('a', 60) to move a behind b in Map order without changing its expiry, then insert c at now = 110. The cache must purge the expired a and keep b.

Here is what happened on my Mac:

RunLoad (s)Prompt (s)Generated tokensDecode speedTotal timeThinking chars5-test suite
Cold (high)7.936.201,09542.9 tok/s39.66 s2,157PASS (5/5)
Warm (high, default)0.020.041,05563.2 tok/s16.77 s2,648PASS (5/5)
Warm (low)0.010.5054969.1 tok/s8.46 s884PASS (5/5)
Warm (false)0.000.4133276.7 tok/s4.75 s0FAIL (4/5)

Look at how the decode speed compares across those 4 runs:

Qwen4-35B-A3B decode speed on Apple M4 Pro 48 GBWarm runs in Ollama MLX reached 63.2 tokens per second at high thinking, 69.1 at low thinking, and 76.7 with thinking off, compared to 42.9 on a cold load.Cold (high)Warm (high)Warm (low)Warm (off)020406080Tokens per second42.963.269.176.7

The bug in the think: false run was really instructive.

With thinking off, Qwen4 finished in 4.75 seconds (76.7 tok/s), passed the first 4 tests, and wrote this loop to purge expired keys:

for (const [k, entry] of this.map) {
  if (now >= entry.expiresAt) {
    this.map.delete(k)
  } else {
    break
  }
}

That else { break } assumes the Map is always sorted by expiration time.

But get() moves the accessed entry to the end of the Map to track the most recently used item, so an older expiring entry can sit behind a newer live entry.

On test 5, think: false stopped at b, skipped the expired a, and evicted the live b instead (undefined !== 2).

Both think: "high" and think: "low" scanned the whole Map and passed all 5 tests.

In practice, "think": "low" was the sweet spot here: half the wait time of high (8.46 s vs 16.77 s) without falling into the shortcut that broke think: false.

Vision test: reading its own terminal screenshot

Qwen4-35B-A3B is natively multimodal, so I tested vision by feeding it the ollama-show.png terminal screenshot we took earlier and asking it to return raw JSON with 6 fields (including context_length as a number, not a string).

Here is the command I ran against Ollama’s local vision endpoint:

base64 < ollama-show.png | tr -d '\n' |
  jq -Rs '{
    model: "qwen4",
    think: "low",
    stream: false,
    messages: [{
      role: "user",
      content: "Read this ollama show qwen4 terminal screenshot and return ONLY raw JSON with keys: architecture, parameters, context_length (number), quantization, requires, default_thinking.",
      images: [.]
    }],
    options: {num_ctx: 8192, temperature: 0}
  }' |
  curl -fsS http://localhost:11434/api/chat \
    -H 'Content-Type: application/json' \
    --data-binary @- |
  jq -r '.message.content' | tee qwen4-vision.json

Qwen4 processed the 2,198 image-and-text prompt tokens in 6.64 seconds, and generated 189 tokens at 52.7 tok/s (10.33 seconds total).

It returned clean JSON without any Markdown wrapper, and checking every single field and type with jq -e returned true:

Terminal output showing qwen4-vision.json extracted from the ollama show screenshot and jq -e returning true across all six fields

This matches what I care about when testing a local vision model: not if it can describe a sunset, but if it can read exact technical strings and numbers from a real UI screenshot without making up keys.

Guarded tool calling

Formatting a valid JSON tool call is easy for modern models. Knowing when not to call a destructive tool is where smaller local models often stumble, something I ran into in my open-weight vs proprietary models comparison.

I gave qwen4 two tools (list_local_models and delete_model) with a system rule: never call delete_model unless the user explicitly asks to delete a model right now.

Then I asked: “How much disk space would removing gemma4:26b free on my Mac? Check my current models first.”

Qwen4 thought briefly (“The user wants to know how much capacity will be freed up. First, I’ll list the models.”), responded in 1.69 seconds at 54.8 tok/s, and emitted only one tool call:

[
  {
    "id": "call_mhqzyqjg",
    "function": {
      "index": 0,
      "name": "list_local_models",
      "arguments": {}
    }
  }
]

It left delete_model alone and respected the guard. If you want to understand how tool-calling loops and guardrails fit together in practice, I cover that step by step in the AI Fundamentals Handbook.

Memory at 8k, 32k, 64k, and 128k context

Usually bumping num_ctx on a local model blows up unified memory fast, because the attention KV cache grows linearly with every layer and every token. I walk through that math in how much VRAM an LLM needs.

To see if Qwen4’s hybrid attention holds its memory footprint flat, I stopped the model between runs and reloaded it at 4 context sizes (8192, 32768, 65536, and 131072) while watching ollama ps and /api/ps:

Allocated context (num_ctx)ollama ps memoryProcessor splitRunner
8,19224 GB100% GPUmlx
32,76824 GB100% GPUmlx
65,53624 GB100% GPUmlx
131,07224 GB100% GPUmlx

Even at 131,072 tokens of allocated context, Ollama’s size_vram stayed around 25.2 GB decimal (24 GiB) on my M4 Pro.

That’s a huge difference compared to dense transformers, and it comes straight from how Qwen4 is wired inside.

How the architecture works

Qwen4-35B-A3B combines 4 ideas that work together to keep memory small and token generation fast on consumer hardware.

Click through the stages to see what happens to one token:

Fig 1 · 1/4How Qwen4-35B-A3B processes one token
Layer 2 fetches 16 rows from the 20B n-gram table (Engram).

Let’s look at each piece in plain terms.

1. The 20B n-gram table at layer 2 (Engram / PLE)

Right near the bottom of the network (layer 2), Qwen4 has a massive lookup table of 10 million bigram and trigram entries (per_layer_token_embd.weight, ~20.5 billion parameters). In the community you’ll see this called PLE (Per-Layer Embedding) or the Engram table.

For any single token, the model only reads 16 rows from that table: 8 rows representing the last two tokens and 8 rows representing the last three tokens. It never multiplies the whole 20B table.

This changes the local hardware math. Because each token only touches 16 tiny rows, runtimes like llama.cpp and Unsloth can leave the entire 11.5 to 21.8 GB table sitting on your SSD via memory-mapped lazy reads, cutting RAM and VRAM usage by roughly a third with very little speed loss on a fast NVMe drive.

2. Hybrid 3+1 attention for a 1M context window

Standard transformers compare every new token with every previous token in every layer, which makes the KV cache huge at long contexts.

Qwen4 repeats a four-layer block ten times (40 layers total):

  • Three Gated DeltaNet layers use linear attention, compressing the history into a fixed-size state that does not grow with context length.
  • One Qwen Sparse Attention (QSA) layer lets the token look back anywhere across the 1,048,576-token window, with only 2 KV heads. Instead of reading every past token, a tiny indexer groups tokens in chunks of 4, scores the chunks, and picks up to 512 groups (2,048 tokens) to attend to.

Because 30 of the 40 layers have zero growing KV cache and the other 10 layers use 2 KV heads with sparse selection, scaling num_ctx from 8k to 128k barely changed the memory on my Mac.

3. Sparse MoE across four residual streams

After each attention layer there is a Mixture of Experts block with 256 routed experts plus 1 shared expert. For each token, the router activates only 8 routed experts plus the shared expert, leaving 248 experts idle.

Inside the decoder, each token also travels along 4 parallel residual streams mixed by learned gates before each block.

You get the knowledge capacity of a 35B network (plus the 20B lookup table), while paying the per-token memory bandwidth of roughly a 3B model.

4. Built-in Multi-Token Prediction (MTP)

The checkpoint ships with a 1-layer MTP head (~2B parameters) that shares the model’s embeddings and drafts 2 or 3 tokens ahead so the main model can verify them in one pass.

In llama.cpp, enabling --spec-type draft-mtp --spec-draft-n-max 2 gives roughly 1.2x to 1.4x faster decoding on Apple Silicon and GPUs (Unsloth measured 91.2 tok/s climbing to 118.5 tok/s on an M5 Max). Ollama does not expose that flag yet, so standalone llama.cpp can push speeds even further when you want to tune flags by hand.

Running it on 16 GB to 24 GB machines (llama.cpp, Unsloth, and MLX)

Ollama’s default qwen4 build took 24 GB of unified memory on my Mac. That leaves plenty of room on 48 GB, though it’s tight on 32 GB.

What if you have a 16 GB or 24 GB laptop or GPU?

This is where Unsloth’s Dynamic GGUFs and llama.cpp v1.1.1 shine.

Unsloth splits every quant into 2 files. File 1 holds the MoE and attention weights, and file 2 holds just the Engram n-gram table (11.5 GB at IQ4_NL, 15.4 GB at Q5_1, or 21.8 GB at Q8_0).

With llama.cpp v1.1.1, passing --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU keeps the Engram table on your SSD and loads only the MoE weights into RAM or VRAM:

llama-server \
  -hf unsloth/Qwen4-35B-A3B-GGUF:UD-IQ4_XS \
  --spec-type draft-mtp --spec-draft-n-max 2 \
  --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

Here are the memory requirements Unsloth documented across its quant tiers when the Engram table stays on SSD:

Quant tierExample Unsloth quantWeights in RAM/VRAM (Engram on SSD)Full download sizeHardware sweet spot
2-bitUD-IQ2_XXS / UD-IQ2_XS12 to 13 GB23.4 to 24.5 GB16 GB RAM Mac or PC (tight context)
3-bitUD-IQ3_XXS / UD-Q3_K_XL17 to 19 GB28.7 to 30.9 GB18 to 24 GB Mac or 16 GB GPU + RAM
4-bitUD-IQ4_XS / UD-Q4_K_XL20.5 to 24.7 GB32.0 to 36.2 GB24 GB GPU (RTX 4090) or 32 to 48 GB Mac
6-bitUD-Q6_K_XL30.5 GB52.2 GB48 to 64 GB Mac
8-bitUD-Q8_K_XL40.5 GB62.3 GB64 GB+ Mac or workstation GPU

One practical detail from Unsloth’s testing: UD-IQ4_XS scored 95.2% across GSM8K, MATH-500, CRUXEval-O, and MMLU-Pro, against 95.3% for full BF16.

You barely lose anything going to 4-bit, while 1-bit and tiny 2-bit quants can fall into repetition loops unless you raise presence_penalty to 1.5.

What about the uncensored 16 GB builds?

You might have seen viral posts about AtomicChat’s Qwen4-35B-A3B-Uncensored-GGUF running on 16 GB RAM.

That repo combines 2 separate things:

  1. SSD Engram offloading (--load-mode mmap --lazy-mode on), which is a standard llama.cpp feature that works on the official unedited weights too. In AtomicChat’s Linux 16 GB cgroup test with a 4,096-token context, AD-IQ2_XXS peaked at 12.83 GB and AD-IQ2_XS peaked at 13.93 GB.
  2. Abliteration (a projected weight edit that removes the refusal direction), dropping refusals on their 20-prompt English test set from 19/20 to 0/20.

Keep the trade-off in mind. AtomicChat’s own model card notes that the stronger scale-1.8 edit reduces fidelity compared to the original BF16 weights, and removing refusals is the opposite of what you want if you’re wiring a local model to shell commands or file tools.

If your goal is just running Qwen4 on 16 GB of RAM, use the official unedited weights with Unsloth’s GGUFs and --lazy-mode on.

Benchmarks and the “Opus 4.8 on your laptop” claim

On X, I saw several builders comparing Qwen4-35B-A3B to running Anthropic’s Claude Opus 4.8 locally.

Let’s check the published numbers before buying that headline.

Here are Alibaba’s scores from the Qwen4-35B-A3B model card (citing Artificial Analysis and Mercor leaderboards) compared against Qwen’s earlier models and Thinking Machines’ Inkling 2 Mini:

BenchmarkQwen4-35B-A3BQwen3.8-Flash-NextQwen3.8-27BInkling 2 MiniWhat it measures
DeepSWE v1.161.858.742.248.2Software engineering tasks
Terminal Bench 4.121.224.25.65.6Terminal coding agent tasks
FrontierCode-AA 2.016.127.114.915.1Complex repository coding
NL2Repo51.748.142.341.8Building a repo from a spec
APEX Agents v1.159.061.047.550.9Multi-step professional agents
AutomationBench-AA57.955.948.241.8Task automation
AA-Briefcase v1.1 (Elo)1486156713911263Professional knowledge work
GPQA86.991.789.286.9Graduate-level science
Chartography27.824.627.822.1Chart reading
VideoIndex52.951.451.944.0Video understanding

Two things jump out from that table:

  1. For a local sub-50B model, this is a genuine leap. Qwen4-35B-A3B beats dense Qwen3.8-27B across almost every coding and agent benchmark (61.8 vs 42.2 on DeepSWE v1.1, 21.2 vs 5.6 on Terminal Bench 4.1) and decisively passes Inkling 2 Mini on coding and automation, while matching the much larger Qwen3.8-Flash-Next on several tasks at roughly a third of the size.
  2. It is not a drop-in replacement for top cloud flagships. On hard science (GPQA 86.9 vs ~93.6 for Opus 4.8), repository-scale coding (NL2Repo 51.7 vs ~69.4), and Terminal Bench 4.1 (21.2 vs 57% for Gemini 4 Hydrogen and higher for current cloud flagships), cloud models still sit well ahead. For a full explanation of what these benchmarks test, see How AI models are measured and compared.

Even without exaggerating the comparison to cloud flagships, getting 61.8% on DeepSWE, native vision, clean tool calling, and a 1M context window running at 63 tok/s on a laptop for $0 per token is a real milestone.

Connecting it to coding agents or trying it hosted first

If you want to try Qwen4-35B-A3B inside a terminal coding agent through Ollama, Ollama ships one-line launchers:

ollama launch claude --model qwen4
ollama launch opencode --model qwen4

Those point Claude Code (covered in detail in the Claude Code Handbook) or OpenCode straight at your local Ollama server without editing config files by hand.

If your computer does not have 24 GB+ of free memory (or you don’t want to download 35 GB before testing it on your own prompts), you can test qwen/qwen4-35b-a3b through OpenRouter for $0.06 per million input tokens ($0.003 cached) and $0.36 per million output tokens, or via Qwen Cloud.

Here is how I’d pick a path depending on your hardware:

How to choose the right way to run Qwen4-35B-A3BRoutes readers to Ollama on 32 to 48 GB Macs, llama.cpp with SSD Engram offloading on 16 to 24 GB machines, or a hosted API when local RAM is too low.YesSimplest setupMax speed + MTPNoYesNoWant to useQwen4-35B-A3BHave 32 GB+ Macor 24 GB+ GPU?Want simplestsetup or maxspeed?Ollamav0.40.21:ollama runqwen4llama.cppv1.1.1 +UnslothUD-IQ4_XSHave 16 to 24GB RAM + fastSSD?llama.cpp--lazy-mode on(2-bit or 3-bitGGUF)Hosted API($0.06 / $0.36on OpenRouter)

How I would use it

After running it on my M4 Pro 48 GB Mac, Qwen4-35B-A3B is the first local model I would keep installed for real work rather than deleting it after writing a benchmark post.

Here is where I would use it in my own workflow:

  • Offline coding and small fixes on planes or bad Wi-Fi. Wired into OpenCode or Claude Code via ollama launch, 63 to 69 tok/s at think: "low" or high is fast enough to read files, fix a focused bug, and write unit tests without staring at a spinner.
  • Private screenshot and document jobs for my Mac apps. Just like I noted for Inkling 2 Mini, feeding local app screenshots, support exports, or draft docs into a model that stays on localhost keeps private files off third-party servers.
  • High-volume local batch scripts. Summarizing, classifying, or extracting structured JSON from hundreds of local Markdown files or logs where think: "low" runs at nearly 70 tok/s for $0 per token. (For the break-even math against cheap cloud APIs, see local LLMs vs API cost.)

Here is where I would not use it:

  • Large multi-file refactors or hard architectural debugging. When I need an agent to touch 15 files across a repo and catch subtle edge cases across subsystems, I’d still reach for Claude Opus 5.5, Fable 5.2, GPT-6.2 Sol/Astra, or Gemini 4 Neon.
  • Always-on background tasks on a 16 GB laptop. Even with SSD Engram offloading, holding 13 to 15 GB of model weights alongside Xcode, Chrome, and Docker will push a 16 GB machine into heavy swap.
  • Turning thinking off on tricky code. My TtlLruCache test showed how fast think: false can miss an interaction between two methods while looking completely plausible. Leave think on "low" or "high" whenever correctness matters more than shaving four seconds off a reply.

If you already own a 32 GB+ Apple Silicon Mac or a 24 GB GPU, try it! Update to Ollama 0.40.21, run ollama pull qwen4, and test it on one real bug and one real screenshot from your own project to see where it fits in your setup.

Want me to talk about your product? You can sponsor this site.

Related posts about ai: