GitHub - ShinMegamiBoson/lookatmyquant: A quantization compiler that delivers 12× lower KL than Q4_K_M at the same file size
Pangram verdict · v3.3
We believe this text is mainly AI, with some human-written content.
AI likelihood · overall
AIArticle text · 1,114 words · 19 segments analyzed
LookAtMyQuant is a quantization compiler. It measures how much each stored piece of a model hurts the output when compressed. It then picks a code for each piece so the whole model fits a size budget with the least damage. On Gemma 4 E2B, its GGUF has 12× lower KL than Q4_K_M at the same file size. The method and every result are on the site. The code is under the MIT license. LookAtMyQuant 2: Qwen3.5-4B in 1.2 GB LookAtMyQuant 2 takes Qwen3.5-4B to 1.23 GB, 2.3 bits per weight. The file solves 330 of 540 exact-answer math problems. Prism ML's Bonsai 2 Ternary 4B solves 328 at 1.20 GB, and the original solves 359. Its KL from the original on held-out text is 0.45 nats, against 0.59 for Bonsai. The recipe is post-training quantization with trellis codes, calibrated on the model's own worked math solutions with digit tokens weighted 10×, and with bits allocated per row by Fisher information. 4,000 steps of distillation follow, in which every layer is re-quantized once from the original weights. The page has the findings, the full recipe and its cost, about $34 of GPU time. The recipe's code is here, and the next section runs it. The 1.23 GB file itself is the lm2-qwen35-4b-1.2gb release, packed for the Apple Silicon runtime. Qwen3.8-27B in 7.2 GB The same recipe takes Qwen3.8-27B from 53.7 GB to 7.2 GB, 2.1 bits per weight, calibrated and distilled on English prose and chat, code and math. The file solves 401 of the 540 math problems, as many as the original, and Unsloth's UD-IQ2_XXS GGUF of the same size solves 348. It also scores above that GGUF on HumanEval (73.8% against 67.1%), MMLU (78.8% against 75.0%) and GSM8K (94.5% against 92.7%). Beside it sits a 4-bit DSpine drafter (1.02 GB, converted from tencent/Qwen3.8-27B-DSpine-b16 with runtime_mlx/convert_dspine.py and packed with pack_drafter.py), which roughly doubles decode speed on math and code on Apple silicon. Inkling-2-Mini in 5.4 GB and 8.9 GB The same compiler and proximal fine-tuning (SQYFR), extended to a 26.4B physical / 5.4B active 3×-looped MoE (L6–17 looped 3× = 48 logical visits, 128 experts top-8), compresses thinkingmachines/Inkling-2-Mini from 18.89 GB of text weights to 5.38 GB (1.63 bits/weight) and 8.87 GB (2.69 bits/weight) using 4 KB SRAM hashed block-vector trellis codes (ht2/ht3), row trellis codes (rtr1/rtr4), and a tr2 floor on the tail lm_head bucket (head.7). Evaluated on the same BF16 teacher, openai/gsm8k (test[:200], greedy, reasoning_effort="none"), all 164 executable openai/openai_humaneval problems, 4 Vision VQA tests (with the untouched 637 MB BF16 vision tower), and 16+13-language TextMix windows: Model Text GB free_KL (en/chat/code) all13_KL GSM8K (200) HumanEval (164) Pooled vs Teacher Original BF16 Teacher 18.89 0.0000 0.0000 147 / 200 (73.5%) 66 / 164 (40.2%) 100.0% LookAtMyQuant 5.4 GB (SQYFR) 5.38 0.0895 0.2871 134 / 200 (67.0%) 60 / 164 (36.6%) 91.2% Unsloth UD-IQ1_S 7.76 0.0808 0.1236 127 / 200 (63.5%) 46 / 164 (28.0%) 81.6% LookAtMyQuant 8.9 GB (SQYFR) 8.87 0.0208 0.0571 148 / 200 (74.0%) 58 / 164 (35.4%) 96.8% Unsloth UD-Q2_K_XL 9.14 0.0486 0.0811 132 / 200 (66.0%) 49 / 164 (29.9%) 85.3% Unsloth UD-IQ3_XXS 11.66 0.0189 0.0278 148 / 200 (74.0%) 68 / 164 (41.5%) 101.4% At 5.38 GB, Inkling-2-Mini-LookAtMyQuant-5.4GB outscores Unsloth's 9.14 GB UD-Q2_K_XL on both GSM8K and HumanEval at 41% smaller size (up from 76/200 and 24/164 untuned). At 8.87 GB, Inkling-2-Mini-LookAtMyQuant-8.9GB matches the BF16 original on GSM8K and cuts KL 2.34× on English/chat/code and 29.6% across all 13 languages below UD-Q2_K_XL. Both run directly through lamq and runtime_mlx with custom Apple Silicon Metal kernels, optionally paired with the 178.9 MB 4-bit DSpark drafter: on M5 Max, 5.4 GB decodes at 73.2 tok/s serial and 125.2 tok/s median (141.8 tok/s math, 129.0 tok/s reasoning, 121.4 tok/s code, 102.3 tok/s prose; 1,037 tok/s prefill at T=512, 5.83 GB active RAM), and 8.9 GB decodes at 63.1 tok/s serial and 101.3 tok/s median (133.9 tok/s reasoning, 118.9 tok/s math; 838 tok/s prefill at T=512, 9.32 GB active RAM). Install and use the Apple Silicon runtime On Apple silicon, install the runtime package directly (this installs mlx, mlx-lm, numpy, and huggingface-hub without the PyTorch compiler dependencies): pip install git+https://github.com/ShinMegamiBoson/lookatmyquant.git From a local clone, pip install -e . installs the lamq command, or run python -m runtime_mlx without installing.
Command line.
Pass either a local model folder or a Hugging Face repo ID: lamq generate shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB \ -p "What is 17 times 23?
Show the steps."
lamq generate shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB \ --drafter shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB-drafter \ -p "Write a Python function that merges overlapping intervals." --stats lamq chat shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB \ --drafter shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB-drafter lamq generate shinmegamiboson/Inkling-2-Mini-LookAtMyQuant-5.4GB \ --drafter shinmegamiboson/Inkling-2-Mini-LookAtMyQuant-drafter \ -p "What is 17 times 23?
Show the steps."
--stats lamq generate reads stdin when -p is omitted, supports --raw, --system, --thinking, --temp, --mode linear|chat-fork|copy-wide, --no-adaptive, and --json. lamq info <model> inspects a packed model's format and dimensions without loading weights.
Python integration.
runtime_mlx.load returns an (model, tokenizer) pair compatible with mlx_lm.generate and mlx_lm.stream_generate (auto-detecting opgraph-packed-1 models such as Qwen3.5-4B / Qwen3.8-27B and lamq.json exports such as Gemma 4 E2B): from mlx_lm import generate from runtime_mlx import load model, tok = load("shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB") prompt = tok.apply_chat_template( [{"role": "user", "content": "What is 17 times 23? Show the steps."}], add_generation_prompt=True, enable_thinking=False, ) print(generate(model, tok, prompt, max_tokens=200)) For streaming, multi-turn chat, or speculative decoding through one interface, use Runtime: from runtime_mlx import Runtime rt = Runtime.load( "shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB", drafter="shinmegamiboson/Qwen3.8-27B-LookAtMyQuant-7.2GB-drafter", ) for chunk in rt.stream("Solve 3x + 4y = 31 and 5x - 2y = 17.", max_tokens=256): print(chunk.text, end="", flush=True) Run the compiler on SmolLM2-360M in three commands Install the dependencies and download the model and WikiText-2. The code reads SmolLM2-360M's config when it starts, so do this first.
pip install -r requirements.txt python -c "from huggingface_hub import snapshot_download as d; d('HuggingFaceTB/SmolLM2-360M')" python -c "from datasets import load_dataset as l; l('Salesforce/wikitext', 'wikitext-2-raw-v1')" Measure.
This compresses one piece at a time, leaves the rest exact, and records the KL to the original model. The full set for this model, 2,312 measurements, took about 50 minutes on an L40S.
python compiler.py measure --model HuggingFaceTB/SmolLM2-360M --part linear --layers 0-3 --out results/batch/my_measurements.json Allocate.
This picks one code per piece, with the least summed KL inside the budget.
It needs no GPU. This command uses the SmolLM2-360M measurements in this repository, with a budget of 3.044 bits per weight.
python compiler.py allocate --sens 'results/batch/ccSens*.json' --target disk --items linear --bits 3.044 --out results/compiler/plans/my_plan.json The plan it writes has the same widths as results/compiler/plans/sm_lin_3044.json.
Build and score.
This quantizes the model to the plan, one matrix at a time.
It then reports perplexity and KL to the original on WikiText-2 test.
python quantize.py --program plan --model HuggingFaceTB/SmolLM2-360M --plan results/compiler/plans/my_plan.json --out results/my_run.json Our run of that plan is in results/batch/cc_sm_lin_3044.json.