Skip to main content

Disk KV restore for hybrid MoE models on Apple Silicon. A Qwen-specialised fork of Rapid-MLX that keeps a 122B model warm on a Mac.

Project description

qMLX qMLX

Keeping a hybrid 122B warm on a Mac.
A Qwen-specialised fork of Rapid-MLX for long-context serving of hybrid MoE models on Apple Silicon.

Website · Docs · charted


Why this exists

Qwen3.5-122B-A10B is a hybrid: about 75% of its layers are DeltaNet (recurrent, linear-attention) and 25% are full attention. The recurrent state cannot be rewound to an earlier position, so the standard in-memory prefix cache drops every entry that contains those layers. On this model it misses 100% of the time. In a normal window we measured zero in-memory hits against 109 disk hits.

So the only thing that keeps the model warm is disk KV restore: checkpoint the attention KV to SSD, page it back on the next turn. It is not a fallback here, it is the entire cache. qMLX is that subsystem built properly, plus the fixes needed to make it hold on real agentic-coding traffic.

The result: a follow-up question on a 130,000-token conversation goes from a multi-minute cold prefill to a sub-second restore. Measured on an M3 Ultra, a repeated 32k prompt drops from 88 seconds of prefill to 0.64 seconds, 137x faster.

What is in it

  • Disk KV checkpoint and restore for hybrid recurrent + attention MoE caches, with int4 checkpoints dequantised on restore.
  • Matchable-aware disk-cap eviction so the checkpoint the next turn needs never gets evicted by unmatchable interval writes.
  • Honest, phase-split metrics: real decode tok/s (decode window only), real prefill throughput (excludes cached tokens), disk-restore hit rate, TTFT. No amortised (prompt+gen)/wall throughput lie.
  • Live divergence logging that pinpoints the exact token where a prefix-cache match broke, so this class of bug is diagnosable in minutes.

Status

Alpha. It runs one model (Qwen3.5-122B-A10B) on one class of machine (M3 Ultra, 96GB+ unified). Qwen-first, and honest about what is built and what is not. Decode slows gradually with context because the dense-attention layers re-read a growing KV each token, but there is no cliff: it stays usable well past 100k tokens on this hardware. Windowed attention to flatten that curve further is on the roadmap.

Install

From source (this is a fork, not published to PyPI under its own name):

git clone https://github.com/marzukia/qMLX.git
cd qMLX
pip install -e .

Serving

rapid-mlx serve mlx-community/Qwen3.5-122B-A10B-4bit \
  --text-only --host 0.0.0.0 --port 8095 --max-num-seqs 1 \
  --enable-prefix-cache --prefix-cache-index radix \
  --enable-disk-kv-restore --kv-disk-checkpoint-interval 256

Drop-in OpenAI / Anthropic API, same as upstream. --text-only is required: the vision path is incompatible with the hybrid continuous-batching that the cache work depends on.

Credit

Forked from raullenchai/Rapid-MLX. The base engine, the OpenAI/Anthropic API surface, and the MLX serving path are theirs. qMLX adds the hybrid-aware disk restore, the eviction and metrics work, and the Qwen specialisation. We went a different direction on hybrid attention, too fundamental to reconcile in a PR, hence the fork.

Notes

The package is still imported as vllm_mlx and the CLI is still rapid-mlx; those are kept as functional identifiers for compatibility. rapid_mlx_* metric names, RAPID_MLX_* env vars, and the ~/.cache/rapid-mlx/ cache path are unchanged for the same reason.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qmlx_serve-0.11.0.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qmlx_serve-0.11.0-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file qmlx_serve-0.11.0.tar.gz.

File metadata

  • Download URL: qmlx_serve-0.11.0.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for qmlx_serve-0.11.0.tar.gz
Algorithm Hash digest
SHA256 d30674440a264f3805d64bd695444a21239c5ed103740253bd2399be32a04507
MD5 0af12e308cff20750a7a3ff2be65abb8
BLAKE2b-256 cd64dfbfce1a2b82ed7b15c2fbb008b8d492cdb319359a87c26e333e4e21ba20

See more details on using hashes here.

File details

Details for the file qmlx_serve-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: qmlx_serve-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for qmlx_serve-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4acf84b24efb193dccb8dafc80764762d2395a8609c92d14ab897fbd9a6e567b
MD5 f4459d7edbdfcaadf79354b2fbfa3d92
BLAKE2b-256 02c6623eeb152f885aea4bedda39e203bebdd73921832d45fd74d2d4f5be5eac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page