PionRedis-compatible key-value store

1.1.4 · macOS Apple Silicon + Linux

Your Redis clients, on a durable store in one small binary.

Pion is a key-value store that speaks the Redis protocol: one small Mojo binary that Redis clients such as redis-cli and redis-py talk to unmodified. Every write goes to a write-ahead log before it is acknowledged, --maxmemory with Redis's eviction policies makes it a cache, and the same server does vector search over the RediSearch FT.* commands and keeps a prompt cache for mlx-lm.

redis-cliredis-pyyour appLMCachea restart after SIGKILLmlx-lm prompt cache pion-server
Installone binary, no toolchain
brew install pavelhorak/tap/pion
brew services start pion         # 127.0.0.1:1974; restarts at login and after a crash
redis-cli -p 1974 PING           # +PONG

The service starts with --kvcache --metal-attention --nle-embed, so the prompt cache (the four PionPromptCache lines) and the semantic cache work against it as installed. As a service, Pion keeps its WAL, snapshots and crash log in $(brew --prefix)/var/pion and logs to $(brew --prefix)/var/log/pion.log. pion-server is also on your PATH; run by hand, it writes its data to the directory you start it from.

Without Homebrew, the release tarball is on the install page.

Loopback by default, no TLS; a password flips the bind address. Read the security model before the server sees a network.

Usewith the client you have

Redis commands, Redis clients

355 command names (the generated command table), every one exercised by a dispatch sweep in five argument shapes, and a differential suite that compares replies against a real redis-server: strings, hashes, lists, sets, sorted sets, bitmaps, HyperLogLog, geo, streams and consumer groups, pub/sub, MULTI/EXEC/WATCH, TTLs, Lua. Every write goes to a write-ahead log before it is acknowledged; an acked write is still there after SIGKILL. --maxmemory with --maxmemory-policy makes it a cache, evicting by LRU, LFU, TTL or at random. redis-cli and redis-py, which the test suite uses, talk to it unmodified over RESP2 or RESP3. Reference: doc/command_matrix.md, doc/persistence.md.

redis-cli -p 1974 SET user:1 '{"name":"alice"}'
redis-cli -p 1974 GET user:1
Numbersagainst Redis 8.10.2

Throughput on one Linux server, both engines measured the same day

Against Redis 8.10.2, Pion wins some configurations and loses others. Every number below comes from one Linux server, an AMD EPYC 8124P (16 cores). Both engines were measured the same day with the same client settings: Redis 8.10.2 built from source, Pion built as the release builds it. The one-keyspace numbers are from 2026-10-12 (Pion 0.9.9). The all-cores and vector numbers are from 2026-10-06 (Pion 0.9.5). Raw output, scripts and method: 2026-10-12, 2026-10-06.

KV throughput (memtier, 256-byte values, 1:10 SET:GET over 1M keys, 30 s a run, median of 3, ops/sec):

One keyspace, ops/sec Redis, 1 thread Redis, io-threads 8 Pion, 1 thread Pion, --io-threads 8
P=1 110,044 386,278 114,909 515,267
P=10 640,985 1,661,596 895,149 2,972,713
P=50 979,984 1,368,935 1,703,363 3,909,190
All 16 cores, 16 independent keyspaces, ops/sec 16 Redis processes Pion -w 16
P=10 7,178,453 6,097,719
P=50 11,128,400 9,848,658

One keyspace, with I/O threads: Pion's --io-threads 8 leads Redis's io-threads 8 at every pipeline depth.

  • Ratios: 1.33× at P=1, 1.79× at P=10 and 2.86× at P=50.

  • Like for like: both count threads the same way, one thread that runs commands plus seven I/O threads, and the client runs on the same machine.

  • P=50: --io-threads 4 is faster still, at 4,431,024. One thread executes every command, and at that depth it is the limit.

Without I/O threads: Pion's single thread trails Redis's I/O threads at P=1 and P=10, and leads single-threaded Redis at every depth.

With durability on (P=10): Redis's AOF (everysec) against Pion's WAL, both at 8 I/O threads. Pion leads, 2,724,529 to 1,297,102 (2.1×).

Where I/O threads pay: on a server with cores to spare. On a Mac with the client on the same machine, they lower throughput, for Redis too (2026-10-10).

Across all cores: sixteen Redis processes beat Pion's sixteen workers by 13–18%, both sides as sixteen independent keyspaces.

Where it does not helpread before installing
13–18%

Across all 16 cores of one Linux server, both sides as sixteen independent keyspaces, sixteen Redis processes beat Pion's sixteen workers by 13–18%. Pion's lead over Redis is on one keyspace with I/O threads.

  • -w N is N independent keyspaces, not one shared keyspace. The server refuses to start with -w N > 1 unless you pass --independent-workers.
  • The default is one thread. Without --io-threads, Pion trails Redis with io-threads 8 at pipeline depths 1 and 10, and leads single-threaded Redis at every depth. I/O threads pay on a server with cores to spare; on a Mac with the client on the same machine they lower throughput, for Redis too.
  • No TLS. Loopback by default; terminate TLS at a proxy.
  • Eviction holds RSS, not allocator bytes. --maxmemory-policy evicts as Redis's policies do, but freed memory stays with the allocator, so RSS can sit somewhat over the limit after a burst.
  • Cluster mode is single-node. Slot migration and replication exist; production multi-node does not.
  • One program, one fixed prefix: use mlx-lm's own prompt-cache file. save_prompt_cache / load_prompt_cache ship with mlx-lm and answer faster than a Pion fetch: 37.0 ms against 69.0 ms at a 2,049-token prefix. Pion's prompt cache earns its place when several processes, tools or restarts share the cache.
  • The prompt cache caches prefill, not decode. If your bottleneck is tokens-per-second once generation starts, it changes nothing.
  • The reuse has to be real, and the prefix has to be long. Time to first token from a separate process, only the prefix length varying: 34 tokens → 1.4×. 268 → 4.6×. 1,035 → 12×. 2,049 → 17×. At short prefixes the saving is small — about 14 ms at 34 tokens, not worth a second process. The demo once printed a slowdown at a short prefix, and shipped that way for a while; it defaults to 2,048 now, and --prefix-tokens 33 shows how little there is to save.
  • The sparse selector is NIAH-class. Factual QA over dense paragraphs needs a query-aware selector; the default block-mean selector is built for finding a needle, not for reading every paragraph.
  • A large vector index that keeps taking writes. Vectors written since the last build are searched exactly, and during a rebuild every search is. At 500K vectors on an EPYC 8124P a query took 1.6 ms from the graph alone, 3.8 ms with 10,000 vectors written since, and 190 ms during the 84 s rebuild. An index loaded once and then queried pays none of this.
  • One maintainer, working evenings.
Also in the serversame binary, same port

Durable by default

Every write goes to an mmap write-ahead log before it is acknowledged, with segment rotation, snapshots, blob arenas for large values, crash breadcrumbs and a 1 Hz status file that survives an OOM kill.

mmap WAL + HNSW snapshot + V-store WAL

Loopback by default. No TLS, and --maxmemory holds RSS, not allocator bytes — read the security model first.

Vector search

HNSW with SIMD INT8 kernels over the RediSearch FT.CREATE/FT.SEARCH commands, the Redis 8 VSET commands (one vector set per key), BM25 and hybrid retrieval, and built-in text embedding on macOS (Apple's NLEmbedding, on in the Homebrew service).

QPS 7,339 at 10 clients on Linux at recall 0.960, 8,544 at 0.939 (Redis 8.10.2 vector sets: 8,039 at 0.920); 8,729 on an M4 Mac mini · Recall@100 0.960 at that QPS (Redis vector sets: 0.920); INT8, ef=150

One index per server; L2 and COSINE, anything else refused at FT.CREATE.

A prompt cache for mlx-lm

On Apple Silicon, PionPromptCache goes where mlx-lm's own prompt cache does, and a separate process, a restarted one or another tool reads the same cache over the Redis wire. Below: the four lines and the numbers.

It caches prefill, not decode, and pays only on long, reused prefixes.

Prompt cachefor mlx-lm on Apple Silicon

A drop-in for make_prompt_cache

On Apple Silicon, PionPromptCache sits where mlx-lm's own prompt cache does. The first run warms it; every later run — this process or another — hits.

get_or_prefill returns what mlx_lm.make_prompt_cache(model) would, with the prefix's K/V already in it. prefix_ids is the part every request shares (the system prompt, the few-shot block, the retrieved chunk); suffix_ids is the part that changes. The first process to ask pays the prefill once and stores it; every later call — this process, another one, or after a restart — fetches it. That is the cross-process row in the table below. The same-process row adds the Stage-2 attention patch, in which Pion computes the attention over the prefix itself (pion-vllm-mlx/README.md).

Runnable end to end against a running Pion: examples/prompt_cache_demo.py times vanilla mlx-lm's cold prefill against five cached requests, each followed by a full answer, and prints every one. Install with pip install 'pion-vllm-mlx[mlx]'.

It needs Pion running with --kvcache --metal-attention: the Homebrew service does that; otherwise start the binary with those flags.

from pion_vllm_mlx import PionPromptCache

pc = PionPromptCache(model, host="127.0.0.1", port=1974)                       # once per loaded model
cache = pc.get_or_prefill(prefix_ids, namespace="app|v1|llama-1b|system_v1")  # MISS: prefill once + store · HIT: fetch
text = generate(model, tok, prompt=suffix_ids, prompt_cache=cache)             # decode as usual, at native speed
Prompt cache numberswith their denominators

Time to first token, and what each row reads

Llama-3.2-1B-4bit, 2,049-token prefixfirst tokenwhat it readsvs cold
Cold prefill, vanilla mlx-lm1,193 msnothing
mlx-lm's own prompt-cache file, a fresh process37.0 msa 67 MB file (mmap)32×
Pion, same process46.2 msits own MLX arrays26×
Pion, from a separate process, over the wire69.0 ms67 MB over loopback TCP17×
Pion, from a separate process on the same machine37.0 msa file Pion wrote (V.EXPORT, mmap)32×

On the same machine, Pion hands over a file too. mlx-lm ships save_prompt_cache / load_prompt_cache, and mapping a file beats fetching the same rows over TCP, so a hit on the same machine maps a file Pion wrote when the prefix was stored: 37.0 ms, the file's own time. If one program reuses one fixed prefix, mlx-lm's file is the simpler tool (file_cache_ttft.py, raw output). Pion is for what a file does not do: one cache that any process, model object or tool reads over the Redis wire, an acked write that survives a crash, and in pion-vllm-mlx serve a longest-prefix match that a restarted agent or a second session finds without naming a file.

The Pion rows answer the same 16-token question after the same prefix, and differ only in where the cache comes from. The first is the process that computed it, which an in-process prompt cache also gives you. The second pays a wire hop for a cache a separate process wrote, and produces BLEU 1.000 on a 50-token greedy completion against the reference output: a different socket and a different model object, same text (test output). Vanilla here prefills the way mlx-lm's own generate_step does; the ratios this table showed until 2026-10-02 did not, and were too high (the changelog lists them).

Both rows come from one script, cross_process_ttft.py (--same adds the first), and its raw output for every run is published. The reproducers list what each one needs.

A third number: at 64K context, with a sparse mask that attends 0.80% of the prefix on each full-attention layer, Gemma-4-E2B-it-4bit still finds a single needle, and the warm call takes 124.4 ms against vanilla's 54.4 s cold prefill (437×). It is one needle at one depth, warm against cold (raw output). mlx-lm's prompt-cache file of the same prefix (405 MB) answers in 82.6 ms with dense attention over all of it (raw output). The example missed on 2026-10-06 because its prompt carried 397 <bos> tokens; it now carries one.

Prompt cache, comparedtwo rows are ours

Every competitor here does something well, and most of them do more than a table can show. Cells are what each project ships today (checked 2026-09-19; the mlx-lm column re-checked against mlx-lm 0.31.3 on 2026-10-07); the footnotes carry the sources.

LMCache (+vLLM) SGLang HiCache oMLX mlx-lm cache_prompt Pion
Cache shared across processes ✓ via remote store¹ ✓ L3¹ ✗ per-process² manual file ✓ wire-native
Survives restart ✓ ✓ ✓ SSD tier ✓ manual ✓
Crash-consistent (acked = durable) ✗ ✗ ✗ ✗ ✓ WAL†
KV quantization FP8; 4-bit demo³ FP8 ✓ TurboQuant ✓ --kv-bits⁵ fp16/int8/turbo4/INT3/INT2/mlx4g32
Hybrid (Mamba/GDN) prefix state in-process⁴ host + storage tiers⁴ in-process + SSD ✓ in the file⁵ cross-process + persisted
Sparse long-context selector ✗ ✗ ✗ ✗ ✓ block-mean, bit-identical decode
Apple Silicon ✗ (CUDA) ✗ (CUDA) ✓ ✓ ✓ (+ Linux CPU)
Redis wire / any RESP client ✗ ✗ ✗ ✗ ✓
Runs as vLLM plugin + service serving engine menu-bar app / server library one server binary

The two rows that are actually ours are crash-consistency and the shape of the sharing. Everything else on this list is a matter of degree.

Crash-consistent is not the same as persistent. LMCache's disk backend, SGLang's L3 and oMLX's SSD tier all persist, and all of them recompute on a miss — that is a perfectly good design. Pion's contract is narrower and stronger: an acked write is there after a SIGKILL.†

Shared across processes is not the same as distributed. LMCache does cross-instance sharing through a remote store, and that is its entire pitch; oMLX clusters by routing a request to the node that already holds the prefix, which is a different and reasonable answer. Pion is one process on one port that a different program, a different model object, or a different machine reads directly — no connector, no serving stack, no CUDA.

¹ LMCache ships local_disk_backend.py, p2p_backend.py and NIXL/remote connectors; SGLang HiCache L3 backs onto Mooncake/3FS/NIXL. ² oMLX per-node caches are private to the process; its cluster scheduler scores nodes on prefix affinity and routes to the hot one. An export/import API was requested by one user on 2026-09-12 (jundot/omlx#3612, converted to a discussion on 2026-10-05 with no votes); the same user's draft implementation (jundot/omlx#3615) is unmerged, and nothing has shipped. ³ LMCache demoed 4-bit KV with AMD on 2026-08-28. ⁴ vLLM merged hybrid prefix caching 2026-07-12 (vllm#46384), vllm-metal 2026-08-10 (#584); both share that state within a process. SGLang's HiCache tiers hybrid GDN/Mamba state to host memory and its storage backends as of 2026-09-21 (sglang#37507), inside its own serving stack.

⁵ mlx_lm.cache_prompt builds the cache with make_prompt_cache and writes it with save_prompt_cache, which serializes every cache class's state, the rotating sliding-window and recurrent (ArraysCache) layers included; --kv-bits quantizes the K/V. file_cache_ttft.py --workload ssm checks a Mamba model's recurrent state through the file, and --workload gemma a sliding-window model's, each against the cold path's first token (raw output).

† WAL durability is verified on macOS and Linux, V-store included: SIGKILL → restart replays the WAL and V.FETCH returns bit-equal data (max |Δ| = 0.0), validated on EPYC 8124P. tests/test_vstore_wal.py runs in Gate 2c on every gate.

If you run one server and never restart it, vLLM's automatic prefix caching already does this and you do not need Pion.

On oMLX specifically

oMLX is the best way to serve models locally on a Mac today, and if that is what you want, use it — a menu-bar app, continuous batching, a RAM+SSD tiered KV cache, TurboQuant KV, and cache-aware cluster routing across machines.

Pion is not a serving app and does not compete with it. oMLX keeps each node's cache private to its own process and routes work to whichever node is warm; Pion is a cache substrate that a separate process reads over a wire protocol, holds hybrid/SSM state across processes rather than within one, and makes an acked write survive a crash. The two compose, and Pion as a shared or remote tier underneath oMLX is a thing we would like to build.

One oMLX user asked for durable, portable prefix-cache artifacts so an agent session would stop re-prefilling 60–120k tokens after a reload (#3612, no votes, since converted to a discussion). It is one request, not a demand signal. They proposed a different shape from ours — an agent-owned file with a manifest, exported through oMLX's own API, rather than a server — so read it as evidence for the problem, not as a vote for Pion. The constraints they arrived at are the four Pion had to solve: carry the recurrent/GDN state and not only KV, pin the quantization parameters in the manifest, key on the exact token sequence rather than the text, and fail closed on any mismatch.


Use it fromwhat the tests use

Pion's tests talk to it through redis-cli, redis-py and LMCache's RESP connector. Other Redis clients speak the same protocol; the client page lists them, and they are not in the test suite. Runnable examples ship in examples/, each with its prerequisites stated: the prompt-cache demo, hybrid retrieval, 64K sparse-mask NIAH, agent memory across a restart.