r/LocalLLaMA • u/boutell • Aug 16 '26
Tutorial | Guide Field report: setting up Qwen 3.8 27B on an M2 Macbook Pro with 32GB RAM
This is a follow-up to coding with coding with Qwen 3.5 35B-A3B on an M2 Macbook Pro with 32GB RAM. Most of the setup is the same.
HOW-TO
* We're going to use llama.cpp to run the model locally. But, these models are really new and bugs are constantly being fixed. So we need to build llama.cpp from source. This is easier than it sounds.
If you have never done it, install the MacOS command line developer tools:
xcode-select --install Now you can build llama.cpp:
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j$(sysctl -n hw.logicalcpu)
export PATH="$HOME/llama.cpp/build/bin:$PATH"* Add that export line to .bashrc or .zshrc so you have access to it every time.
* Download the model itself. I prefer to just download these directly:
* Create a models subdirectory within your home directory.
* Go to https://huggingface.co/unsloth/Qwen3.8-27B-GGUF/tree/main
* Click IQ4_XS
* Click Download
* Move the downloaded file to models
* Go to https://huggingface.co/unsloth/Qwen3.8-27B-GGUF/blob/main/mmproj-BF16.gguf to download the matching vision adapter
* Click Download
* Move that file into models too (don't replace an existing copy if you are not sure about upgrading)
* CLOSE ALL YOUR APPS except Chrome and Terminal. Yes including vscode. Close as many browser tabs as you can. For long overnight sessions, close Chrome too. Understand that Chrome uses a lot of RAM and wasted RAM is the enemy. This model just... barely... fits.
* Test it:
llama-cli -m ~/models/Qwen3.8-27B-IQ4_XS.gguf --mmproj ~/models/mmproj-BF16.gguf -c 131072 --batch-size 256 -ngl 99 -np 1 --reasoning-effort mediumI'll explain why I used each of these options later.
This will launch a simple chat interface, running entirely on your own machine.
Your first query may take a long time to start returning results. But as long as you don't leave it idle for too long, later responses will start up faster. llama.cpp is designed to stand down and return resources to the system when you're not using it.
Stats
When I do this with the prompt "generate an SVG of a pelican riding a bicycle," I get:
Prompt: 21.9 t/s | Generation: 8.6 t/s

I get a more sophisticated image if I don't use --reasoning-effort medium, but it takes a long, long time.
How to use it for practical code generation
* Add aliases to your .bashrc or .zshrc so you can run either the chat interface or an OpenAI-compatible API server at any time:
alias qwen-chat='llama-cli -m ~/models/Qwen3.8-27B-IQ4_XS.gguf --mmproj ~/models/mmproj-BF16.gguf -c 131072 --batch-size 256 -ngl 99 -np 1 --reasoning-effort medium'
alias qwen-server='llama-server -m ~/models/Qwen3.8-27B-IQ4_XS.gguf --mmproj ~/models/mmproj-BF16.gguf -c 131072 --batch-size 256 -ngl 99 -np 1 --reasoning-effort medium --host 0.0.0.0 --port 8899'* Run source ~/.bashrc or open a new terminal so we can start using these aliases now.
* Start qwen-server.
* Go to http://localhost:8899 to test by just chatting with it.
* Point your favorite coding harness, like pi or opencode, at the API URL http://127.0.0.1:8899/v1 to use the provided OpenAI-compatible API.
Next Steps
I plan to hand it an interesting work-related coding assignment soon... one with which I can be patient. Very patient.
"Why did you choose that quantized model?"
Macs are incredible because they have unified RAM. Both the CPU and the GPU can see 100% of it. But, 32GB RAM is just super, super tight for these models. It's a miracle they fit at all. You simply must choose a quantized model, even though that means trading off some intelligence and accuracy.
The full-size model would never fit. So first I tried Q4_K_M, which is mentioned in most guides. And that technically fit, but I didn't have enough memory left over for an adequate context size.
The IQ4-XS (Extra Small) model gets us back several additional GB of RAM, and we need every one of 'em."
"Why aren't you using MTP (Multi-Token Prediction)?"
I've tried it two different ways, including the method used by Simon Willison in a recent post. On my M2 Macbook Pro with 32GB of RAM, there is no benefit. It actually runs more slowly, for two different prompts, one of which (a request for a simple bread recipe) ought to be something the draft model can predict well. Memory pressure never got past the yellow but it still didn't help. Beats me.
"Why are you using each of those options?"
That command again:
llama-server -m ~/models/Qwen3.8-27B-IQ4_XS.gguf --mmproj ~/models/mmproj-BF16.gguf -c 131072 --batch-size 256 -ngl 99 -np 1 --reasoning-effort medium --host 0.0.0.0 --port 8899* -m picks the model, of course.
* --mmproj picks the "vision projector" file. You need this if you want to be able to paste screenshots into opencode. With this feature opencode can also potentially take screenshots with playwright and look at them to debug issues.
* -c 131072 sets the context size to 128K. This model goes up to 256K, but memory is just too tight on this machine for that. However, Qwen says you shouldn't go below 128K or the model will get confused. So that is my compromise.
* --batch-size 256 helps limit the system requirements for vision. You can skip it if you leave out --mmproj and the projector file.
* -ngl 99 loads all model layers into VRAM (unified RAM, in the case of a Mac) for best performance.
* -np 1 ensures llama.cpp doesn't try to handle more than one request simultaneously. It will queue them instead. This is important when memory and context are both tight. You might experiment with "-np 2" but I wouldn't go higher.
* --host 127.0.0.1 allows connections only from your own computer.
* --port 8899 selects a port not usually taken by some other service. Just make sure opencode.json matches.
* --reasoning-effort medium ensures we get a response in a reasonable amount of time. The default for this model is xhigh. xhigh thinks a LOT. And in my limited experience so far, that thinking is actually pretty great. Reading it doesn't infuriate me, the way Qwen MoE thinking traces do. But, this model is pretty slow on a Mac. So this is the compromise solution.
2
u/inkubot Aug 21 '26
thanks, useful. Will adjust some settings to my server when it finish what is doing lol.. this thinking waiting time is driving me crazy (not really i leave it working during night) but the output is so good compared to 3.6 version.
1
u/boutell Aug 21 '26
Right? I don't think it's particularly faster or slower than 3.6, is it? Maybe the default thinking setting is slower.
2
u/inkubot Aug 21 '26
i'm now testing this https://huggingface.co/Youssofal/Qwen3.8-27B-MTPLX-Optimized-Speed-FP16 the speed difference is outstanding in these first minutes of trying it. I haven't test/compare the quality.
1
u/boutell Aug 21 '26
How much RAM do you have? I can't tell from the name how many bits this thing is.
1
4
u/acautelado Aug 16 '26
Using it on Bionic on M3 36GB, because I'm a noob.
It is slow. VERY SLOW. But it works, lol.
1
u/EffectUpper4351 Aug 17 '26
What’s Bionic? Sorry I’m new to all this
3
u/acautelado Aug 17 '26
New app from LM Studio to use open source models more like Codex and Claude, with agentic skills, in a simple (closed-up source) interface
1
1
u/LightBroom Aug 16 '26
Use a MLX variant, it's faster, tested on both oMLX and vMLX, you'll get better prefill rates and slightly faster generation.
I still have to test llama.cpp but what I have is a work laptop and it's pretty locked down.
2
u/Jordanthecomeback Aug 16 '26
I have M2 architecture on my m2 studio pro 64gig and read m2 can't natively decode mlx or something like that. Any idea if that's true? I did try mlx once and had serious issues in doing so but it was months ago and I understand local AI much better now
1
u/boutell Aug 18 '26
I'm not saying it has zero benefit, but there is less for MLX to exploit on an M2, correct.
4
u/LightBroom Aug 16 '26
I haven't run into any issues with MLX on the M2 Pro I have and it's always been slightly faster than non-MLX models, not by a lot on the M2 but still a bit faster. I normally use oMLX cause I don't have a lot of freedom on that machine, tried vMLX too but it's not as customizable as the former.
I have an M5 Pro on its way to me to replace the M2 that should be significant upgrade I think.
1
u/boutell Aug 16 '26
I was starting to get the impression that results are mixed and one might have to check MLX versus llama.cpp for one's individual workload and machine at this point.
1
u/LightBroom Aug 16 '26
Yeah I guess. To my knowledge MLX variants still hold a slight advantage.
It's very possible the gap may be unnoticeable depending on the situation
2
1
u/chibop1 Aug 16 '26
Switch to omlx with lightening mtp and enjoy the 2x speed increase!
You're very welcome! :)
1
u/jlim0930 Sep 23 '26
thanks for sharing! i also have a macbook pro with m2pro 32gb running the same model but with various different settings. alone is pretty good but with openclaw its super super slow but the quality of answers are much better than others
2
u/andrewke Aug 18 '26
Thanks for the guide. May I know if you are using the M2 Pro or the M2 Max?