Memory is super tight with Qwen 3.8 27B even with 64GB?!
Hey, I'm running an Apple MBP M1 Max 64GB with Bionic, and using Qwen 3.8 27B. I am unsure which quantization Bionic is using; I downloaded all three variants in LMStudio before. Context according to Bionic is now 164K.
Without anything else running, I am at 92-93% RAM usage! I am wondering where all that memory is going, even with 164K context. Is there any way to save some memory? Or I may need to force bionic to use the 6bit quant.
About this post
- Posted
- Archived
- Score
- 10 · 78% up
- Kind
- Text
- ID
- 1vpsof8
19 comments
Make sure you don't have the "Keep model in Memory" setting on in Bionic. Go to Settings -> Library click the gear icon on the model and make sure it is turned off.
this also
Thanks, I will try this. I am guessing it will now only load layers into the unified memory that it currently needs for computation?
Yes. To be more clear: The full model is always loaded to unified memory, unless it is too big, then it goes to swap.
Keep Model in Memory is basically (technically a bit different) a copy of the model in RAM so you can reload the model faster without having it loaded from SSD again. Great if you have the free memory and/or reload often to test different settings. Aside of that pretty much useless.
Does that explains it a bit better?
My 48GB A6000 fits the 8 digit weight comfortably at max supported ctx len (llama.cpp and Q8 weight)... seems strange 64GB on Mac would be tight.
164K context is almost certainly your real problem, not the quant. KV cache size scales with context length, so at 164K you could be adding tens of extra GB on top of the model weights themselves — that adds up fast even before you factor in which quant you're on.
A few things worth checking:
Find out which quant Bionic is actually loading. Check the file size on disk in LM Studio for whatever model it's pointing at — roughly Q4 ≈ 16GB, Q6 ≈ 22GB, Q8 ≈ 29GB, BF16 ≈ 56GB. Bionic apparently doesn't surface this clearly, which is annoying but worth confirming directly.
Drop context way down and see what happens. I ran the same model (Q8, 8-bit) at 32K context on an M5 Pro 64GB and it handled a genuinely massive multi-part reasoning + coding task without ever touching swap, peaking around 49GB. 164K is over 5x that — try 32K-64K first and watch what your memory usage actually does.
If you genuinely need very long context regularly, KV cache quantization becomes worth the tradeoff at that point — it costs you a bit of accuracy but saves real memory. At 92-93% RAM usage with zero headroom you're closer to system-wide slowdown risk than a quality problem worth optimizing around.
Worth watching Activity Monitor's actual Swap Used number while you test rather than trusting the app's context/memory display — that's the only number that tells you if you're actually in trouble.
What coding harness were you using? It must be fairly capable if it works well with only 32k of context, and I need to pick one to start with!
LM Studio and Llms Studio Bionic. I ran it at Q8 quant, 32K context, on an M5 Pro 64GB and it held up well for a genuinely hard architectural/coding task.
The quantization was Q8, I had not downloaded the BF16. I still find it impossible to preselect the Quantization in Bionic, the only reliable way is deleting all other quants.
Yes, I reduced context to 64K and am now sitting at roughly 80% memory usage. That made a big difference! Fairly sure it was swapping before. It is much faster now.
So I take it you enable quantization for both and set them to Q8 each?
Good catch to ask — actually no, I ran mine with KV Cache Quantization OFF entirely for that test, full-precision cache the whole way. That's part of why it used the memory it did at 32K.
If you're seeing real gains from enabling it and dropping to 64K, that tracks — quantizing the K/V cache (in LM Studio there are usually separate bit settings for each, both can be set to Q8) trades a bit of accuracy for real memory savings, which sounds like it's exactly what fixed your swap problem.
For what it's worth, there's a thread going around right now (someone tested Qwen 3.8 27B against a real codebase, had Sonnet 5 grade the output) where multiple people pointed at quantized KV cache as the likely source of most of the minor errors it made. So there is a real tradeoff there — just seems like in your case it was worth it to stop swapping. If accuracy on something important ever seems off, that's the first knob I'd try turning back down.
I have the same and you should use quant 8 or lower. If you use the full model you will have no room left for a context window.
Dense models context is no joke
Yes, done! Model = Q8, and KV Cache = Q8. Context is limited to 64K. I'll see how it works out.
Try unsloth studio and their UD Q5 K M XL , it basically performs the same as Q8 which is amazing and it can def fit your ur ram budget at full contex (set KV to Q8 too)
Bf16 is 54gb. If you have 64gb to play witb,you do not have enough vram for bf16 AND 165k uncompressed kv cache/context.
Either compress your kv cache, pick a lower context, or pick a lower quant (q8 would be absolutely fine).
Yeah I would be running a q4 or q5 quant of the model itself, in addition to lowering context and these other suggestions.
You need to use turbo quant 4 and 3 for your KV cache.
Have you ran commands to allow more memory freed from the OS? I’m running 3.8-27b full 8bit on a 64GB M2 with max context and model in memory with these commands. Can’t do much else while it’s running due to memory constraints though.
To set:
sudo sysctl iog.wired_limit_mb=61440
Confirm status:
sysctl iogpu.wired_limit_mb
You have to run the command after a reboot unless you add it to a startup script. If it doesn’t work or you don’t like it just reboot and the setting is gone. Give it a shot.