SHAPEQ / Q4_LUT model zoo — fitted 16-level grids
Author: Roman S. Pokora · Independent researcher.
Paper: https://stiggigy-jpg.github.io/shapeq-paper/ · Code and paper repo: https://github.com/stiggigy-jpg/shapeq-paper · Runtime: https://github.com/stiggigy-jpg/shapeq-q4lut.
Two GGUF quantizations in Q4_LUT, the experimental weight-only format used by SHAPEQ
(shape-adaptive quantization). Every linear tensor decodes its 4-bit codes through a
fitted non-uniform 16-level grid (lookup table) plus an fp16 scale per group:
group 96 → Q4_LUT, group 64 → Q4_LUT64. The fit is deterministic, rests on classical
Lloyd–Max theory, needs no training or gradients, and changes only the alphabet, so it
composes with GPTQ, AWQ, rotations, sparse corrections, and mixed-precision allocation.
Requires our llama.cpp fork. These are not standard GGUF quant types. Upstream
llama.cppcannot load them; upstream support is not planned because the type ids are private. Build theshapeq-q4lutbranch and run as usual.
Files in this repository
| file | role |
|---|---|
smollm-135m-q4lut.gguf | 96-weight blocks, type Q4_LUT (44) |
qwen2.5-0.5b-q4lut.gguf | 64-weight blocks, type Q4_LUT64 (45) |
b4_smollm_shapeq.pt | fitted pack: codes, scales, grids; hash in SHA256SUMS.txt |
b4_qwen_shapeq.pt | fitted pack for Qwen2.5-0.5B |
b4_qwen_shapeq.pt.json | perplexity and greedy-64 anchors for a rerun |
pack_q4lut.py | repacks a fitted .pt into GGUF |
REPRODUCE.md | baseline quants, fitting, packing, measurement |
SHA256SUMS.txt | hashes of both GGUFs, both packs, and the anchor JSON |
The pre-fitted packs mean the GGUFs can be rebuilt without rerunning the fitter.
The fitter, its qb/ library, and all raw CSV/JSON results are in https://github.com/stiggigy-jpg/shapeq-paper.
SmolLM-135M (smollm-135m-q4lut.gguf)
| item | value |
|---|---|
| type id | GGML_TYPE_Q4_LUT (= 44, fork-private) |
| block | 96 weights = 1 fp16 scale + 48 bytes of 4-bit codes (50 B/block) |
| payload rate | 4.167 bits/weight on linear layers |
| per tensor | 16 fp32 grid values in GGUF metadata (q4lut.* keys) |
| what is quantized | 210 linear tensors (55.3 MB); embeddings/output stay f16 |
| file | smollm-135m-q4lut.gguf, 108.6 MB, 134.5 M params |
| pack | b4_smollm_shapeq.pt, 55.5 MB |
Measured with the fork's CPU build, AVX2, i7-10850H, 6 threads; corpus = first 240 KB of WikiText-2, ctx 512:
| quant | file, MB | ppl | pp512 t/s | tg128 t/s |
|---|---|---|---|---|
| q4lut | 108.6 | 20.73 | 229 | 54 |
| Q4_0 | 87.5 | 21.64 | 533 | 105 |
| IQ4_NL | 87.8 | 20.43 | 565 | 98 |
| Q4_K_M | 100.6 | 19.06 | 269 | 99 |
q4lut beats Q4_0 by about 0.9 ppl at a similar bit rate. It is slower to decode than the tuned upstream kernels (no repack-GEMM path), and IQ4_NL remains a stronger all-round point. These files demonstrate a fitted grid inside a real runtime, not a speed win. Full protocol: paper §6.11.
Qwen2.5-0.5B (qwen2.5-0.5b-q4lut.gguf)
Qwen2.5 hidden sizes are not divisible by 96, so this model uses the 64-weight block
variant (GGML_TYPE_Q4_LUT64, type id 45, 4.25 bpw), fitted with the same
Hessian-weighted procedure.
| item | value |
|---|---|
| type id | GGML_TYPE_Q4_LUT64 (= 45, fork-private) |
| block | 64 weights = 1 fp16 scale + 32 bytes of 4-bit codes (34 B/block) |
| payload rate | 4.25 bits/weight on linear layers |
| per tensor | 16 fp32 grid values in GGUF metadata (q4lut.* keys) |
| what is quantized | 168 linear tensors; embeddings/output stay f16 |
| file | qwen2.5-0.5b-q4lut.gguf, 446.9 MiB, 494.0 M params |
| pack | b4_qwen_shapeq.pt, 190.3 MB |
Measured with the same machine and settings (16-chunk ctx-512 slice):
| run | PPL | pp512 t/s | tg128 t/s |
|---|---|---|---|
| stock f16 GGUF | 15.83 | 210.0 | 12.8 |
| f16 dequantized (same grid, no LUT kernel) | 17.13 | — | — |
| q4lut (this file) | 17.13 | 67.1 | 13.2 |
| Q4_0 (reference) | 17.65 | 190.9 | 33.4 |
The q4lut kernel reproduces its own dequantized reference to 0.001 PPL; greedy 64-token continuations match the PyTorch fake-quant model token-for-token (EN and RU). The speed gap to Q4_0 is reported openly in paper §§6.9–6.11: this is a grid-shape study, not a kernel-speed study.
Loading
git clone -b shapeq-q4lut https://github.com/stiggigy-jpg/shapeq-q4lut llama.cpp && cd llama.cpp
cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -j
./build/bin/llama-cli -m smollm-135m-q4lut.gguf -p "Hello" -n 64
Not supported on purpose
llama-quantizecannot produce or re-export this type (nofrom_float/to_float).- GPU backends have no kernel; CPU only.
- Upstream llama.cpp rejects the file as an unknown quant type.
Reproducibility
REPRODUCE.md rebuilds the baseline quants and the two Q4_LUT GGUFs from the shipped
packs. SHA256SUMS.txt gates both packs and both GGUFs. The fitter and raw tables are
in https://github.com/stiggigy-jpg/shapeq-paper; the two engines (legacy, hist) match the dates of the shipped
packs. Absolute perplexity can shift in the last decimal with BLAS reduction order.
Speeds are machine-specific. The LUT kernel is a reference implementation, not an
optimized one (paper §8).
Provenance and license
Weights derived from SmolLM-135M and Qwen2.5-0.5B (both Apache-2.0 upstream); these
derivatives are Apache-2.0 as well. Calibration used WikiText-2 train only. Model card,
format spec, and kernel: paper https://stiggigy-jpg.github.io/shapeq-paper/, fork FORMAT.md.