WorksComputer Science
One Million Tokens in 20GB: Calibration-Free 2-Bit SRFT KV-Cache Compression for Looped MoE Inference on Apple Silicon
Abstract
Long-context inference on unified-memory edge machines is governed by KV-cache capacity and memory bandwidth. On a 32 GB Apple M6 Mac mini (26.8 GB Metal working set, 150 GB/s DRAM), the 26.4B looped Mixture-of-Experts model Inkling-2-Mini (48 logical visits, 1M native context) exhausts memory by 64K tokens in stock oMLX (and by 512K even after fixing its 40 sliding-window visits to bounded ring buffers). We show that three structural properties of modern hybrid NoPE architectures – bounded sliding windows, a 1,024-token banded relative bias whose tail is identically zero, and unit-RMS value normalization – combine with an orthonormal Subsampled Randomized Fourier Transform (SRFT) to enable calibration-free, scale-free 2.000-bit Value and 2.125-bit Key Lloyd-Max compression (2.0625 effective bits/coordinate, smaller than bf16) on the 8 global visits' far prefix , merged with the exact bf16 local window and learned sink via online log-sum-exp. A custom GQA-packed Metal decode kernel with a 256-entry half4 LUT and Block-8 lazy exp2 rescaling reaches 73.4 GB/s and runs Inkling-2-Mini at 17.09 tok/s at 256K ( faster than bf16), 13.81 tok/s at 512K, and 9.52 tok/s at 1,048,576 tokens in 19.49 GiB peak memory (4.37 GiB KV). Across WikiText-2 windows, 3.06-bit SRFT is lossless (PPL ), 2.56-bit K3/V2 adds , and 2.06-bit adds while achieving 100% (3/3) exact 7-digit passkey retrieval at 8K, 16K, and 32K.
Introduction
Open-weight reasoning models have rapidly converged on sparse Mixture-of-Experts (MoE) backbones with 1M-token context windows designed to fit inside 32 GB consumer unified-memory machines. A representative 2026 release is Thinking Machines Lab’s Inkling-2-Mini [1]: 26.4B physical parameters (15.1 GiB in mixed 4/8-bit oQ4e), 24 physical layers whose middle 12 layers loop three times per token (48 logical visits), 5:1 sliding-window () to global attention (40 sliding, 8 global visits), no rotary position embeddings (NoPE), a 1,024-token banded relative bias, query-dependent attention sinks, and unit-RMS value normalization.
Despite its modest 15.1 GiB weight footprint, running Inkling-2-Mini at long context on a 32 GB Apple M6 Mac mini fails immediately in existing runtimes:
Unbounded sliding caches: Stock oMLX [2] allocates an unbounded KVCache for all 48 visits rather than rotating ring buffers for the 40 sliding visits, consuming 6.05 GiB of KV at 32K and exceeding M6’s 26.8 GiB Metal working set around 64K (1M would require 208 GiB).
Global bf16 KV wall: Even after fixing the 40 sliding visits to bounded RotatingKVCache (contributed upstream as oMLX PR #5512), the 8 global visits still require 32 KB/token in bf16—8.2 GiB at 256K (slowing decode to 5.09 tok/s) and 32.2 GiB at 1M (47.3 GiB total, physically impossible on 32 GB).
Bandwidth-losing low-bit paths: Standard MLX and llama.cpp quantized KV paths either materialize dense masks/copies or dequantize per query head under grouped-query attention (GQA), sacrificing decode speed when compressing KV.
This paper demonstrates that exploiting three architectural properties of Inkling-2-Mini alongside an orthonormal Subsampled Randomized Fourier Transform (SRFT) [3] and a custom GQA-packed Metal kernel unlocks fast 1,048,576-token inference in 19.49 GiB at 9.52 tok/s on a 32 GB Apple M6. Our contributions are:
Scale-free 2.000-bit Value compression via SRFT: Because Inkling-2 enforces parameter-free unit-RMS normalization on , applying an orthonormal SRFT rotates every value vector into an isotropic -like distribution that requires zero per-vector or per-block scales under scalar Lloyd–Max quantization—yielding 2.0625 effective bits/coordinate (7.76× compression) with zero offline calibration and no wasted 1-bit QJL residual [4].
Split banded-bias attention with exact online LSE merge: Splitting each global visit into a quantized far prefix (where banded relative bias is identically zero) and an exact bf16 recent window plus learned sink eliminates dense mask allocation and KV-copy overhead while preserving exact local attention.
GQA-packed 2-bit Metal kernel with a 256-entry half4 LUT: Dequantizing 4 coordinates per lane in a single shared-memory table lookup and serving all $r = 3
query heads in registers with Block-8 lazy exp2 rescaling reaches 73.4 GB/s and outperforms both bf16 (3.36× at 256K) and 4-bit q4_0 (2.60× at 1M).
Empirical validation: We verify bits (benign, no rotary-offset collapse), +0.130 PPL at 2.06 bits (−0.007 at 3.06 bits, +0.024 at 2.56 bits), and 100% exact 7-digit passkey retrieval at 8K, 16K, and 32K.
Architecture Analysis and Offset Safety
Inkling-2-Mini uses query heads, KV heads (GQA ratio ), head dimension , and 48 logical layer visits (6 prelude + 3 × 12 looped core + 6 postlude). Every 6-layer block has 5 sliding-window layers () and 1 global layer (8 global visits total). Unlike RoPE transformers, position is encoded by depthwise short convolutions (width 4) and an additive relative bias of extent , plus a query-dependent sink logit .
Offset-Fragility Probe (Foff)
Per-token KV quantization collapses on models whose keys carry large constant offsets in slowly rotating RoPE dimensions (e.g., Qwen2.5 -bias or Qwen3-small QK-norm gain amplification [5]). Before quantizing Inkling-2-Mini, we measured the one-pass offset-waste statistic with across all 48 logical visits on 2,048 WikiText-2 tokens. Every visit scored bits (well below the 1.3-bit benign threshold), because Inkling-2 has no RoPE, no bias, L2-clipped , and unit-RMS . Consequently, rotated per-token KV quantization requires no offset centering.
Why Stock Runtimes Fail at Long Context
Auditing both mlx-vlm and oMLX revealed two compounding inefficiencies:
Per-token KV copy for learned sinks (mlx-vlm): Appending a zero K/V vector via
mx.concatenateon every decode token copies the entire KV cache. Passing MLX’s nativesinks=argument toscaled_dot_product_attentionis bit-exact (0.00e+00 max diff) and 1.85–2.44× faster from 1K to 128K.
Unbounded sliding caches (oMLX): Allocating
KVCache()for all 48 visits stores 48 full-length histories instead of 8. Replacing the 40 sliding visits withRotatingKVCache(with +16-token rollback headroom for DSpark speculative verification) cuts 32K KV memory from 6.05 to 1.36 GiB (4.45×) and fixes speculative wrap-around rollback (merged/submitted as oMLX PR #5512).
Scale-Free 2-Bit SRFT Compression and Metal Kernel
Orthonormal SRFT and Scale-Free Unit-RMS Values
For any head vector , we apply a real orthonormal Subsampled Randomized Fourier Transform:
where packs the normalized real FFT outputs . Because SRFT is strictly orthogonal ( to ), decode attention operates directly in the rotated domain: we transform once per query and inverse-transform the single output vector once per global visit, performing zero inverse FFTs over the cached keys or values.
After SRFT, coordinates are near-Gaussian and identically distributed, making scalar unit-Gaussian Lloyd–Max centroids near-optimal (at : , MSE ). Crucially, Inkling-2 applies parameter-free RMS normalization to (use_value_norm_no_gamma=True), guaranteeing identically. Thus requires no stored scale whatsoever (exact bits/coord), while stores one fp16 RMS norm per 128-element vector ( bits/coord), giving:
SRFT 1m2: 2.125 () + 2.000 () 2.0625 eff. bits (7.76× vs bf16).
SRFT K3/V2: 3.125 () + 2.000 () 2.5625 eff. bits (6.24×).
SRFT 1m3: 3.125 () + 3.000 () 3.0625 eff. bits (5.23×).
Unlike OSCAR [6], this requires zero offline calibration; unlike TurboQuant [4], it avoids spending 1 bit on a QJL sign residual (which increases softmax logit variance at equal bit budget).
Split Banded-Bias Attention with Exact Online LSE Merge
For each global visit at sequence length , the additive relative bias is nonzero only on the newest keys. We therefore partition the global cache into:
Far prefix : Spilled in 256-token chunks through SRFT and packed into 2-bit codes (32 bytes/row for , 32 bytes/row for , plus 2 bytes/row -scale = 66 bytes/head/token). Decoded via our GQA-packed Metal kernel returning with zero mask memory.
Recent window + learned sink: Kept in exact fp16, evaluated with the exact 1,024-wide banded relative bias and query-dependent sink logit to produce , and combined with via exact two-way log-sum-exp merging:
GQA-Packed 2-Bit Metal Kernel (kv_lm2_metal)
For and 2 bits/coordinate, each 32-lane Metal simdgroup maps 4 coordinates to each lane: 1 byte per lane, yielding a perfectly coalesced 32-byte burst per token. Our kernel eliminates three overheads of general-purpose Metal attention:
Zero GQA padding waste: Prior simdgroup_matrix kernels pad to 8 rows (62.5% wasted compute).
Our kernel holds all query heads (half4 q0, q1, q2) in registers, dequantizes each and byte once, and updates all 3 heads simultaneously.
256-entry threadgroup half4 LUT: Every byte encodes 4 two-bit Lloyd–Max indices (256 states total). Precomputing a 2 KiB threadgroup half4 LUT[256] at kernel entry decodes all 4 coordinates in a single table lookup, replacing 28 shift/mask/select instructions and halving register pressure.
Block-8 lazy exp2 rescaling: Computing 8 token scores per head before performing a single hardware exp2 rescale reduces rescaling overhead 8×.
Split-K parallelism across 64–256 partitions per KV head saturates M6’s GPU cores, followed by a single exact LSE reduction dispatch. Against float32 reference attention on dequantized codes (), the kernel matches to max output error and max LSE error.
Evaluation on a 32GB Apple M6
All measurements were collected on a 32 GB Apple M6 Mac mini (150 GB/s DRAM, 26.8 GiB Metal working set) using mlx 0.32.4 and mlx-community/Inkling-2-Mini-oQ4e-mtp (15.10 GiB active weights).
End-to-End Speed and Memory from 4K to 1,048,576 Tokens
Table I and Figure 1 report end-to-end decode throughput, KV cache footprint, and peak GPU memory from 4K to 1M tokens. At 256K, m6_lm2_srft delivers 17.09 tok/s (3.36× faster than m6_bf16’s 5.09 tok/s) while cutting KV memory 6.5× (1.27 vs 8.20 GiB). At the full 1,048,576-token native context, m6_lm2_srft decodes at 9.52 tok/s (105.1 ms/tok) in 19.49 GiB total peak memory (4.37 GiB KV)—2.60× faster than 4-bit q4_0 SRFT (3.66 tok/s, 24.36 GiB) and 44× smaller KV than stock oMLX (∼193 GiB).
| Context | Mode | tok/s | ms/tok | KV (GiB) | Peak (GiB) |
| 4K | Stock oMLX | 25.27 | 39.58 | 0.80 | 15.91 |
| 4K | m6_q4_srft (4.5b) | 25.31 | 39.50 | 0.47 | 15.59 |
| 32K | Stock oMLX | 19.36 | 51.66 | 6.05 | 21.16 |
| 32K | m6_bf16 (PR #5512) | 19.71 | 50.74 | 1.36 | 16.47 |
| 32K | m6_q4_srft (4.5b) | 22.24 | 44.96 | 0.72 | 15.84 |
| 64K | m6_bf16 | 16.55 | 60.42 | 2.20 | 17.32 |
| 64K | m6_q4_srft (4.5b) | 20.85 | 47.96 | 0.81 | 15.93 |
| 128K | m6_bf16 | 11.59 | 86.30 | 4.20 | 19.33 |
| 128K | m6_q4_srft (4.5b) | 17.52 | 57.09 | 1.38 | 16.50 |
| 256K | m6_bf16 | 5.09 | 196.40 | 8.20 | 23.34 |
| 256K | m6_q4_srft (4.5b) | 12.50 | 80.01 | 2.50 | 17.62 |
| 256K | m6_lm2_srft (2.06b) | 17.09 | 58.51 | 1.27 | 16.39 |
| 512K | m6_q4_srft (4.5b) | 8.42 | 118.82 | 4.75 | 19.87 |
| 512K | m6_lm2_srft (2.06b) | 13.81 | 72.40 | 2.31 | 17.43 |
| 1M | m6_q4_srft (4.5b) | 3.66 | 272.94 | 9.20 | 24.36 |
| 1M | m6_lm2_srft (2.06b) | 9.52 | 105.08 | 4.37 | 19.49 |
Table I. End-to-End Inkling-2-Mini Decode on a 32 GB Apple M6.
Figure 1. End-to-end Inkling-2-Mini (26.4B looped MoE) decode speed and peak GPU memory from 4K to 1,048,576 tokens on a 32 GB Apple M6. Stock oMLX OOMs around 64K; sliding-fixed m6_bf16 OOMs before 512K. Packed 2.06-bit SRFT (m6_lm2_srft) reaches 17.09 tok/s at 256K (3.36× vs bf16) and runs the full 1M context at 9.52 tok/s in 19.49 GiB.
Kernel Optimization Ladder and SRFT vs. Hadamard
Figure 2 tracks the 1M-token decode speedup across our kernel iterations: moving from 4.5-bit q4_0 SRFT (3.66 tok/s) to naive 2-bit LM2 with per-token exp() (6.67 tok/s, 41.7 GB/s), adding Block-8 lazy exp2 rescaling (8.37 tok/s, 59.4 GB/s), and introducing the 256-entry half4 LUT (9.52 tok/s, 73.4 GB/s; 7.65 ms/layer at 1M). Interestingly, at 64K–256K m6_q4_srft also outran in-kernel FWHT (20.85 vs. 18.88 tok/s at 64K; 17.52 vs. 15.65 tok/s at 128K) because rotating only the single query/output vector with MLX’s Metal FFT allows the attention kernel to run without in-kernel butterfly barriers while maintaining identical quality (63/64 greedy token agreement at 4K for both).
Figure 2. 1,048,576-token end-to-end decode progression on a 32 GB M6 across kernel optimizations (2.60× total speedup over 4-bit SRFT).
Language Modeling Quality and 8K–32K Passkey Retrieval
Table II evaluates multi-window WikiText-2 perplexity (4 × 4096 tokens, scoring the last 2,048 tokens of each window where the earlier prefix resides in the quantized cache) alongside long-range Needle-in-a-Haystack (NIAH) retrieval where a 7-digit passkey is buried at position 1,500 inside 8K, 16K, and 32K WikiText-2 haystacks—6.7K to 30.5K tokens behind the query, 100% invisible to the 40 sliding layers and the 1,024-token bf16 local window.
| Format | Eff. Bits | PPL | ΔPPL | 8K | 16K | 32K |
| bf16 (ref) | 16.0000 | 6.7489 | +0.0000 | PASS | PASS | PASS |
| SRFT 1m4 | 4.0625 | 6.7428 | −0.0061 | — | — | — |
| SRFT 1m3 | 3.0625 | 6.7418 | −0.0071 | PASS | PASS | PASS |
| SRFT K3/V2 | 2.5625 | 6.7725 | +0.0236 | PASS | PASS | PASS |
| SRFT 1m2 | 2.0625 | 6.8785 | +0.1296 | PASS | PASS | PASS |
Table II. Quality (4×4096 WikiText-2) and Long-Range NIAH Retrieval.
SRFT 1m3 (3.06 bits) is indistinguishable from bf16 (ΔPPL = −0.0071), SRFT K3/V2 (2.56 bits) adds only +0.0236 (+0.35%), and SRFT 1m2 (2.06 bits) adds +0.1296 (+1.9%) while passing 3/3 exact 7-digit passkey retrievals out to 32K.
Note on Speculative Decoding on Sparse MoE
Testing Inkling-2-Mini’s bundled DSpark drafter () on M6 revealed an MoE expert-union trade-off: verifying 8 tokens reads the union of ∼35–45 distinct experts from 128, costing 120 ms vs. 40 ms for 1 token. Fixed speeds up code (24.80 → 27.52 tok/s, 3.76 tok/step, 128/128 exact) but slows prose (25.78 → 22.90 tok/s, 2.93 tok/step). Quantizing the draft to 4-bit and adapting verify depth by acceptance EMA eliminates the prose regression (26.15 tok/s) and lifts code to 28.61 tok/s (128/128 exact).
Related Work and Limitations
Per-channel KV quantization (KIVI [7], KVQuant [8]) and rotation-based methods (QuaRot [9], TurboQuant [4], OSCAR [6]) target full-attention RoPE models and either require offline calibration (OSCAR) or pay a 1-bit QJL overhead. (TurboQuant). Our work shows that modern NoPE hybrid architectures with unit-RMS values admit strictly calibration-free, scale-free 2-bit SRFT compression that simultaneously accelerates decode on unified memory.
Limitations. End-to-end 256K–1M decode timings use direct cache population rather than multi-hour prefill; NIAH was evaluated to 32K (single needle per length); and quality was measured on WikiText-2 and passkey retrieval rather than full RULER or long-chain reasoning benchmarks.
Conclusion
Combining bounded sliding-window caches, split banded-bias online LSE merging, scale-free 2.000-bit SRFT Value compression, and a half4-LUT GQA-packed Metal kernel enables full 1,048,576-token inference of a 26.4B looped MoE model at 9.52 tok/s in 19.49 GiB on a 32 GB Apple M6 Mac mini—3.36× faster than bf16 at 256K and 44× smaller KV than stock oMLX—with 100% passkey retrieval up to 32K and zero offline calibration.
Reproducibility. All Metal kernels, benchmarks, and interactive chat scripts are open-sourced under the MIT license at https://github.com/aminems/inkling-1m-mlx [10], and the sliding-window cache fix is submitted upstream at https://github.com/jundot/omlx/pull/5512.
References
- [1]Thinking Machines Lab, “Inkling 2 Mini: Open-weights looped multimodal MoE model,” https://huggingface.co/thinkmachines/Inkling-2-Mini, Nov. 2026.
- [2]oMLX Contributors, “oMLX: Optimized MLX inference engine for apple silicon,” https://github.com/jundot/omlx, 2026.
- [3]M. A. Berghach, “When quantization is free: An int4 KV cache that outruns fp16 on apple silicon,” 2026.
- [4]A. Zandieh, M. Daliri, M. Hadian, and V. Mirrokni, “TurboQuant: Online vector quantization with near-optimal distortion rate,” in International Conference on Learning Representations (ICLR), 2026.arxiv.org/abs/2504.19874
- [5]A. Jonasson, “Rotary offset features in large language models,” 2025.arxiv.org/abs/2503.01832
- [6]Z. Zhou, D. Zhuang, J. Li, Z. Chen, S. L. Song, B. Athiwaratkun, and X. Wu, “OSCAR: Offline spectral covariance-aware rotation for 2-bit KV cache quantization,” 2026.arxiv.org/abs/2605.17757
- [7]Z. Liu, Y. Yuan, H. Jin, S. Zhong, Z. Xu, V. Braverman, B. Chen, and X. Hu, “KIVI: A tuning-free asymmetric 2bit quantization for KV cache,” in International Conference on Machine Learning (ICML), 2024.DOI
- [8]C. Hooper, S. Kim, H. Mohammadazdeh, M. W. Mahoney, Y. S. Shao, K. Keutzer, and A. Gholami, “KVQuant: Towards 10 million context length LLM inference with KV cache quantization,” in Advances in Neural Information Processing Systems (NeurIPS), 2024.arxiv.org/abs/2401.18079
- [9]S. Ashkboos, A. Mohtashami, M. L. Croci, B. Li, P. Cameron, M. Jaggi, D. Alistarh, T. Hoefler, and J. Hensman, “QuaRot: Outlier-free 4-bit inference in rotated LLMs,” in Advances in Neural Information Processing Systems (NeurIPS), 2024.arxiv.org/abs/2404.00456
- [10]M. A. Berghach, “inkling-1m-mlx: Calibration-free 2-bit SRFT KV-cache compression for 1m-context Inkling-2-Mini on apple silicon,” https://github.com/aminems/inkling-1m-mlx, 2026.

