pickuma.
AI & Dev Tools

Running Local LLMs on a 24GB M4 Mac: What Actually Fits

How much of 24GB the GPU can use, which models fit at 4-bit (Qwen 3.5/3.6, Gemma 4, gpt-oss-20b), measured M4 speeds, and Ollama vs LM Studio vs MLX.

Updated 2026-11-19 10 min read
Diagram: Bar chart of approximate 4-bit model sizes on a 24GB M4 Mac: 7B dense at 4.7 GB, 14B dense at 9.0 GB and gpt-oss-20b at 14 GB fit an ~18 GB budget; 32B dense at 20 GB fits only after raising the GPU limit; 70B at ~44 GB won't fit.

Animated diagram: Bar chart of approximate 4-bit model sizes on a 24GB M4 Mac: 7B dense at 4.7 GB, 14B dense at 9.0 GB and gpt-oss-20b at 14 GB fit an ~18 GB budget; 32B dense at 20 GB fits only after raising the GPU limit; 70B at ~44 GB won't fit.

Apple’s M4 chip put unified memory into laptops and desktops that don’t require a server budget. For developers who want to run language models without an API bill, the 24GB MacBook Air or Mac mini is the cheapest serious entry point. The question isn’t whether local LLMs work on it — they do. The question is which models fit, how fast they run, and where the cliffs are.

Short answer: on a base 24GB M4, plan on about 18GB for model weights plus context. Dense models up to about 14B at 4-bit fit with room to spare. Mixture-of-experts (MoE) models up to about 20B total fit and run fast. 27B-32B models squeeze in only after you raise the GPU memory limit, and 35B MoE and 70B models don’t fit at all.

What fits in 24 GB

Sizes below are Ollama download sizes from each model’s library page, at the default 4-bit-class quantization. “Default budget” means the ~17-19 GB the GPU can use without changing any settings (explained in the next section).

Size classExample Ollama tagsDownload sizeFits the default budget?Notes
7B-9B denseqwen2.5-coder:7b, qwen3.5:9b4.7 GB; 6.6-7.6 GBYesLots of room for long context
12B-14B densegemma4:12b, qwen2.5-coder:14b7.7-8.0 GB; 9.0 GBYesThe comfortable ceiling for dense models
20B MoE (3.6B active)gpt-oss:20b14 GBYes~3-5 GB left for context
26B MoE (3.8B active)gemma4:26b16-19 GBBorderlineOne report hit the GPU limit at Q4 and switched to a 12 GB Q3 build
27B-32B denseqwen3.6:27b, gemma4:31b, qwen2.5-coder:32b18-19 GB; 19-20 GB; 20 GBOnly after raising the limitShort context, other apps closed, slow
30B MoE (3.3B active)qwen3-coder:30b19 GBOnly after raising the limitFast per token, but little room for context
35B MoEqwen3.6:35b, qwen3.5:35b22-23 GBNoNeeds a 32GB+ Mac
70B dense—~40 GB+ (math below)NoNot close

Sources for the sizes: Ollama library pages for qwen2.5-coder, qwen3.5, qwen3.6, gemma4, gpt-oss, and qwen3-coder. The Gemma 4 and Qwen 3.5/3.6 tags are multimodal (Ollama lists text and image input), so part of each download is the vision component. Parameter counts come from the model cards: gpt-oss-20b is “21B parameters with 3.6B active” (Hugging Face), Gemma 4 26B-A4B is 25.2B total with 3.8B active (Hugging Face), Qwen3-Coder 30B has “3.3B activated” (Ollama), Qwen3.6-35B-A3B has 3B activated (Hugging Face), and Qwen3.6-27B is dense (Hugging Face).

The memory math

Weights ≈ parameters × bits per weight ÷ 8. A “4-bit” Q4_K_M file works out to roughly 5 bits per weight once the higher-precision layers are included: qwen2.5-coder:32b is 32B parameters and a 20 GB download (32 × 5 ÷ 8 = 20). The same math puts a 70B model at about 70 × 5 ÷ 8 ≈ 44 GB, which is why 70B is out of reach on any 24GB Mac. gpt-oss uses MXFP4, where the MoE weights are “quantized to 4.25 bits per parameter” (Ollama), so its 21B parameters come to 14 GB.

Then add context. The KV cache grows with context length, and how fast it grows depends on the architecture. Add a few hundred MB of compute buffers on top. In one published llama.cpp load of Gemma 4 26B-A4B on a 24GB Mac, compute buffers took 523 MB and a q4_0-quantized KV cache at 16K context took 174 MB (Kartit). At the other end, llmcheck estimates that Qwen 3.6-35B-A3B with a 64K-token, 16-bit KV cache needs about 26 GB in total (llmcheck; their figure is an estimate from the model config, not a measurement). As a planning rule, leave 1-3 GB of the budget free for short-to-moderate context, and more for long coding-agent sessions.

MoE models fit by total size but run by active size. Every expert has to sit in memory, so the 21B-parameter gpt-oss-20b needs its full 14 GB. But each token only reads the active parameters (3.6B), which is why an MoE model generates far faster than a dense model of the same file size.

How much of the 24GB the GPU can use

Unified memory means your CPU and GPU share one pool. macOS does not let the GPU wire all of it. Metal reports the default cap as recommendedMaxWorkingSetSize, which llama.cpp prints at startup; Apple does not document the formula. On a 24GB machine that is about 17.2 GB on macOS 15 (two-thirds of RAM, the pattern public logs show on 32GB-and-smaller Macs) and about 19 GB on macOS 26 and later (17.76 GiB in reports from mlx-video and MoltenVK). Some machines report less: one 24GB M4 Pro run hit a Metal limit of about 16 GB (Kartit). Read your own value from that log line. As a rounded planning figure between those two defaults, plan on ~18GB for model weights plus KV cache.

You can raise the ceiling with the iogpu.wired_limit_mb sysctl, which takes megabytes:

sudo sysctl iogpu.wired_limit_mb=20480   # let the GPU wire up to 20 GB
sudo sysctl iogpu.wired_limit_mb=0       # back to the system default
  • The name is confirmed by MLX’s docs. The mlx.core.set_wired_limit page says a wired limit above the system limit is an error, and gives sudo sysctl iogpu.wired_limit_mb=<size_in_megabytes> as the way to raise the system limit (MLX docs). The same page says the MLX function is “only useful on macOS 15.0 or higher.”
  • It does not survive a reboot. It needs no reboot to take effect, it is not persistent by default, and 0 restores the default (devnote). Making it permanent through /etc/sysctl.conf may require disabling SIP, per the same note.
  • Older macOS used a different key. On Ventura and earlier it was debug.iogpu.wired_limit, in bytes (devnote).
  • On 24GB, every GB you give the GPU comes out of macOS. The devnote recommends leaving 8-16 GB for macOS and other processes, which a 24GB Mac can’t do once you raise the limit to fit a 20 GB model. Raising it to 20480 leaves about 4 GB for everything else, so expect swapping unless you close other apps.

How fast it runs: measured numbers, then estimates

Measured on a base M4 (both from llama.cpp’s Apple Silicon benchmark thread, run with llama-bench):

ModelHardwarePrompt processing (512 tok)Generation
LLaMA 7B Q4_0 (3.56 GiB)M4, 10-core GPU, 120 GB/s221 tok/s24.1 tok/s
qwen2.5-coder:7b Q4_K_M (4.36 GiB)Mac mini M4, 24 GB, macOS 26.4240 tok/s22.6 tok/s
llama3.2:3b Q4_K_M (1.87 GiB)Mac mini M4, 24 GB, macOS 26.4530 tok/s46.0 tok/s

Those runs land at roughly 75-90% of the simple bandwidth ceiling (120 GB/s ÷ file size). That ceiling gives a usable estimate for sizes nobody has published base-M4 numbers for. The figures below are estimates, not measurements, and real speed will be lower:

  • 12B-14B dense (8-9 GB): ceiling ~13-15 tok/s. Usable interactively, but you will watch it type.
  • 27B-32B dense (18-20 GB): ceiling ~6 tok/s. Fine for a batch job, painful for chat.
  • 20B-30B MoE (3.3B-3.8B active, about 2 GB read per token): ceiling roughly 50-70 tok/s. Real MoE throughput lands well below that ceiling: Kartit measured 49 tok/s for Gemma 4 26B-A4B at Q3 on an M4 Pro (Kartit), a chip with 2.3x the base M4’s bandwidth. We found no published base-M4 measurement for these MoE models.

Prompt processing (the time before the first token) scales with prompt length. At ~220-240 tok/s for a 7B model, a 4,000-token prompt means a wait of more than 15 seconds before output starts, and bigger models are slower. For agentic coding workflows that put a whole file into context, this matters more than steady-state tokens/sec.

Which model to start with

  • For coding agents and tool use: qwen3.5:9b. Johanna Larsson tried several models on a 24GB M4 MacBook Pro in LM Studio. Qwen 3.6 at Q3, GPT-OSS 20B, and Devstral Small 24B “technically fit in memory but were in practice unusable”, and Qwen 3.5-9B was the one she kept, with working tool use and a 128K context (jola.dev). She also found it much weaker than frontier models: it loops and misreads requests unless you guide it step by step.
  • For the most capability that fits: gpt-oss:20b. At 14 GB it is the largest model in the table that fits the default budget with room for context, and its 3.6B active parameters keep it fast for its size. Larsson’s verdict above shows that “fits” is not the same as “works well for agents” — test it on your own task before committing.
  • For a 26B MoE: Gemma 4 26B-A4B at Q3, through llama.cpp. Kartit’s Q4_K_M attempt on a 24GB Mac exceeded the Metal GPU limit with a compute error. A 12 GB Q3_K_XL build, a q4_0 KV cache, flash attention, and --no-mmproj (which skips the vision encoder) brought total GPU use to about 13 GB (Kartit).
  • For 27B-32B dense (qwen3.6:27b, gemma4:31b, qwen2.5-coder:32b): only with the wired limit raised, other apps closed, and short context. At an estimated ~6 tok/s ceiling, most people will prefer a smaller model or a 32GB+ Mac. Our 30B and 70B memory guide covers the larger configurations.

For a deeper comparison of MoE options on this exact memory size, see picking an MoE model for a 24GB Mac with MLX. If you are deciding between 16GB and 24GB, the 16GB M4 guide covers the smaller budget.

Ollama vs LM Studio vs llama.cpp vs MLX

Four tools, overlapping audiences.

Ollama gives you a model registry, automatic downloads, and a REST API on localhost:11434. The CLI is one command: ollama run qwen3.5:9b pulls and starts the model. Its OpenAI-compatible endpoint at /v1/chat/completions means most existing client libraries work without changes. On Apple silicon, Ollama now has an MLX engine: the March 2026 preview asked for “a Mac with more than 32GB of unified memory” (Ollama), and a June 2026 post runs it through -mlx tags such as gemma4:12b-mlx without stating a memory minimum (Ollama). Ollama 0.30 also added GGUF support through llama.cpp, which “augments Ollama’s MLX engine on Apple silicon” (Ollama). One caveat from April 2026: Kartit reported that Ollama’s tool-call parser lost Gemma 4 tool calls and moved to llama.cpp (Kartit). That is a single report, so check the current release.

LM Studio is the GUI option. It runs llama.cpp (GGUF) models, and “on Apple Silicon Macs, LM Studio also supports running LLMs using Apple’s MLX” (LM Studio docs). It requires macOS 14.0 or newer and recommends 16GB+ of RAM (LM Studio).

llama.cpp is the engine under most GGUF tools. Use it directly when a model is a tight fit or you need flags the wrappers hide: quantized KV cache (-ctk q4_0 -ctv q4_0), flash attention (-fa on), skipping the vision projector (--no-mmproj), speculative decoding, and grammar-constrained output. Kartit’s Gemma 4 26B setup above is a working example of those flags on a 24GB Mac.

MLX is Apple’s own ML framework. The mlx-lm package runs models in MLX format (look for mlx-community/*-4bit repos on Hugging Face). On the same model and quantization, MLX is often faster than llama.cpp on Apple Silicon, though the gap varies by model and version. The downside is a smaller ecosystem than GGUF. If you only need one model for a specific app, MLX is worth benchmarking.

A note on Cursor: pointing Cursor’s OpenAI base URL at localhost:11434 does not work, because “Cursor’s servers try to call localhost on their own machines, not yours,” and Tab autocomplete always uses Cursor’s own model (ngrok). A tool that runs on your machine avoids both problems.

OpenCode

OpenCode is a terminal coding agent that runs on your machine. It probes Ollama at 127.0.0.1:11434 and discovers installed models, and it also supports LM Studio's local endpoint, so the agent can use a model running on your own Mac.

Try OpenCode

Affiliate link · We earn a commission at no cost to you.

When Local Beats Cloud

Local LLMs aren’t replacing frontier cloud models for every task. The honest tradeoff: the models that fit in 24GB lose to current frontier models on hard reasoning, long-context retrieval, and instruction following. Larsson’s experience with Qwen 3.5-9B is typical: useful as a research assistant and a rubber duck, unreliable when left to finish multi-step work alone (jola.dev).

Where local wins:

  • Privacy-sensitive code review: you control where the prompt and source go, the same argument behind running a coding agent against a local model.
  • Batch processing: a 5,000-document summarization job over a weekend costs you electricity, not API tokens.
  • Offline development: airplanes, training rooms, anywhere the WiFi is unreliable.
  • Tool-use prototyping: iterate on tool schemas without paying for each test run.

If your workflow is “ask a hard question once a day,” cloud models are still the right answer. If it’s “make 500 cheap calls a day to summarize, classify, or draft,” the math favors hardware you already own.

What this article did not test

  • No model was run for this article. Model sizes are Ollama download sizes; the GPU budget comes from public recommendedMaxWorkingSetSize reports.
  • Measured speeds are other people’s llama-bench runs, cited above. Every other tokens/sec figure is a bandwidth-ceiling estimate, and real speed is lower.
  • We found no logged, minute-by-minute test of sustained LLM inference on the fanless M4 MacBook Air, so throttling is not quantified here.
  • Power draw, battery life, and answer quality were not measured.

FAQ

Which models can I run in Ollama on a 24GB MacBook Air or Mac mini M4?
Anything up to about 14 GB comfortably: qwen2.5-coder:7b (4.7 GB), qwen3.5:9b (6.6-7.6 GB), gemma4:12b (7.7-8.0 GB), qwen2.5-coder:14b (9.0 GB) and gpt-oss:20b (14 GB). gemma4:26b (16-19 GB) is borderline. 27B-32B models and qwen3-coder:30b (18-20 GB) need the GPU limit raised, and 35B MoE models (22-23 GB) do not fit. Sizes are from the Ollama library pages.
How many parameters can an M4 with 24GB of RAM run?
At 4-bit, about 14B dense parameters with room for context, or about 20B total in an MoE model such as gpt-oss-20b. 27B-32B dense models fit only after raising iogpu.wired_limit_mb, with short context and other apps closed. 70B needs roughly 40 GB or more at 4-bit and does not fit.
How do I increase the GPU memory limit on a Mac for MLX or llama.cpp?
Run sudo sysctl iogpu.wired_limit_mb=<megabytes>, for example 20480 for 20 GB. MLX's documentation names this sysctl as the way to raise the system wired limit. The setting takes effect without a reboot, resets when you restart, and a value of 0 restores the default. On a 24GB Mac, every GB you give the GPU is a GB macOS and your apps can no longer use.
Can I run a 32B model at Q4 on a 24GB Mac, and how much context do I get?
Barely. qwen2.5-coder:32b is a 20 GB download, which is above the default GPU budget of about 17-19 GB. After raising the wired limit to around 20-21 GB, only a small KV cache fits, so expect short context and an estimated ceiling of about 6 tok/s on a base M4. Quantizing the KV cache in llama.cpp (-ctk q4_0 -ctv q4_0) stretches context further.
What is the best MoE model for a 24GB Mac?
gpt-oss-20b (21B total, 3.6B active, 14 GB) is the MoE model that fits the default budget with room for context. In one published 24GB setup, Gemma 4 26B-A4B at Q4 exceeded the GPU limit and a ~12 GB Q3 build worked, and Qwen3-Coder 30B (19 GB) needs the GPU limit raised. 35B-A3B models such as Qwen 3.6 (23 GB) need a 32GB+ Mac.
Does the fanless MacBook Air M4 throttle during long LLM runs?
The MacBook Air is fanless, so sustained load is limited by passive cooling. We found no logged, reproducible throttling measurement for long LLM runs, so we cannot give a reliable percentage. For short interactive sessions, memory and bandwidth matter more than cooling; for overnight batch jobs, a Mac with active cooling is the safer choice.
Will a 16GB M4 Mac work for local LLMs?
Yes for 7B-9B models at 4-bit, but you'll be tight. By default the GPU can use about 11.5 GB on macOS 15 and about 12.7 GB on macOS 26 and later, and macOS and your apps share what is left. 24GB is the practical floor for 14B models and gpt-oss-20b.
Is MLX worth switching to from Ollama?
For exploration, no — Ollama's registry and OpenAI-compatible API save time, and Ollama now has its own MLX engine on Apple silicon through -mlx model tags. For an app where you've picked one model and want extra throughput, benchmark mlx-lm against llama.cpp on that model.
How much battery does running a local LLM drain?
Continuous inference keeps the GPU busy, so battery drains much faster than in normal use while a model is generating. This article did not measure power draw. Idle Ollama with no active generation costs almost nothing — by default it unloads models after 5 minutes of inactivity.

Tools used in this review

Some links above are affiliate links. We may earn a commission if you sign up. See our disclosure for details.

Related reading

See all AI & Dev Tools articles →

Get the best tools, weekly

One email every Friday. No spam, unsubscribe anytime.