oMLX: The KV Cache Moved to Disk, and Local Agents Got Usable

· Dev & Open Source · Apple Silicon · MLX · LLM inference · KV cache · macOS

oMLX 0.8.5 pages KV blocks to SSD and restores matching prefixes, cutting author-reported follow-up TTFT on 50–100K-token agent prompts from 30–90 s to 1–3 s. Third-party decode numbers lag llama.cpp 3–7×.

oMLX: The KV Cache Moved to Disk, and Local Agents Got Usable

24.5k stars in ten months for a Mac server that treats KV blocks like disk pages.

Executive Takeaway: oMLX 0.8.5 is an Apache-2.0 inference server for Apple Silicon that keeps prefill work instead of discarding it. Block-based KV cache spills from RAM to SSD and is restored on prefix match, which the author measures as 30–90 s of first-token wait collapsing to 1–3 s on 50–100K-token agent prompts.

The mechanism is borrowed, not invented: paged KV blocks from vLLM, prefix sharing with copy-on-write, continuous batching from mlx-lm, and a two-tier hot-RAM / cold-SSD store. What is new is the packaging — a native SwiftUI menu bar app, a multi-model engine pool with LRU and TTL, and OpenAI plus Anthropic endpoints in one install.

oMLX admin dashboard: per-model status badges, live memory, and load/unload controls
oMLX admin dashboard: per-model status badges, live memory, and load/unload controls

jundot/omlx on GitHub (Apache-2.0)

1 · What Actually Changed

The unit of reuse moved from the request to the token block.

Older local servers treated a changed prompt as a new prompt. oMLX hashes and pages KV blocks, so a shifted prefix costs a partial recompute instead of a full one.

Tiered KV cache: RAM hot, SSD cold

Write-back hot tier, safetensors cold tier

Blocks spill to disk when RAM fills and return on a matching prefix, even after a restart:

  • Hot tier: frequently hit blocks stay in unified memory.
  • Cold tier: overflow persists as safetensors under --paged-ssd-cache-dir.
  • Budget: auto takes 50% of free disk plus existing cache.
Hot in-memory tier feeding a cold SSD tier: blocks are restored, never recomputed
Hot in-memory tier feeding a cold SSD tier: blocks are restored, never recomputed

Prefix sharing with copy-on-write

Divergent branches stop invalidating siblings

Two agent sessions that share a system prompt share the same blocks. Only the divergent tail is written, so a tool-heavy loop keeps its cache across turns.

Continuous batching, 8 by default

mlx-lm BatchGenerator behind a FCFS scheduler

Concurrency is capped by --max-concurrent-requests (default 8). Batching lifts aggregate tokens per second; it does not lower single-stream latency.

Engine pool: LRU, TTL, pinning

Several model types inside one process

LLM, VLM, embedding, reranker and decision engines coexist. LRU evicts under pressure, pinned models stay resident, per-model TTL unloads idle ones, and a process memory enforcer (default RAM − 8 GB) blocks system-wide OOM.

Menu bar app: native SwiftUI

Not an Electron shell around a web UI

Start, stop and monitor without a terminal, with per-model usage heatmaps and crash auto-restart. A CLI shim at ~/.omlx/bin/omlx lets scripts and Shortcuts drive the same server.

2 · Benchmarks & Landscape

Every headline number here is vendor-reported unless a third party is named.

The author's Show HN thread and the repo docs are the only sources for the latency claims. Where a figure comes from an internal doc benchmark, the hardware and prompt length are stated.

First-token latency: 90 s to 1 s

The claim behind the launch

On 50–100K-token agent prompts the author reports 30–90 s per request without reuse and 1–3 s with SSD-restored prefixes. The chart plots the reported endpoints, not a distribution.

Batch scaling: 58.7 to 243 tok/s

M3 Ultra 512 GB, Qwen3-Coder-Next 8-bit

One request decodes at 58.7 tok/s; eight concurrent requests reach 243 tok/s aggregate. That is 4.1× from 8× concurrency — real batching, but clearly sublinear.

KV compression costs ~10% decode

Affine4 numbers from the repo docs

Measured on an M3 Ultra with Qwen3.8-27B-oQ4e-mtp and a 32,767-token prompt. Full-attention KV drops from 2.00 GiB to 0.52 GiB; the saving is paid for at decode.

KV formatPrefill tok/sDecode tok/sPeak GiB
Native BF16407.228.74.66
Affine8398.126.13.68
Affine4397.925.73.19

It grew out of vllm-mlx 0.1.0

Credits line as the changelog

The repo's own credits list exactly these as the additions: multi-model serving, tiered KV caching, VLM with full paged cache, an admin panel and a menu bar app.

Layervllm-mlx 0.1.0oMLX 0.8.5
ServingOne modelEngine pool + LRU
KV cacheRAM onlyRAM + SSD tier
VLM cache—Full paged support
ControlCLIAdmin UI + menu bar
APIsOpenAIOpenAI + Anthropic

3 · Limits & Counterarguments

The 90× figure is a best case on one machine, not a benchmark suite.

Third-party benchmark: 3–7× slower

M1 Max 64 GB, same model family

A Hacker News commenter measured Gemma 4 26B-A4B class weights on an M1 Max: llama.cpp about 395 tok/s prefill and 40 tok/s decode versus oMLX about 350 and 5–13. One report on an older 0.3.x build, but it is the only third-party number in the thread.

Native kernels are a build tax

Without full Xcode, GLM-5.2 falls to 29 tok/s

GLM-5.2, MiniMax M3 and Qwen3.5 need custom Metal kernels. Command Line Tools alone cannot build them (xcrun: unable to find utility "metal"); the DMG ships them precompiled, source builds need the Metal toolchain.

The SSD tier is a disk tenant

Budget grows, cleanup is manual

auto claims 50% of free disk plus existing cache and does not shrink on its own. Users in the HN thread already ask about caches that "pile up until you notice you must delete them manually" — plan a prune task or set a hard --paged-ssd-cache-max-size.

Memory guard: default RAM − 8 GB

Safety ceiling, not a tuning suggestion

A 64 GB Mac hands at most 56 GB to all loaded engines combined. Raise --memory-guard-gb and concurrency deliberately; the defaults favour not freezing your desktop over throughput.

Mac-only, no CUDA main path

MLX is the engine, not one backend among many

A CUDA helper exists only for the experimental prefill accelerator. Teams with mixed NVIDIA fleets end up running two stacks and two sets of numbers.

4 · Decision Playbook

Adopt for long-prompt agent loops on one Mac; wait if you need CUDA parity or audited throughput.

Judge it on your own prompt shape. The cache wins when the prefix is long and slowly shifting; it wins nothing when every request is a fresh document.

Adopt now, or wait

Two different machines, two answers

Adopt: single-Mac agent workflows (Claude Code, Codex, OpenCode) with 64 GB or more unified memory and 50K+ token contexts. Wait: multi-tenant serving, NVIDIA fleets, or procurement that needs a reproducible benchmark harness.

One-hour eval, no lock-in

Reuses an LM Studio model directory

brew tap jundot/omlx https://github.com/jundot/omlx
brew install jundot/omlx/omlx --with-custom-kernel
omlx start
curl -s localhost:8000/v1/models | jq '.data[].id'

Tune the cache first

Sizing beats model shopping

omlx serve --model-dir ~/models \
  --paged-ssd-cache-dir ~/.omlx/cache \
  --hot-cache-max-size 20% \
  --max-concurrent-requests 16 \
  --memory-guard-gb 48

Measure PP/TG yourself

The built-in benchmark is the honest test

The admin benchmark reports prefill and generation tokens per second with partial prefix-cache hits. Send the same 35K-token agent prompt twice, cold then warm, and compare against llama.cpp before you migrate a team.

Built-in benchmark: prefill and generation tok/s with partial prefix-cache hit testing
Built-in benchmark: prefill and generation tok/s with partial prefix-cache hit testing

5 · Verified Sources

Primary docs, the author's thread, and the community numbers.

Primary: jundot/omlx repository

Release notes: oMLX 0.8.5

Show HN: oMLX SSD-backed KV cache (author thread)

Docs: Affine4 KV cache benchmarks

Community benchmark table (675,285 runs)

中文导读:oMLX:把 KV 缓存搬上磁盘,本地 Agent 才真正可用

oMLX 把 KV 块分页落到 SSD,命中前缀即恢复:作者自测 5 万–10 万 token 的 Agent 首 token 从 30–90 秒降到 1–3 秒;但第三方实测解码落后 llama.cpp 3–7 倍。

Primary Sources & References

  1. jundot/omlx on GitHub
  2. oMLX 0.8.5 release notes
  3. Show HN: oMLX SSD-backed KV cache (author thread)
  4. Docs: Affine4 KV cache benchmarks
  5. oMLX community benchmarks