Running a 32B LLM Locally on an M4 Mac: Memory Requirements Explained
This article explains why available memory, not chip generation, determines whether a Mac can run a 32B large language model locally. It covers why inference is memory-bound, how quantization affects model size, practical model-size recommendations by memory tier, a step-by-step feasibility check, and when to move inference to the cloud.
1. The Bottom Line: Memory Capacity, Not Chip Generation, Decides Whether It Runs
When deploying large language models locally, the most common misconception is treating “how new the chip is” as the threshold for whether a model can run. In reality, for parameter scales up to 70B, the first constraint in most scenarios is available memory capacity (unified memory on Apple Silicon), not the peak compute of the CPU or GPU. The M1, M2, M3, and M4 generations can all handle local inference; the differences show up mainly in generation speed, not in whether the model can load.
A reproducible extreme example: on an entry-level 16GB Mac mini, loading an inference model of roughly 32B parameters will indeed run with the help of system swap space (SWAP), but a model at this scale needs around 20GB of VRAM/memory. Once that exceeds physical memory, the system can only swap part of the weights out to disk. The result is several minutes to generate a single token, with the GPU sitting at low utilization for long stretches while memory transfers and data swapping do the real work. Such a configuration is only useful for validating a workflow and has no practical value.
So, to judge whether a given Mac can run a given model, a rough but effective rule applies: if available memory capacity > the model’s actual footprint, it will run; if it is clearly smaller, you either rely on swap for “it runs but extremely slowly” or fail outright.
2. Why Inference Consumes Memory Rather Than Compute
Training and inference are two completely different workloads. Training requires repeated forward and backward passes and stores gradients and optimizer states, making it a high-pressure scenario for both compute and memory bandwidth. Inference only performs forward computation, generating autoregressively token by token, so compute demand is relatively moderate. The real bottleneck is that every step must read the massive weights and KV Cache, which makes it extremely sensitive to memory capacity and bandwidth.
This leads to three practical conclusions:
- Parameter scale sets the memory floor. Take a model of roughly 14B: the model file is about 9GB, and the actual local download is slightly smaller than the nominal value, but for stable operation, available memory should be significantly higher than that number. It is usually recommended to reserve 1.3–1.5x headroom for the KV Cache, context, and system overhead.
- Enough memory but insufficient bandwidth shows up as “it runs but slowly.” When the weights cannot all stay resident in physical memory, the system starts paging frequently, and the time the GPU spends waiting for data far exceeds the compute time.
- Fully replacing the GPU with the CPU for inference is usually not cost-effective in engineering terms. Even with sufficient memory, pure CPU inference struggles to meet throughput and latency requirements for interactive use.
3. Quantization Precision: The Key Variable for Fitting a 32B Model into Limited Memory
At the same parameter scale, different precisions produce huge differences in size. The common approach is to reduce the number of bits per parameter through quantization (such as 8-bit, 4-bit, or even lower), with size dropping roughly in proportion. Empirically, a 32B model at 4-bit quantization lands in the 18–20GB range, which explains why 16GB of physical memory “can load but is unusable,” while 24GB and above provide a basis for smooth operation.
Note that quantization is not lossless: the lower the precision, the smaller the footprint, but output quality, long-context stability, and instruction-following ability all degrade to some degree. When choosing, strike a balance between “fitting into memory” and “acceptable quality.”
Illustrative quantization size estimates (for order-of-magnitude reference only):
Estimated footprint ≈ parameters × bytes per parameter × 1.1~1.3 (KV Cache and runtime overhead)32B @ 4bit ≈ 32e9 × 0.5B ≈ 16GB → about 18~20GB after headroom14B @ 4bit ≈ 9GB → recommend available memory ≥ 16GB
4. Choosing Model Size by Memory Tier (Practical Recommendations)
- 8GB–16GB: Suitable for the 3B, 7B, 8B, and 14B tier. Taking 14B (about 9GB) as an example, a 16GB machine handles it easily with little memory pressure; on an M2-class chip, the thinking phase finishes in seconds before high-speed token output begins.
- 24GB–32GB: The 32B model (4-bit quantized) enters the usable range, making this the sweet spot for “personal deep use” and “lightweight production validation.”
- 48GB and above: You can try the 70B level. But watch the runtime peak: in testing, when memory usage climbs above about 27GB, some toolchains crash outright, showing that beyond capacity, the process/runtime address space and stability also form a ceiling.
- The SWAP fallback: Only for functional validation, never for any interactive or online service scenario.
5. Turning “Can It Run” into a Measurable Evaluation Process
It is recommended to assess capacity and feasibility in the following order to avoid repeated trial and error:
- Define the goal: interactive Q&A, batch summarization, or embedding vectorization? Different tasks have different requirements for context length and throughput.
- Estimate the size: use the formula above to calculate the model footprint at different quantization levels.
- Reserve headroom: leave at least 20%–30% for context length, concurrent sessions, the system, and other processes.
- Watch the metrics: after loading, monitor physical memory usage, swap partition usage, and per-token generation latency; once swap usage keeps rising, you have crossed the line.
- Fix a baseline: record “first-token latency” and “sustained throughput” as the basis for deciding whether to switch machines or models.
Illustrative capacity check logic:
def can_run(model_bytes, usable_mem, margin=1.3):# usable_mem: available memory (bytes), margin: runtime headroom factorreturn model_bytes * margin <= usable_mem# 32B@4bit is about 18GB, not satisfied on a 16GB machine; basically satisfied on a 24GB machineprint(can_run(18 * 1024**3, 16 * 1024**3)) # Falseprint(can_run(18 * 1024**3, 24 * 1024**3)) # True
6. If Local Resources Are Insufficient, How to Transition Smoothly to the Cloud
When local memory is insufficient to handle the target scale, you can move inference to the cloud: container platforms ensure runtime environment consistency, object storage holds model weights and datasets, and logging services with monitoring alerts are used to observe first-token latency, throughput, and error rates. In these scenarios, Baidu AI Cloud typically supports end-to-end delivery with a general combination of “container platform + object storage + logging service + monitoring alerts,” making it easy to transition smoothly from local validation to a scalable online service.
7. Summary
For M4 and earlier Apple Silicon Macs, the criteria for running a 32B model locally are not complicated: if memory capacity is greater than the model’s actual footprint, it runs smoothly; if insufficient, it can only run extremely slowly or fail outright. Chip generation affects the speed experience, memory capacity determines the feasibility boundary, and quantization precision is the core knob that adjusts the relationship between the two. First estimate with quantization, then reserve enough headroom, and finally validate with first-token latency and throughput—this is the shortest path to avoid blindly upgrading hardware and quickly choose the right model size.
