If you want to run Qwen locally, the picture changed on December 4, 2026. Alibaba released Qwen4-35B-A3B, the first open model of the fourth generation, under Apache 2.0 and with a context window of one million tokens. The catch is the file size: the Q4_K_M quantization weighs almost 33 GB. A laptop with 16 GB cannot load it, and from about 48 GB of memory it gets realistic. Everyone else can pick from older and smaller Qwen models that run on ordinary hardware. This guide shows which model fits which machine, how to install it with Ollama, LM Studio and llama.cpp, and how to talk to your local LLM through chat and an OpenAI-compatible API. Everything is checked against the vendors’ own pages as of December 5, 2026, and the last sections separate what I tested myself from what I only took from documentation.
Run Qwen locally: which models are current
Qwen is no longer one model family but a stack of generations, and all of them can still be downloaded. Four groups matter for local use.
At the top sits Qwen4-35B-A3B. It is a mixture-of-experts model with 256 experts per layer, of which eight plus one shared expert work on each token. According to the Hugging Face blog the main model has about 35 billion parameters, roughly 3.8 billion of them active per token. On top comes a table of 20.5 billion parameters for n-gram embeddings, which brings the checkpoint to about 56 billion. The model reads text, images and video and outputs text. Checkpoints exist in BF16 and FP8, there are GGUF files, MLX builds and an Ollama package. The model card says more sizes of the open Qwen4 series are on the way, but so far the 35B-A3B is the only open model of the generation. The flagship Qwen4-Max, which we covered in November, is not among them.
For most machines, Qwen3.8-27B from August is the more interesting pick. It is a dense model without experts, also multimodal and licensed under Apache 2.0, with a native context of 262,144 tokens. It weighs 18 GB on Ollama, and the Llama app lists 19 GB. Below it sit the small Qwen3.5 models with 0.8, 2, 4 and 9 billion parameters, which cost between 1.2 and 7.6 GB on Ollama depending on size and quantization. Then there are Qwen3.6 in 27B and 35B-A3B, plus the heavyweights: Qwen3.5-122B (81 GB on Ollama) and the Qwen3.8 flagship with 2.4 trillion parameters, which only runs in a data center.
Dedicated coder and vision variants matter less in the newer generations. Since Qwen3.5 the standard models understand images, so you no longer need a separate VL model. Neither the Qwen page on Hugging Face nor the Ollama library shows a Qwen4-Coder today. The dedicated coding models are older: Qwen3-Coder comes as a 30B-A3B at 19 GB and as a 480B, and Qwen3-Coder-Next weighs 52 GB. If you code locally, Qwen3.8-27B or Qwen4 is usually the better choice, because the vendor names coding and agent work as a focus there.
Hardware: memory, quantization and Apple Silicon
One rule holds for every model: the weights have to fit into system memory or video memory, and you need room on top for the context cache and the operating system. Quantization stores the weights with fewer bits. That saves memory and costs some quality. Q4_K_M at roughly four bits is the usual compromise, Q8_0 is close to the original, and Q2_K is a last resort. How much quality each step loses is something we measured in our GGUF quantization comparison.
| Model | Download | Memory rule of thumb | Fits |
|---|---|---|---|
| Qwen3.5-4B (Q4_K_M) | 3.0 GB (measured) | 8 GB | Laptop without a GPU |
| Qwen3.5-9B | 6.6 to 7.6 GB (Ollama) | 16 GB | Mac with 16 GB, gaming PC with 12 GB of VRAM |
| Qwen3.8-27B | 18 GB (Ollama) | 32 GB | Mac with 32 GB, 24 GB graphics card |
| Qwen4-35B-A3B (Q4_K_M) | 32.9 GB (GGUF), 36 to 37 GB (Ollama) | 48 GB | Mac with 48 GB or more, workstation |
The memory column is my own estimate: download size plus headroom for cache, operating system and your other programs. Vendors rarely publish official minimums. LM Studio lists Qwen4 as a 21.5 GB download that needs at least 22 GB of memory, without saying which quantization sits behind that. The GGUF files from ggml-org weigh 27.9 GB for Q2_K, 32.9 GB for Q4_K_M and 49 GB for Q8_0, and in BF16 the model is 114 GB on Ollama.
Qwen4 has one quirk. The 20-billion-parameter n-gram table is only read at a few places per token. The ggml-org GGUF is laid out so that llama.cpp reads it from disk on demand (--lazy-mode auto) instead of keeping it in memory. On the Mac, oMLX can also move that table to the SSD, according to Hugging Face. That lowers the memory requirement but costs speed. With a small graphics card, -cmoe in llama.cpp helps too: the expert weights stay in system memory while attention and cache run on the card.
On Apple Silicon, what counts is the memory shared between CPU and GPU. A Mac with 16 GB handles Qwen3.5-9B well, 32 GB is enough for Qwen3.8-27B, and for Qwen4 in Q4 I would plan for 48 GB. Qwen4 has two MLX routes: Ollama ships the tag qwen4:35b-a3b-nvfp4 at 36 GB, and mlx-lm runs the 4-bit build from mlx-community. Hugging Face points out that mlx-lm support for the language model is still on its way into the official repository, so if you want it simple, use Ollama or LM Studio.
Ollama: the shortest path to a running model
Ollama is a background service that downloads and manages models and serves them through a local API. On Linux and macOS you install it with one command. On Windows you use PowerShell or the OllamaSetup.exe installer, which does not need administrator rights.
# Linux and macOS
curl -fsSL https://ollama.com/install.sh | sh
# Windows (PowerShell)
irm https://ollama.com/install.ps1 | iex
After that, one command pulls a model and opens a chat. The first download takes a while, and the files stay in the local model folder.
ollama run qwen4 # Qwen4-35B-A3B, 36 to 37 GB
ollama run qwen3.8 # Qwen3.8-27B, 18 GB
ollama run qwen3.5:9b # 6.6 to 7.6 GB
ollama run qwen3.5:4b # 3.3 to 4.0 GB
ollama ps # what is loaded, on CPU or GPU, with which context
Qwen4 is new, so use a current Ollama version; older ones may not know the architecture. You can bring your own GGUF file, say a specific quantization from Hugging Face, through a Modelfile.
# Modelfile
FROM ./Qwen3.5-4B-Q4_K_M.gguf
ollama create qwen35-4b -f Modelfile
ollama show qwen35-4b
That is how I did it on my test server, because downloads from the Ollama registry were blocked there by network rules. With Ollama 0.40.21, ollama show then reported the architecture qwen35, 4.2 billion parameters, Q4_K_M, a context of 262,144 tokens and the capabilities tools, thinking and completion. The chat template came from the GGUF file. I did not run ollama run qwen4 itself.
LM Studio: a desktop app instead of a terminal
LM Studio is a desktop app for macOS, Windows and Linux. You install it from lmstudio.ai, search the catalog for “Qwen4” and click download. If you prefer the terminal, the bundled command line tool lms does the same.
lms get qwen/qwen4-35b-a3b
lms load qwen/qwen4-35b-a3b
lms server start --port 1234
The server speaks the OpenAI API and listens on 127.0.0.1 only by default. --bind 0.0.0.0 opens it to the network, and the documentation then recommends authentication. The advantage over Ollama is the interface: you find a model, load it and chat without touching a config file. I did not try LM Studio for this guide. The commands come from its documentation and model page.
llama.cpp: full control over quantization and memory
If you want to set every parameter yourself, use llama.cpp. It now ships as a single program called llama with subcommands. The former llama-server is now llama serve. On Linux and macOS you install it with a script, the Mac also gets a small menu bar app, and Windows has a PowerShell variant.
# Linux, macOS
curl -LsSf https://llama.app/install.sh | sh
# macOS as an app
brew install --cask llama-app
# Windows (PowerShell)
irm https://llama.app/install.ps1 | iex
The model comes straight from Hugging Face. For Qwen4 the call looks like this, using the Q4_K_M file from ggml-org:
llama serve -hf ggml-org/Qwen4-35B-A3B-GGUF:Q4_K_M -c 32768
# faster with multi-token prediction
llama serve -hf ggml-org/Qwen4-35B-A3B-GGUF:Q4_K_M --spec-type draft-mtp --spec-draft-n-max 3
For the second variant Hugging Face reports 22 percent more generation speed on an Apple M5 with the Q4 file. That is a vendor figure and depends on your hardware. The server starts on port 9931 and includes a chat interface in the browser. Our guide to the llama.cpp server shows how to protect it with an API key. Image input runs through a separate projector file (mmproj), which -hf downloads automatically.
Two options help when memory gets tight. -c sets the context length, and the default -fit adjusts unset parameters to the free device memory. -ngl decides how many layers move to the graphics card.
vLLM and Transformers for a GPU server
If you have a server with a large GPU, run the original weights with vLLM or SGLang instead of GGUF. The Qwen team recommends these engines for production and high throughput. The Hugging Face recipe assumes a single NVIDIA H200 with 141 GB and loads the BF16 model. The FP8 checkpoint Qwen/Qwen4-35B-A3B-FP8 needs less space.
docker run --gpus all --shm-size 16g -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
-e HF_TOKEN \
vllm/vllm-openai:qwen4 \
--model Qwen/Qwen4-35B-A3B \
--trust-remote-code \
--max-model-len auto \
--enable-auto-tool-choice \
--tool-call-parser qwen4 \
--reasoning-parser qwen4
This is shortened; the full recipe adds options for the cache and multi-token prediction. With that setup the authors measure about 330 tokens per second for a single request and roughly 2,660 tokens per second across 64 parallel requests. If you only want to try it, pip install vllm and vllm serve Qwen/Qwen4-35B-A3B get you there. In Python, Transformers loads the model with AutoModelForMultimodalLM, and you control the thinking effort through reasoning_effort in the call to apply_chat_template.
Using the local LLM: chat and the OpenAI-compatible API
All routes expose the same interface: a server that mimics the OpenAI API. Only the port differs: Ollama listens on 11434, LM Studio on 1234, llama.cpp on 9931 and vLLM on 8000. Any tool that can talk to OpenAI works once you change the base URL. The local server does not need an API key, but most clients insist on some value.
Here is the test with curl against a llama.cpp server. I ran it with Qwen3.5-4B in Q4_K_M and thinking switched off, using the values the Qwen model card recommends for non-thinking mode.
curl -s http://127.0.0.1:9931/v1/chat/completions \
-H "Content-Type: application/json" -d '{
"model": "qwen",
"messages": [{"role": "user", "content": "Explain in two sentences what a mixture-of-experts model is."}],
"max_tokens": 200,
"temperature": 0.7, "top_p": 0.8, "top_k": 20, "presence_penalty": 1.5,
"chat_template_kwargs": {"enable_thinking": false}
}'
The answer came back after 78 tokens: “A mixture-of-experts model is a machine learning architecture that combines multiple specialized sub-models, known as ‘experts,’ to handle different types of input data. It dynamically selects which expert(s) should process a given input …” It is correct but a little wordy, which is typical for a 4-billion-parameter model. In Python, the call with the official OpenAI package looks like this, this time with thinking switched on:
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:9931/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="qwen",
messages=[{"role": "user", "content": "Write a Python function that merges two sorted lists."}],
max_tokens=500,
temperature=1.0,
top_p=0.95,
extra_body={"top_k": 20},
)
msg = response.choices[0].message
print(msg.reasoning_content) # reasoning trace, llama.cpp returns it separately
print(msg.content) # the actual answer
The result taught me something. The model first wrote its reasoning, then started the code and the explanation, and at 500 tokens the answer broke off in the middle of the test cases (finish_reason was length). The reasoning trace counts against the token limit. If you leave thinking on, set max_tokens generously or turn thinking off for simple questions.
Thinking mode and sampling with Qwen4
Qwen4 controls thinking through reasoning_effort with the levels xhigh, high (the default), low and off. enable_thinking=False is equivalent to off. On servers that pass chat template arguments through, you set the level in the request.
{
"model": "Qwen/Qwen4-35B-A3B",
"messages": [{"role": "user", "content": "Refactor this function ..."}],
"chat_template_kwargs": {"reasoning_effort": "low"}
}
In Ollama, the matching field is think in the native API and reasoning_effort under /v1. /api/show lists the levels a model supports in its thinking field. On my test model, reasoning_effort="none" worked through Ollama’s /v1 endpoint: the question “What is 17 * 23?” was answered with “391” in four tokens and under two seconds. Qwen also warns that low effort is not always faster on multi-step agent tasks, because the model then fails more often and retries.
For sampling, the model card recommends temperature 1.0, top_p 0.95, top_k 20 and presence_penalty 0 in thinking mode, and temperature 0.7, top_p 0.8, top_k 20 and presence_penalty 1.5 in non-thinking mode. The higher presence penalty is meant to curb endless repetition and can occasionally cause language mixing, according to the team.
Setting context length and image input
Qwen4 supports a million tokens natively, but that does not mean your machine can handle them. LM Studio states explicitly that its 22 GB minimum does not include room for the full context. Start with 32,768 tokens and raise it only when you need to. Ollama ties its default to video memory: under 24 GiB you get 4,096 tokens, between 24 and 48 GiB 32,000, and from 48 GiB 256,000. For agents and coding tools the documentation recommends at least 64,000. You set the value when you start the server or per request.
OLLAMA_CONTEXT_LENGTH=65536 ollama serve
# or per request in the native API
"options": {"num_ctx": 65536}
You send images as image_url in the message, as with OpenAI. Ollama and LM Studio list Qwen4 with text and image input. According to Hugging Face, video goes through Transformers, vLLM or SGLang and needs a strong GPU there.
Connecting an editor, Open WebUI and agents
The easiest route to a chat interface in the browser is Open WebUI. It detects a local Ollama automatically when it runs in Docker with the --add-host option set. This is the Docker variant from its documentation:
docker run -d -p 3000:8080 \
--add-host=host.docker.internal:host-gateway \
-v open-webui:/app/backend/data \
-e WEBUI_SECRET_KEY=your-secret-key \
--name open-webui --restart always \
ghcr.io/open-webui/open-webui:main
Generate the key with openssl rand -hex 32. If Open WebUI runs in Docker, Ollama on the host has to listen on 0.0.0.0. You can add other sources, such as llama.cpp or LM Studio, as an OpenAI-compatible connection under Connections in the admin settings.
For programming there is Qwen Code, the Qwen team’s terminal agent. It needs Node.js 22 or newer and can be pointed at a local server. In ~/.qwen/settings.json you enter the model and the base URL, and the key is a placeholder.
npm install -g @qwen-code/qwen-code@latest
{
"env": { "OLLAMA_API_KEY": "ollama" },
"modelProviders": {
"openai": [{
"id": "qwen4",
"name": "Qwen4 (Ollama)",
"envKey": "OLLAMA_API_KEY",
"baseUrl": "http://localhost:11434/v1",
"generationConfig": { "contextWindowSize": 65536 }
}]
},
"security": { "auth": { "selectedType": "openai" } },
"model": { "name": "qwen4" }
}
Ollama also has a starter. According to the model page, ollama launch opencode --model qwen4 is enough to start the OpenCode agent with the local model. For Continue in VS Code, an entry with provider: llama.cpp and the apiBase of your server does the job. To let a local model call tools, see our tutorial on function calling with llama.cpp, and for your own documents the RAG guide shows how to search local files.
When something goes wrong: memory, speed and the wrong quantization
Out of memory. This is the most common failure and comes in two forms: the model does not fit, or the context eats the rest. First pick a smaller quantization or a smaller model, then shrink the context. In llama.cpp, -cmoe helps MoE models on machines with a small graphics card. On Linux, dmesg confirms whether the kernel killed the process for lack of memory. That is exactly what happened to me with Qwen4, more on that below.
Slow output. In Ollama, check with ollama ps whether the model sits entirely on the graphics card. If the PROCESSOR column shows a CPU share, part of the work runs on the processor, and that slows things down. Long thinking phases cost time as well. Setting reasoning_effort to low or off cuts the wait noticeably on simple questions. In llama.cpp, multi-token prediction can help. And the load on the machine counts: my test server reached 1.9 tokens per second with Qwen3.5-4B while other processes kept all eight cores busy, and 11 to 12.5 tokens per second once they were idle.
The wrong or too aggressive quantization. If quality is off, Q2_K or Q3 is often the reason. The Qwen4 file in Q2_K roughly halves the memory need, but I would only use it when Q4_K_M does not fit. If you ask Ollama for plain qwen4, you get the default package of 36 to 37 GB, and you fetch other quantizations through tags such as qwen4:35b-a3b-q4_K_M. A frequent misunderstanding is that the model “forgets” what you wrote earlier. Usually Ollama’s 4,096-token default is to blame, not the model.
Architecture not supported. Qwen4 is new. If your tool reports an unknown architecture, update it. The ggml-org GGUF explicitly requires a llama.cpp build with qwen4_moe support.
License and privacy
Qwen4-35B-A3B and Qwen3.8-27B are licensed under Apache 2.0. You may use them commercially, modify them and redistribute them, as long as you include the license text and notices. For other Qwen models, check the license file in the respective Hugging Face repository, since I did not go through them one by one. Third-party GGUF and MLX conversions fall under the same license as the original. On privacy the advantage is clear: when you run locally, prompts and documents do not leave the machine, provided you do not switch on web features in the interface.
What I tested and what I did not
My test server has eight shared CPU cores, 16 GB of memory and no graphics card. On it I tried llama.cpp build 12970 (version 1.1.0-dev) with Qwen3.5-4B in Q4_K_M: llama serve, a curl call with and without thinking, and Python with the OpenAI package. I also ran Ollama 0.40.21 with a GGUF import through a Modelfile, a chat through the native API and a call through /v1. The numbers above come from those runs, and because the machine is shared they are rough guides.
Qwen4 itself did not run for me. I downloaded the 27.9 GB Q2_K file and tried to load it with llama.cpp. The Linux kernel killed the process twice during loading for lack of memory, at about 8 GB of process memory and on a machine that other processes were also using. That says nothing about how good Qwen4 is, only that 16 GB is not enough. I did not test LM Studio, vLLM, SGLang, MLX, Open WebUI, Qwen Code, Windows or macOS. For those, commands and figures come from the linked sources. The Qwen4 benchmarks are vendor figures too, and I have no measurements of my own for them.
When running Qwen locally makes sense
Local pays off when your data must not go to the cloud, when you work offline, or when you send a lot of small requests at predictable cost. For summaries, classification, code help in the editor and experiments, a 9B or 27B model on a decent laptop is enough. It pays off less when you need the best possible quality on hard tasks and have only 16 GB of memory. Then you get a small model that can do noticeably less than what the cloud offers, and without a graphics card it answers at a few tokens per second. Qwen4 demands serious hardware. If you do not have 48 GB, take Qwen3.8-27B or Qwen3.5-9B, or call Qwen4 through Qwen Cloud, where it runs under the name qwen4-35b-a3b.
My suggestion for getting started: install Ollama, run ollama run qwen3.5:9b and check whether quality and speed are good enough for your tasks. If they are, you are done in ten minutes. If you need more, Qwen3.8-27B on 32 GB comes next, and Qwen4 with 48 GB or more only after that. The model is new, the tools are still catching up, and in the coming weeks quantizations, drivers and recipes should improve.




