✦ SRFP311T1
Technical report · leech-quant v0.1.0 · Apache-2.0 software

Exact GPU-Native Leech Lattice Quantization and Differentiable Soft Routing via Golay Sextet Contraction

SRFP311T1 Collaboration · December 2026

196,560 unit codewords. Structured hard selection, differentiable full-shell routing, fractional-bit residual encoding and packed cosine search.

13.03×Peak measured soft-routing speedup vs. dense FP32
177 / 180Paired matched-rate PQ distortion wins
≤0.0094%Maximum observed calibration distortion change; standard PQ mean penalties 7.6–9.1%
40.42× / 20.76×Actual 1 / 2-stage packed index compression
Scientific manuscript

Abstract

The minimal shell of the 24-dimensional Leech lattice contains 196,560 vectors with exceptional spherical geometry, but direct enumeration imposes substantial computation and memory costs. We derive an exact, subtraction-free factorization of its Boltzmann partition function using extended binary Golay sextets, together with differentiable routing, Jacobian-vector products, and tropical hard quantization with canonical 18-bit indexing. The representation requires 64.17 KiB for soft routing and 80.64 KiB including hard indexing, compared with an 18 MiB dense FP32 dictionary. On a Tesla T4, compiled soft routing achieves up to 13.03× acceleration over the tested dense baseline and reduces peak additional allocated GPU memory by 90.9%. Greedy residual quantization provides index rates of 0.75, 1.50, and 2.25 bits/dimension using fixed codewords and shared calibrated gains. Across two pretrained sentence-embedding models and 18,118 filtered 20 Newsgroups documents, Leech achieves lower distortion in 177 of 180 paired, matched-rate PQ comparisons. Under topic-domain calibration shift, standard per-subspace PQ incurs 7.6–9.1% additional distortion, whereas Leech distortion remains nearly unchanged. Actual packed index compression reaches 40.42× and 20.76× relative to FP32 at up to 100,000 vectors, with numerically verified direct compressed scoring. Limitations include slower prototype compressed search and inferior reconstruction relative to binary scalar quantization in a learned Fashion-MNIST bottleneck.

Unrefereed technical report. Historical measurements are from the frozen notebooks; the installed package passed separate CPU and T4 regression checks.

Install directly

python -m pip install https://srfp311t1.com/downloads/leech_quant-0.1.0-py3-none-any.whl

Python 3.10+, PyTorch 2.2+ and NumPy 1.24+. Install a suitable CUDA build of PyTorch first. No PyPI account or package publication is needed; dependencies still need to be installed. The static package index is also available at /simple/.

For environments with both dependencies already installed, use:

python -m pip install --no-deps https://srfp311t1.com/downloads/leech_quant-0.1.0-py3-none-any.whl#sha256=d9fb0d193839c766e9976e409287e91ffb870a95e7b977d99bab594c267e1af6

Search a compressed index

from leech_quant import LeechIndex
index = LeechIndex(dim=768, stages=2, device="cuda")
index.build(embeddings, calibration=calibration_embeddings)
scores, ids = index.search(queries, k=10, mode="tiled")

Pass separate calibration vectors for scientific comparisons. Dimensions must be divisible by 96. Use mode="lut" for direct compressed scoring; mode="tiled" decodes bounded tiles and batches queries.

Encode and decode

from leech_quant import LeechQuantizer
q = LeechQuantizer(stages=3, device="cuda")
q.fit_gains(calibration_embeddings)
packed = q.encode(embeddings)
reconstructed = q.decode(packed)

Differentiable routing

from leech_quant import LeechSoftRouter
router = LeechSoftRouter(T=0.07, device="cuda")
logZ, mean = router(blocks)  # [B, 24]
jvp = router.jvp(blocks, upstream_gradient)

The fixed dictionary requires no learned centroids, but the reconstruction gains are calibrated. Standalone quantization does not normalize vectors automatically; the search index does.

Frozen evidence · Tesla T4

Calibration-domain transfer

18,118 filtered 20 Newsgroups documents; 13,766 database vectors across both domains and 256 queries per seed (49, 50, 51). The table compares the same held-out target documents under target versus source calibration. Penalty = 100 × (source-calibrated MSE / target-calibrated MSE − 1). Three-seed means. Standard PQ is a custom independent 4D Lloyd implementation, not FAISS.

MPNet · 768D

MethodBits/dimTarget calibrated MSESource calibrated MSEShift penaltyOOD R@10
leech180.750.4097430.409743+0.0000%78.62%
pq18_std0.750.4068670.443371+8.9720%77.08%
pooled_pq180.750.4631540.465670+0.5434%76.33%
leech361.500.1673660.167362-0.0026%87.24%
pq36_std1.500.1694120.184877+9.1286%86.28%
pooled_pq361.500.1901690.191386+0.6402%86.43%
leech542.250.0685270.068527-0.0006%92.32%
pooled_pq542.250.0736010.074210+0.8276%91.90%

MiniLM · 384D

MethodBits/dimTarget calibrated MSESource calibrated MSEShift penaltyOOD R@10
leech180.750.4075520.407552-0.0000%67.47%
pq18_std0.750.4334070.467596+7.8885%64.66%
pooled_pq180.750.4600000.463443+0.7486%65.44%
leech361.500.1656520.165657+0.0030%82.50%
pq36_std1.500.1793750.194101+8.2097%80.16%
pooled_pq361.500.1852590.186856+0.8622%80.39%
leech542.250.0674880.067485-0.0044%88.62%
pooled_pq542.250.0719970.072774+1.0791%87.47%

Across all 180 overlapping paired PQ comparisons: 177 lower-distortion wins and 159 higher-recall wins. Largest absolute relative shift across 54 paired Leech conditions: 0.009396%. Standard PQ54 was not evaluated. The comparisons are not independent trials and do not establish universal OOD robustness.

Download complete validation JSON · Vector rate–distortion plot

Full-shell soft routing

65,712 bytes of soft tables versus 18 MiB dense FP32 codebook; 82,576 bytes including hard indexing. Timings are steady-state original notebook measurements, not refactored-wheel benchmarks. Extra memory is peak additional allocated tensor memory.

All 18 measured batch / temperature combinations
BatchTDense msChunked msCompiled msvs. denseCompiled extra MiB
10.0010.5893.6340.8160.72×0.14
80.0011.0993.6481.0411.06×1.09
320.0011.7953.6350.8962.00×4.33
1280.0016.4206.9711.2205.26×17.31
2560.00112.50912.8840.96612.95×34.82
3840.00118.68518.3041.44212.95×52.64
5120.00124.75824.4451.90113.03×69.65
7680.00137.11636.3742.93112.67×104.26
10240.00149.45245.6673.96712.47×139.37
10.0700.3313.2831.0800.31×0.14
80.0700.8763.4780.8391.04×1.09
320.0701.8313.5160.8222.23×4.33
1280.0706.3746.8880.8627.40×17.31
2560.07012.49112.8201.4588.57×34.82
3840.07018.68518.2981.48212.61×52.64
5120.07024.76424.2591.98012.51×69.65
7680.07037.07936.0992.98912.40×104.26
10240.07049.37145.6014.12311.97×139.37

Download V3 routing results · Vector latency and memory plot

Scope and limitations

Research prototype, not a production ADC engine. Sequential LUT throughput (60–145 QPS) trails the tested pooled PQ36 and dense GPU search. All measurements use one T4; hardware-optimized dense or PQ engines are not compared. Fashion-MNIST binary FSQ achieves lower learned-bottleneck MSE than Leech, and fixed-temperature soft backward underperforms STE.

Exactness refers to the mathematical minimal-shell factorization and numerically verified scoring of compressed reconstructions, not infinite-lattice CVP or lossless neighbor recovery. The 80.64 KiB encoder/router table figure is not total scanner memory. At 768D, query LUTs occupy 727,808 bytes. The installed wheel passed both CUDA checks; at T=0.001 the two stable/ordinary FP32 JVP modes differed by up to 0.0112152 in absolute value. LLM weight/KV compression is untested.

Downloads and reproducibility

SHA-256 manifest covers every other download in this release. The wheel and source distribution are unchanged from the Apache-2.0 release; the PDF contains the self-hosted canonical URL.

Installable Python wheel21.1 KiB · leech_quant-0.1.0-py3-none-any.whl
Python source distribution111.8 KiB · leech_quant-0.1.0.tar.gz
Technical report (PDF)397.5 KiB · leech_quant_v0.1.0_paper.pdf
LaTeX and vector figures43.2 KiB · leech_quant_v0.1.0_paper_src.tar.gz
Complete software source ZIP120.7 KiB · leech_quant_v0.1.0_source.zip
README10.9 KiB · leech_quant_README.md
Canonical codec format1.5 KiB · leech_quant_FORMAT.md
Apache-2.0 license11.1 KiB · leech_quant_LICENSE
Third-party notice0.3 KiB · leech_quant_NOTICE.txt
BibTeX citation0.3 KiB · leech_quant_v0.1.0.bib
Routing figure (vector PDF)15.3 KiB · routing_scaling.pdf
Rate–distortion figure (vector PDF)15.3 KiB · ood_rate_distortion.pdf

Frozen benchmark logs

leech_colab_v3_results.json27.8 KiB · Frozen JSON
leech_compression_results.json91.8 KiB · Frozen JSON
leech_vq_training_results (2).json99.3 KiB · Frozen JSON

Cite this technical report

@misc{leechquant2026,
  title = {Exact GPU-Native Leech Lattice Quantization and Differentiable Soft Routing via Golay Sextet Contraction},
  author = {{SRFP311T1 Collaboration}},
  year = {2026},
  month = dec,
  note = {SRFP311T1 technical report and software release v0.1.0},
  url = {https://srfp311t1.com/leech_quant/}
}

Software license: Apache-2.0. The paper is a separate scholarly work; no separate paper reuse license is asserted.

Research and integration inquiries

Interested in fused C++/AVX-512, CUDA/Triton ADC kernels, vector-database integration or low-bit model compression research? Contact dev@srfp311t1.com.