MacBook Air M2 AI Engineering Guide | Generated by AI

Home 2026.05

Here’s what your MacBook Air M2 (16 GB unified memory) looks like right now:

Memory: critically tight

This is an M2 with unified memory — there’s no separate VRAM. The GPU shares the same 16 GB as everything else. When you run ML workloads here, you’re competing with WeChat and Chrome.


Optimizations for AI Engineering on This Machine

1. Quantization — GGUF 4-bit for everyday inference

llama.cpp with Metal backend is the baseline:

# Install llama.cpp with Metal support
brew install llama.cpp
llama-cli -m model.Q4_K_M.gguf -n 256 --mlock

For 7B models at Q4_K_M: ~4.5 GB RAM. Leaves ~11 GB for system. Q8_0: better quality, ~7 GB — still workable if you close other apps.

2. MLX — The real platform for M2

MLX is Apple’s native framework. It leverages the unified memory intelligently and can use the ANE (Neural Engine) which is separate bandwidth:

pip install mlx mlx-lm

For inference AND fine-tuning on 16 GB, MLX is by far the best option:

from mlx_lm import load, generate
model, tokenizer = load("mlx-community/Llama-3.2-3B-4bit")

3. Stop using swap — close the heavy hitters

Process Memory Fix
WeChat 265 MB Close if not needed
WebKit tabs 250 MB × N Close excess tabs
GitHub Desktop 236 MB CLI git saves 200+ MB
Zend (Zed) 144 MB Already lean

Replace GitHub Desktop with gh CLI. Safari heavy tabs → close or suspend.

4. ML training — don’t

The 16 GB M2 with no discrete GPU VRAM is not a training machine. Use it for:

Reserve actual training for:

5. Memory monitoring toolkit

# Quick check
memory_pressure | grep "free percentage"
vm_stat | head -1
sysctl vm.swapusage

# Watch GPU pressure
sudo powermetrics --samplers gpu_power -n 1 -i 2000

6. For your workflow (AI engineer, API-first, agent builder)

Your actual workflow doesn’t need local GPU at all — you route to OpenRouter, RTX 4070, and AMD cloud. On this MacBook:

Want me to set up any of that — close memory hogs, kill swap, or set up your ideal AI development stack on this machine?


Back Donate