Final Report: Lossless Compression of LLM Weight Files
Summary
We investigated lossless compression algorithms that exploit the floating-point structure of LLM weights (sign / exponent / mantissa separation) instead of relying on byte-level repetition as general-purpose codecs do. The strongest surviving method is a field-separated bit-plane codec: decompose FP16/FP32 weights into a sign stream, a debiased exponent stream, and transposed mantissa bit-planes, then compress each stream separately with LZMA. This method's superiority over whole-buffer LZMA on FP32 Gaussian tensors was confirmed via preregistration (mean gain +9.71%, n=5, Holm-adjusted p = 1.19e-8). On other formats and distributions the gains were smaller but consistently positive in exploratory runs (+3.6% to +9.9%), while simpler alternatives (plain repacking, exponent grouping, an entropy-coded sign/exponent codec, delta coding, correlation modeling) either underperformed or failed roundtrip verification. We caution that absolute compression remains modest (~1.19x on FP32), close to the theoretical entropy bound we measured, and that the confirmed result covers only synthetic Gaussian FP32 data.
Key results
- Confirmed (preregistered): Field-separated bit-plane codec beats whole-buffer LZMA on FP32 Gaussian tensors (n=1M, scale=0.02). Mean ratio gain +9.71% (CI [9.50, 9.93]), n=5, Holm-adjusted p = 1.19e-8, Cohen's d = 56.4. Supported by 5 confirmatory runs plus 6 additional exploratory runs (jobs b1653cf6, 2d44ebfd, 4ff6b1da, 25e2369e, 3f901ebe, 41062067) with gains of +9.6% to +10.0%, e.g. ours = 26.90 bits/weight vs LZMA = 29.49 bits/weight, ratio 1.190x vs 1.085x,
exact_lossless = truein all of them. - Exploratory, other formats/distributions (bit-plane method):
- FP32 Laplace, scale=0.02: 1.176x vs LZMA 1.075x, +9.4%, 27.21 bpw, lossless = true (job 4f8469a6).
- FP16 Laplace, scale=0.02: 1.128x vs LZMA 1.088x, +3.6%, 14.19 bpw, lossless = true (job 4b41f717).
- FP32/F16 with controlled correlation (block_corr 0.0/0.5/0.9): byte-plane LZMA achieves 26.92 bpw (FP32) and 13.58 bpw (FP16) regardless of correlation, i.e. ~8.6–9.5% smaller than raw LZMA (29.47–29.53 and 14.29 bpw) — correlation does not change the picture (jobs d627fbdc, e96bfc23, dfa9ec1c, 1746ef6e, efb8feb9, c51d4226).
- Exploratory, real model data: on a run with
use_real=true(job 1c2a50ac), SEM coding reached 13.72 bpw on real weights vs 14.49 bpw for LZMA (min gain +5.34%, mean +6.12%), but only +0.65% over plane-deinterleaved LZMA, and roundtrip verification failed (all_roundtrips_ok = false), so this number must be treated as unverified. - Theoretical bound: the estimated SEM entropy for FP32 Gaussian data is 26.55 bpw (jobs dfa9ec1c, d627fbdc); the achieved 26.92 bpw is within ~0.4 bpw of this bound, indicating limited remaining headroom for order-0 methods on this distribution.
What did not work
- Plain repacking of FP16 streams (no decomposition): performed worse than LZMA — −1.2% on Gaussian, −1.6% on Laplace (jobs 18db9ab7, 55a6c52f).
group_by_expmethod: reported +5.5–5.8% on FP32 but was not actually lossless (exact_lossless = false, jobs 26884f7c, 024022b9), and −0.9% on FP16 (job 0df805f8). Discard these gains.- SEM class-entropy codec: results were contradictory and roundtrips failed. One run (job 1c2a50ac) showed 13.47 bpw vs 13.61 for plane-LZMA (+0.9%), but
rt=False; another run (job d43f6759) showed SEM at 15.07–16.46 bpw, i.e. worse than LZMA (14.30), withall_roundtrips_verified = false. Until the decoder bug is fixed and roundtrips pass, the SEM codec's claimed ~6% gain over LZMA is unsupported. - Delta coding, transposition, XOR-delta and correlation modeling: gave no gain over plain byte-plane LZMA on synthetic weights (negative result published; jobs d627fbdc, e96bfc23, etc., where
sem_xor_delta,transposed_lzmaall matched or lost tobyteplane_lzma). - 13 runs failed due to a
save_json()missing-argument error in the harness, and one run failed because theconstrictionpackage could not be installed — these experiments (n=2M, Student-t distribution, additional scales) were never completed.
Confidence and limitations
- Confirmed with high statistical confidence: only one preregistered hypothesis — bit-plane codec > whole-buffer LZMA on FP32 Gaussian synthetic tensors (n=5, effect +9.71%, CI [9.50, 9.93], adjusted p = 1.19e-8). Everything else in this report is exploratory.
- Claims status: three methods were proposed as knowledge items, all at confirmation level candidate with 0 reproductions:
- Byte-plane decomposition with per-plane LZMA — candidate, novelty unclear (literature comparison returned an invalid answer).
- Float-anatomy bit-plane codec — candidate, novelty possibly_new (closest prior work: "Quad Length Codes for Lossless Compression of e4m3", arXiv 2602.17849, which targets e4m3 with a different coding scheme, overlap 0.35).
- SEM class-entropy codec — candidate, novelty possibly_new, but its experimental support is contradicted and unverified.
- "Possibly_new" means no close prior work was found, not that novelty is proven. No independent reviews were completed (3 claims, 0 reviewed).
- What needs lab/experimental validation:
- Roundtrip (decode == encode) verification of the SEM codec and the real-data pipeline — currently failing.
- Performance on actual LLM weight files (.safetensors / .bin / .pt from real models) across all layers and dtypes; all confirmed results are on synthetic Gaussian FP32 data, and the one real-data run was unverified.
- Realistic scale (n=2M and Student-t distribution runs all failed on harness errors) and other weight distributions (quantized/int8 tensors, outliers, per-tensor scale variation).
- Absolute compression is modest (~1.19x on FP32, ~1.13x on FP16 Laplace); the measured entropy bound (26.55 bpw) suggests order-0 methods are near their ceiling, so the mission goal of a "significantly higher" ratio likely requires context modeling (order-1+, cross-plane), not just better codecs.
Next steps
- Fix the SEM codec decoder and re-run with mandatory roundtrip verification before trusting any entropy-coded numbers.
- Extend the confirmed bit-plane preregistration to FP16, Laplace/Student-t distributions, and above all real LLM checkpoint files, with exact-lossless checks as the primary gate.
- Re-run the failed n=2M and Student-t sweeps after fixing the
save_json()harness bug and installingconstriction(or replacing the range coder dependency). - Attack the remaining ~0.4 bpw gap to the theoretical entropy bound with context-based modeling (e.g., conditioning mantissa planes on the exponent class, order-1 statistics), which the current order-0 evidence suggests is where further gains must come from.
- Have the three candidate claims independently reviewed and the "unclear" novelty of byte-plane decomposition resolved against prior literature.