TurboQuant-MLX
Extreme weight and KV cache compression for LLMs on Apple Silicon. MLX implementation of Google's TurboQuant (Zandieh et al., 2025): Hadamard rotation + Lloyd-Max codebooks applied both to weights (compile time) and the KV cache (run time). Data-free: no calibration set, no retraining.
📖 Documentation: manjunathshiva.github.io/turboquant-mlx: get started, pick a model for your Mac's memory, and guides for converting, serving, coding agents, vision models and expert streaming.
Supports dense models (LLaMA, Qwen, Mistral), Mixture-of-Experts (Qwen-MoE, GPT-OSS, Qwen3.5-MoE, Qwen3.6-35B-A3B, Qwen3-235B-A22B, DeepSeek-V2, Poolside Laguna, Kimi K3 2.8T, Qwen3.8-Flash-Next 180B), Mamba/attention hybrids (Nemotron-3-Nano-4B, Nemotron-3-Super-120B, Nemotron 3.5 Super VL 120B), and multimodal models (Muse Glimmer, Qwen3.8-27B, Qwen3.8-Flash-Next, Nemotron 3.5 Super VL, and the block-diffusion DiffusionGemma). Compatible with hybrid attention architectures, attention sinks, sliding-window attention, and linear attention layers (including Gated DeltaNet).
With both weight and KV cache compression at 3-bit, GPT-OSS-120B fits its full 131K context window in 50 GB on a 64 GB MacBook — and KV cache compression actually makes generation faster on the 120B (8.7 vs 6.4 tok/s) because the smaller cache cuts memory bandwidth more than dequant costs.
Expert streaming runs MoE models whose weights exceed available RAM by paging only the router-selected experts from disk per token — e.g. the 35B-parameter Qwen3.6-35B-A3B runs on a 16 GB Mac mini in under 4 GB of RAM, with output bit-identical to the fully-resident model. See Models bigger than RAM.
Local coding — Qwen3.6-27B, a dense SWE-bench-grade coder, runs fully resident on a 48 GB Mac at 3-bit (~13 GB on disk, ~17.5 GB at runtime) and serves to Cursor / VS Code over an OpenAI-compatible endpoint. See Local coding agents.
Ternary (1.58-bit) experts shrink the biggest MoEs enough to run fully in memory: Qwen3.6-35B-A3B in 9.4 GB on a 16 GB Mac mini, Qwen3.5-122B in 30.9 GB on a 48 GB Mac, and Poolside Laguna S-2.1 118B and NVIDIA Nemotron 3.5 Super VL 120B on a 64 GB Mac. See Choose a model.
Key Results — Weight Compression
| Model | Method | Bits | PPL | Size | Gen Speed (M4 Max) |
|---|---|---|---|---|---|
| Qwen2.5-7B | TurboQuant | 3 | 8.92 | 3.5 GB | — |
| Qwen2.5-7B | Affine | 3 | 13.37 | 3.3 GB | — |
| GPT-OSS-20B | Affine (mlx-lm) | 4 | — | 11.2 GB | 148 tok/s |
| GPT-OSS-20B | MXFP4 (original) | 4 | 83.04 | 12.8 GB | — |
| GPT-OSS-20B | TurboQuant | 4 | 72.63 | 11.2 GB | — |
| GPT-OSS-20B | TurboQuant | 3 | 78.60 | 9.3 GB | 73 tok/s |
| GPT-OSS-120B | Affine 4-bit (mlx-community) | 4 | — | 65.8 GB | Doesn't fit 64GB |
| GPT-OSS-120B | MXFP4 (original) | 4 | — | 63.5 GB | Doesn't fit 64GB |
| GPT-OSS-120B | TurboQuant | 3 | — | 48 GB | 44 tok/s |
| GPT-OSS-120B (hybrid for 48GB) | TQ 3-attn / 2-experts, gs=32 | 2/3 mix | — | ~35 GB | 42–50 tok/s |
| GPT-OSS-120B | TurboQuant | 2 | — | 32 GB | 51 tok/s (poor quality) |
| Qwen3.5-122B-A10B | BF16 (original) | 16 | — | ~240 GB | Doesn't fit 64GB |
| Qwen3.5-122B-A10B | TurboQuant | 3 | — | ~50 GB | 26.5 tok/s (64 GB) · streams on a 16 GB Mac mini |
| Qwen3.5-122B-A10B (ternary experts) | TQ 3-attn / ternary trit-packed experts, gs=64 | 1.6/3 mix | — | 30.9 GB | ~25 tok/s* (0.29.0: ~13) · 32.5 GB peak, resident on 48 GB Macs without sysctl · 6/6 stress |
| Qwen3.6-35B-A3B | TurboQuant, gs=32 | 3 | — | ~16 GB | ~60 tok/s (resident) · runs in <4 GB via streaming |
| Qwen3.6-35B-A3B (ternary experts) | TQ 3-attn / ternary trit-packed experts, gs=64 | 1.6/3 mix | — | 9.4 GB | ~17 tok/s* fully resident on a 16 GB Mac mini (0.29.0: ~10.4) · ~55 tok/s* M4 Max (0.29.0: ~33) · chat; not for agent harnesses |
| Qwen3.6-35B-A3B (ternary + 4-bit expert-down) | TQ 3-attn / ternary experts / 4-bit expert-down, gs=64 | 1.6/3/4 mix | — | 12.6 GB | ~17 tok/s* on a 16 GB Mac mini (sysctl; 0.29.0: 15.2–15.6) · Opencode agentic 3/3 |
| Qwen3.6-27B (dense coder) | TurboQuant, gs=32 | 3 | — | ~13 GB | ~14 tok/s (resident) · fits 48 GB, SWE-bench coder |
| Qwen3-235B-A22B-Instruct-2507 (hybrid) | TQ 3-attn / 2-experts, gs=32 | 2/3 mix | — | 70.5 GB | ~4–6 tok/s (64 GB, 40 GB cache) · converts + streams on a 16 GB Mac mini |
| Qwen3-235B-A22B-Instruct-2507 (full 3-bit) | TurboQuant, gs=32 | 3 | — | 103 GB | ~1.3 tok/s (64 GB, 40 GB cache) · recall-critical sibling, passes 6/6 stress |
| Qwen3-235B-A22B-Instruct-2507 (ternary experts, 1.58-bit) | TQ 3-attn / ternary trit-packed experts, gs=64 | 1.6/3 mix | — | 53 GB | ~9–12 tok/s* (64 GB; 0.29.0: 5.6) · fully resident, no streaming |
| Nemotron-3-Nano-4B | TurboQuant | 3 | — | ~2.2 GB | 75.6 tok/s |
| Nemotron-3-Super-120B-A12B | BF16 (original) | 16 | — | ~240 GB | Doesn't fit 64GB |
| Nemotron-3-Super-120B-A12B | TurboQuant | 3 | — | ~50 GB | 18.7 tok/s |
| Nemotron-3-Super-120B-A12B (hybrid for 48GB) | TQ 3-attn / 2-experts, gs=32 | 2/3 mix | — | ~36 GB | ~27.2 tok/s |
| Laguna-XS.2 (33B agentic coder) | TurboQuant, gs=64 | 3 | — | 13.8 GB | 46.8 tok/s · 32 GB Mac · Opencode pass |
| Laguna-S-2.1 (118B) | BF16 (original) | 16 | — | ~219 GB | Doesn't fit 64GB |
| Laguna-S-2.1 (118B) | Affine 4-bit (mlx-community; since removed from Hugging Face) | 4 | — | ~64 GB | Exceeds Metal's ~56 GB working set — won't load |
| Laguna-S-2.1 (118B, ternary experts) | TQ 3-attn / ternary trit-packed experts, gs=64 | 1.6/3 mix | — | ~27 GB | ~20–28 tok/s* (0.29.0: ~12.5) · fully resident on 64 GB with ~25 GB spare · Opencode pass |
| Kimi K3 (2.8T MoE) | TQ 3-attn / ternary experts / 4-bit expert-down, gs=64 | 1.6/3/4 mix | — | 931 GB | 2.3 tok/s (Mac Studio 512 GB, top-8) · 1.2 tok/s at native top-16 · streams experts from disk |
| DiffusionGemma-26B-A4B (block-diffusion MoE) | Affine 4-bit (mlx-community) | 4 | — | 15.0 GB | ~35 tok/s |
| DiffusionGemma-26B-A4B | TurboQuant, gs=32 | 3 | — | 13.8 GB | ~4.6 tok/s · experimental: slower than 4-bit |
| DiffusionGemma-26B-A4B (16 GB build) | TQ 3-attn / 2-experts, 6 layers protected at 3-bit / 8-bit extras, gs=32 | 2/3 mix | — | 9.79 GB | ~1.5 tok/s on a 16 GB Mac mini (sysctl) · experimental |
| Muse Glimmer (30B dense VLM) | Affine 4-bit | 4 | 4.3798 | 19.88 GiB | 26.1 tok/s · leaves embedding + vision tower at bf16 |
| Muse Glimmer (30B dense VLM) | TurboQuant, gs=64 | 4 | 4.3315 | 14.88 GiB | 9.4 tok/s · better PPL than affine 4-bit in 25% less space |
| Muse Glimmer (30B dense VLM) | TurboQuant, gs=64 | 3 | 5.0454 | 12.53 GiB | 10.9 tok/s · smallest coherent build |
| Qwen3.8-27B (dense 27.8B hybrid-GDN VLM) | BF16 (original) | 16 | — | 55.6 GB | Needs a 64 GB Mac just to load |
| Qwen3.8-27B | Affine 4-bit (mlx-community) | 4 | 7.2685 | 14.95 GiB | 29.7 tok/s — fastest 4-bit, but peaks 16.16 GiB: won't fit 16 GB |
| Qwen3.8-27B | TurboQuant, gs=64 | 4 | 7.2496 | 15.15 GiB | 11.3 tok/s · best PPL of the three · Opencode agentic pass · vision 4/4 |
| Qwen3.8-27B (16 GB build) | TurboQuant, gs=64 | 3 | 8.0052 | 11.55 GiB | 12–13.6 tok/s (M4 Max) · verified on a real 16 GB Mac mini: 13.61 GiB peak, 3.7 tok/s, vision passes |
| Qwen3.8-Flash-Next (180B MoE, 512 experts) | Affine oQ2 (Vontra) | 2 | — | 63.03 GiB | Too big to load resident on a 64 GB Mac |
| Qwen3.8-Flash-Next | imatrix iQ-MLX 3.3 bpw (ddalcu, for mlx-serve) | 3.3 | — | 50.6 GiB | Fits 64 GB per its card; not measured here |
| Qwen3.8-Flash-Next | TQ 4-attn / 2-experts / 2-bit affine n-gram table, data-free | 2/4 mix | 9.31 | 52.00 GiB + 0.84 GiB vision | 16–18 tok/s · fully resident on 64 GB · vision passes |
| NVIDIA Nemotron 3.5 Super VL 120B (VLM, 512 experts, top-22) | BF16 (original) | 16 | — | 249 GB | Doesn't fit 64GB |
| Nemotron 3.5 Super VL 120B | NVFP4 (NVIDIA) | 4 | — | 63.0 GiB | Doesn't fit resident on a 64 GB Mac |
| Nemotron 3.5 Super VL 120B (ternary experts) | TQ 3-attn / ternary trit-packed experts / 8-bit affine extras, gs=64 | 1.6/3 mix | — | 29.29 GiB | ~16–21 tok/s, measured on 0.30.0 (2× 0.29.0 on the same prompts) · fully resident on 64 GB at default settings · 36K context · text 6/6, vision 3/3 |
| Nemotron 3.5 Super VL 120B (3-bit) | TurboQuant, gs=64 | 3 | — | 50.22 GiB | ~19–21 tok/s · 64 GB with sysctl + --prefill-step-size 256 |
* Estimated for 0.30.0, not measured. 0.30.0 makes ternary experts decode faster (the kernels no longer do an integer division per weight). These figures come from kernel timings at each model's expert shapes, calibrated against the model's measured speeds; the same estimate predicted 20.4 tok/s for Nemotron 3.5 VL, which measured 21.0. The 0.29.0 figures in parentheses were measured.
Key Results — KV Cache Compression
| Model | KV cache config | KV size | Speed | Notes |
|---|---|---|---|---|
| GPT-OSS-20B (FP16 weights) | FP16 KV | 27.0 MB | 90.6 tok/s | baseline |
| GPT-OSS-20B (FP16 weights) | TQ 3-bit KV | 7.79 MB | 29.9 tok/s | 3.5x cache savings |
| GPT-OSS-120B (TQ 3-bit weights) | FP16 KV | 45.0 MB | 6.4 tok/s | baseline |
| GPT-OSS-120B (TQ 3-bit weights) | TQ 3-bit KV | 11.83 MB | 8.7 tok/s | 3.8x cache savings — and faster than FP16 |
| GPT-OSS-120B (TQ 3-bit weights) | TQ 4-bit KV | 12.21 MB | 16.0 tok/s | also clean |
| Qwen3.5-122B (TQ 3-bit weights) | FP16 KV | 161.06 MB | 5.4 tok/s | baseline |
| Qwen3.5-122B (TQ 3-bit weights) | TQ 3-bit KV | 150.17 MB | 5.7 tok/s | output identical to FP16 |
KV cache compression projects to ~7 GB RAM saved at 131K context on GPT-OSS-120B and ~5 GB at 262K on Qwen3.5-122B. Roundtrip cosine similarity vs FP16: 0.983 at 3-bit, 0.995 at 4-bit.
On the Qwen3.5-122B KV rows: they used symmetric 3-bit KV on a short prompt. Fully resident with the recommended K8/V3 cache, FP16 decodes faster on that model, so there KV compression is a memory win, not a speed win; the decode speed-up is specific to GPT-OSS-120B. See KV cache compression and #19.
Community results from an Apple M5 Pro (48 GB), contributed by @sbayer2 (#14, #16), are on the Benchmarks page: resident and streaming speeds, a KV cache sweep against context, and the cache-budget sweep for the 48 GB tier.
Install
pip install turboquant-mlx-full
The package is published as turboquant-mlx-full on PyPI and imported as turboquant_mlx.
- macOS on Apple Silicon (M1 or later)
- Python 3.11+ (mlx-lm 0.32 needs it; on 3.10, pip installs turboquant-mlx-full 0.28.x)
- The Metal kernels are compiled by MLX on first use: no Xcode or CMake needed
Optional extras:
pip install "turboquant-mlx-full[vlm]" # vision and diffusion models via mlx-vlm (>= 0.7.9)
pip install "turboquant-mlx-full[eval]" # perplexity benchmarking (datasets, transformers)
pip install "turboquant-mlx-full[kimi]" # Kimi K3's tiktoken-based tokenizer
From source: git clone https://github.com/manjunathshiva/turboquant-mlx.git && cd turboquant-mlx && pip install -e . (see CONTRIBUTING.md).
Quick start
1. Will it fit? turboquant-plan reads only the safetensors headers (a few hundred KB, over the network for a Hugging Face repo), so you know before a multi-GB download:
turboquant-plan --model manjunathshiva/Qwen3.6-35B-A3B-tq3a-tqTe-down4-g64
Projection at 16,384 tokens of context
weights 12.59 GB
KV cache 0.34 GB (20.0 KB/token, hybrid: 10/40 full-attention layers)
prefill workspace 1.07 GB (estimate, at --prefill-step-size 2048)
runtime reserve 1.00 GB (buffer cache, activations, fragmentation)
----------------------------------
peak 15.00 GB of 61.85 GB usable 46.85 GB headroom
Verdict: ✅ RESIDENT — fits fully in memory
When a model fits only with a raised GPU memory limit or a smaller prefill step, it prints the exact sysctl line and flags. turboquant-doctor adds a read-only readiness check of the model files and machine.
2. Run it.
turboquant-generate --model manjunathshiva/Qwen3.6-35B-A3B-tq3a-tqTe-down4-g64 \
--prompt "Why is the sky blue? Explain in simple terms." --max-tokens 300
3. Serve it over an OpenAI-compatible API at http://localhost:8080/v1, for apps, Cursor, VS Code or a coding agent:
turboquant-serve --model manjunathshiva/Qwen3.6-35B-A3B-tq3a-tqTe-down4-g64 --port 8080
4. Convert your own (BF16 or FP16 weights of a supported architecture; minutes, no calibration data):
turboquant-convert --hf-path meta-llama/Llama-3.2-1B --mlx-path ./llama-3.2-1b-tq3 --bits 3 --group-size 64
Documentation
manjunathshiva.github.io/turboquant-mlx
- Get started and Choose a model for your Mac's memory
- Guides: Convert a model (mixed precision, ternary experts, the streaming converter for 200B+ models) · Generate text · Serve an OpenAI-compatible API · Local coding agents · Vision models · Models bigger than RAM · KV cache compression · Memory and macOS settings
- Models, one page per family with run commands, measurements and how each build was made: GPT-OSS · Qwen3.5-122B-A10B · Qwen3.6-35B-A3B · Qwen3.6-27B · Qwen3-235B-A22B · Nemotron-3 · Nemotron 3.5 Super VL · Poolside Laguna · Kimi K3 · Sarvam MoE · Muse Glimmer · Qwen3.8-27B · Qwen3.8-Flash-Next · DiffusionGemma
- How it works · Benchmarks · Command line · Python API · Supported architectures · Changelog
How it works
- Randomized Hadamard rotation makes any weight distribution close to Gaussian, with no data.
- Group and scale: each group of 32, 64 or 128 weights is divided by its root-mean-square.
- Lloyd-Max codebook: each weight snaps to the nearest centroid of the quantizer that is optimal for a Gaussian, a mathematical constant rather than something fitted.
- Pack the indices into 32-bit words at 2, 3 or 4 bits, or as base-3 trits for the ternary
{-c, 0, +c}expert tier (~1.6 bits per weight).
Fused Metal kernels decode straight from the packed form, so full-precision weights never exist in memory. The result: near-zero quality loss at 3-bit, and usable 2-bit and ternary experts on large MoEs where affine quantization breaks down. The same rotation and codebook compress the KV cache at run time. More.
Supported architectures
LLaMA, Qwen2/2.5, Qwen3.5/3.8 (text and vision), Mistral, Qwen1.5-MoE, GPT-OSS, Qwen3.5-MoE and Qwen3.6, Qwen3-MoE, Nemotron-H, DeepSeek-V2 (MLA + MoE; V3 shares the layout but is untested), and through mlx-vlm Muse Glimmer, NVIDIA Nemotron 3.5 Super VL and DiffusionGemma. Poolside Laguna, Kimi K3 and Sarvam MoE are ported to MLX here, and Qwen3.8-Flash-Next is vendored from an open mlx-lm pull request. Status and tested sizes for each: Supported architectures.
Contributing
Issues and pull requests are welcome; see CONTRIBUTING.md (commits need a DCO sign-off) and SECURITY.md for reporting vulnerabilities.
Citation
@misc{turboquant_mlx,
title={TurboQuant-MLX: Extreme Weight and KV Cache Compression for Apple Silicon},
year={2025},
note={MLX implementation of TurboQuant (Zandieh et al., 2025) for both weight quantization and runtime KV cache compression}
}
License
Apache-2.0 (LICENSE, NOTICE), from v0.3.0. Versions 0.1.x–0.2.0 were released under MIT (LICENSES/MIT.txt).
Acknowledgments
- TurboQuant — Zandieh, Daliri, Hadian, Mirrokni (2025)
- MLX — Apple Machine Learning Research
- mlx-lm — MLX language model utilities
Metadata
Release files for turboquant-mlx-full 0.30.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| turboquant_mlx_full-0.30.0.tar.gz | 407.1 kB | With provenance | Details |
Release files / turboquant_mlx_full-0.30.0.tar.gz
| Download URL | turboquant_mlx_full-0.30.0.tar.gz |
|---|---|
| Size | 407.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44c3778a616e91d1f33fe7fa7562976020918308750acdf92d21099932bef7ee
|
|
BLAKE2b-256 checksum How to use checksums |
df3150898e9137577ae98b62a87f40c0474dfbec7207bde00978a7e2269590cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for turboquant-mlx-full 0.30.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 1 file in this release has been uploaded with provenance metadata.
Attestation for turboquant_mlx_full-0.30.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.