Instructions to use majentik/Leanstral-RotorQuant-MLX-2bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use majentik/Leanstral-RotorQuant-MLX-2bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("majentik/Leanstral-RotorQuant-MLX-2bit") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use majentik/Leanstral-RotorQuant-MLX-2bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "majentik/Leanstral-RotorQuant-MLX-2bit" --prompt "Once upon a time"
KV-cache quantization without any fork (recommended, 2026): upstream llama.cpp/Ollama now cover this natively โ use
-ctk q8_0 -ctv q8_0(half KV memory, negligible quality loss: perplexity +0.002โ0.05) orquarter memory, โ7.6% perplexity increase). In Ollama:-ctk q4_0 -ctv q4_0(OLLAMA_KV_CACHE_TYPE=q8_0withOLLAMA_FLASH_ATTENTION=1. Keep K and V types symmetric to stay on the fast fused Flash-Attention path. Since April 2026, mainline llama.cpp also applies Hadamard rotation to KV activations (PR #21038), which greatly improves low-bit KV quality (opt-out:LLAMA_ATTN_ROT_DISABLE=1).The RotorQuant/TurboQuant fork flow below is experimental/legacy: the TurboQuant llama.cpp PR was closed without merging (June 2026) and the fork is unmaintained relative to mainline. It is NOT required to use this model.
Leanstral-RotorQuant-MLX-2bit
2-bit MLX weight-quantized Leanstral-2603 with RotorQuant KV-cache quantization for high-throughput Lean 4 formal proof generation on Apple Silicon.
Leanstral is the first open-source AI agent purpose-built for Lean 4 formal proofs -- generating both executable code and machine-checkable mathematical proofs. This variant combines dual compression: 2-bit MLX weight quantization for aggressive model size reduction plus RotorQuant KV-cache quantization, delivering 5.3x faster prefill and 28% faster decode compared to TurboQuant equivalents.
Overview
This repository provides an aggressively compressed configuration with RotorQuant's superior throughput: MLX 2-bit weight quantization minimizes the static memory footprint, while RotorQuant's rotation-aware KV-cache compression delivers faster prefill and decode than TurboQuant.
| Spec | Value |
|---|---|
| Base model | mistralai/Leanstral-2603 |
| Architecture | Mistral MoE (~119B parameters, 7 consolidated shards) |
| Weight quantization | 2-bit (MLX) |
| KV-cache quantization | RotorQuant |
| Weight memory | ~30 GB |
| Prefill speedup | 5.3x vs TurboQuant |
| Decode speedup | 28% vs TurboQuant |
| Runtime | MLX (Apple Silicon) |
| License | Apache 2.0 |
| Use case | Lean 4 formal verification, theorem proving, mathematical proofs |
Quickstart
from mlx_lm import load, generate
model, tokenizer = load("majentik/Leanstral-RotorQuant-MLX-2bit")
prompt = "Prove that for all natural numbers n, n + 0 = n in Lean 4:"
response = generate(
model,
tokenizer,
prompt=prompt,
max_tokens=512,
)
print(response)
What is RotorQuant?
RotorQuant is an advanced KV-cache quantization method that leverages rotation-aware quantization to achieve superior throughput compared to standard KV-cache compression. By exploiting the rotary positional embedding structure, RotorQuant achieves:
- 5.3x faster prefill -- critical for long Lean 4 proof contexts
- 28% faster decode -- faster token-by-token proof generation
- Equivalent memory savings to TurboQuant with better computational efficiency
Note: 2-bit weight quantization is lossy. Expect some degradation in proof quality compared to the 4-bit variant. For critical formal verification work, prefer the 4-bit or full-precision variants.
Memory Estimates
| Component | Estimate |
|---|---|
| Model weights (2-bit) | ~30 GB |
| KV-cache | Reduced via RotorQuant |
| Recommended hardware | MacBook Pro M2/M3/M4 Max (64 GB+) or Mac Studio |
Lean 4 Use Case
Leanstral excels at:
- Formal verification -- generating machine-checkable proofs of mathematical theorems
- Theorem proving -- interactive and automated proof search in Lean 4
- Code generation -- writing verified Lean 4 programs with correctness guarantees
- Proof repair -- fixing incomplete or broken proof scripts
See Also
- mistralai/Leanstral-2603 -- Base model
- majentik/Leanstral-RotorQuant -- Full-precision weights + RotorQuant KV cache
- majentik/Leanstral-RotorQuant-MLX-4bit -- MLX 4-bit + RotorQuant
- majentik/Leanstral-RotorQuant-MLX-1bit -- MLX 1-bit + RotorQuant
- majentik/Leanstral-TurboQuant-MLX-2bit -- MLX 2-bit + TurboQuant
- RotorQuant repository
Quant trade-off (MLX lane)
| Bits | Approx size | Use case | Recommendation |
|---|---|---|---|
| 2-bit | ~31 GB | Aggressive quantization | Very low-RAM Macs |
| 3-bit | ~43 GB | Lossy but small | Low-RAM Macs |
| 4-bit | ~50 GB | Balanced default | Recommended for most Macs |
| 5-bit | ~60 GB | Higher fidelity | Quality-sensitive |
| 6-bit | ~71 GB | Approaching FP16 quality | High-fidelity |
| 8-bit | ~90 GB | Near-lossless reference | Fidelity-critical work |
(Current variant โ 2bit โ is bolded.)
Variants in this family
(Showing 8 sibling variants under majentik/leanstral-*. The current variant โ RotorQuant-MLX-2bit โ is bolded.)
| Variant | Runtime | Approx size | Use case |
|---|---|---|---|
| RotorQuant | runtime modifier | n/a | KV-cache root (weight-agnostic) |
| RotorQuant-MLX-2bit | mlx-lm | card-only | Apple Silicon, smallest |
| RotorQuant-MLX-4bit | mlx-lm | card-only | Apple Silicon balanced |
| RotorQuant-MLX-8bit | mlx-lm | card-only | Apple Silicon reference |
| TurboQuant | runtime modifier | n/a | KV-cache root (weight-agnostic) |
| TurboQuant-MLX-2bit | mlx-lm | card-only | Apple Silicon, smallest |
| TurboQuant-MLX-4bit | mlx-lm | card-only | Apple Silicon balanced |
| TurboQuant-MLX-8bit | mlx-lm | card-only | Apple Silicon reference |
- Downloads last month
- 86
2-bit
Model tree for majentik/Leanstral-RotorQuant-MLX-2bit
Base model
mistralai/Leanstral-2603