L5 · 03 · On-device AI: Apple Silicon, Core ML & MLX

Running models on the device — not a server — is a different discipline: hard memory limits, battery budgets, the Neural Engine alongside CPU and GPU, and privacy as a feature. This page is a deep dive into on-device inference, centred on Apple silicon (unified memory, Core ML, MLX), with the general principles that apply to any edge device.

Level 560 minTracks 13, 18Last verified 2026-10

By the end of this page you can

Why on-device is different

ServerOn-device
Big GPUs, abundant power & coolingWatts and battery; thermal throttling
Memory for many large modelsA few GB shared with the whole OS/apps
Throughput = serve many usersLatency for one user; responsiveness
Data leaves the devicePrivacy: data never leaves. Works offline.
The pitch On-device wins when privacy is a requirement, latency must be instant, there's no connectivity, or per-token cost at scale is unacceptable. It loses when the task needs a frontier model. Increasingly the answer is hybrid: small model on-device for most things, a big model in the cloud for the hard cases.

Apple silicon's three engines

CPUgeneral, low-latency, control GPUparallel matrix work, flexible Neural Engine (ANE)ML ops, most power-efficient all share unified memory — no copying between them

The three ways to run a model on a Mac

PathBest forNotes
Core MLShipping in apps (iOS/macOS). Converts models to .mlpackage, routes ops to ANE/GPU/CPU.Most integrated; powers on-device features; conversion step required
MLXResearch/dev on Apple silicon; familiar NumPy-like API; LoRA fine-tuning.Fast iteration; mlx-lm for LLMs; not the production path for apps
llama.cppPortable GGUF inference, works everywhere incl. Mac (Metal).Simple, universal; not Apple-specific-optimised like Core ML

The on-device constraint checklist

Framework Models API (Apple's on-device LLM)

On Apple platforms there's a system-provided foundation model exposed to apps (Apple Intelligence's on-device model). Characteristics that matter for design:

Design pattern: the hybrid on-device app

CONFIDENCE_FLOOR = 0.75


def on_device(query: str) -> dict:
    """Small local model: cheap, private, offline. Returns a confidence."""
    # stand-in for Core ML / MLX model output
    simple = len(query.split()) <= 8
    return {"answer": f"local answer for {query[:24]!r}",
            "confidence": 0.9 if simple else 0.5}


def cloud(query: str) -> dict:
    return {"answer": f"cloud answer for {query[:24]!r}", "confidence": 0.98}


def answer(query: str) -> dict:
    r = on_device(query)
    if r["confidence"] >= CONFIDENCE_FLOOR:
        r["via"] = "on-device"
        return r
    r = cloud(query)            # escalate only the hard cases
    r["via"] = "cloud"
    return r


if __name__ == "__main__":
    for q in ["return policy?", "write a detailed comparison of our five return edge cases"]:
        r = answer(q)
        print(f"{r['via']:>9} ({r['confidence']})  {q[:40]}")
    assert answer("hi")["via"] == "on-device"
    assert answer("a very long complex question with so many words indeed")["via"] == "cloud"

Most queries stay private and instant on-device; only hard ones hit the network. This is the architecture pattern behind privacy-first AI features.

Privacy as a feature

On-device inference isn't just a constraint — it's a product capability: "your data never leaves the device." Health, personal documents, offline fieldwork and regulated industries all pay a premium for it. When you can answer "where does the data go?" with "nowhere", a whole class of L4·07 concerns disappears.

Try it (60 min, needs a Mac for parts)
  1. Run the same prompt through an on-device model (mlx_lm or a small Ollama model) and a frontier model. What does the small one do well? Where does it fall over?
  2. Measure tokens/s and battery/power feel during a long generation vs. a server call.
  3. Sketch the hybrid router for a real feature: which queries stay on-device, which escalate?

Key takeaways