This repository keeps its algorithm notes in-tree so it can be published independently of the parent Gemma workspace.
- TurboAngle: https://arxiv.org/abs/2603.27467
- TurboQuant: https://arxiv.org/html/2504.19874v1
These paper links are kept here directly so the repository does not need a separate paper-notes page for core references.
The repository now includes a simple post-FWHT angle histogram tool for model-derived key vectors:
- plot script:
bench/plot_post_fwht_angle_histogram.py - example output:
docs/assets/post-fwht-angle-histogram.png
On a tiny-random/gemma-2 layer-0 run, the current checked-in stats were:
- KL divergence to a uniform 256-bin angle distribution:
0.0456 - max bin probability deviation:
0.0039
This is not a proof of exact uniformity, but it is useful supporting evidence that uniform angle bins are not grossly mismatched after the randomized transform.
- Input vectors are rows of shape
[B, d] dmust be a power of two for the canonical FWHT path in v1KandVmay use different layerwise policies and different codecs
- Random diagonal sign rotation
D - Orthonormal Walsh-Hadamard transform
H - Pairwise polar decomposition of transformed coordinates
- Uniform angle quantization
- Quantized norm storage
- FWHT preserves vector norm within float tolerance
- encode/decode is deterministic for fixed seed + config
- measured error decreases as angle bins increase
The repository should move from the current TurboQuant-inspired scalar-codebook baseline toward a fuller TurboQuant implementation that includes:
- random rotation
- scalar/codebook quantization on rotated coordinates
- norm handling for non-unit vectors
- residual / QJL-style correction path for the inner-product-aware variant
Every codec must report:
- estimated bits per element
- compression ratio vs fp16 KV
- reconstruction metrics
- later: attention distortion and model quality metrics
- Reconstruction-only
- Attention distortion
- Model quality
- Runtime and memory
Use lossless only for explicitly stated metrics and workloads.
Do not generalize synthetic reconstruction numbers into full-model quality claims.