Abstract
The performance of neural networks improves when more parameters are used. However, the model sizes are constrained by the available on-device memory during training and inference. Although applying techniques like quantization can alleviate the constraint, they suffer from performance degradation. In this work, we introduce NeuZip, a new weight compression scheme based on the entropy of floating-point numbers in neural networks. With NeuZip, we are able to achieve memory-efficient training and inference without sacrificing performance. Notably, we significantly reduce the memory footprint of training a Llama-3 8B model from 31GB to less than 16GB, while keeping the training dynamics fully unchanged. In inference, our method can reduce memory usage by more than half while maintaining near-lossless performance.
Introduction: The Memory Wall
In the era of "Scaling Laws," model performance is directly tied to parameter count. However, while model sizes have exploded—GPT-3 is 100x larger than the original Transformer—GPU memory has only grown by approximately 2.5x in the same period. This "memory wall" makes training and running state-of-the-art models prohibitively expensive, often requiring enterprise-grade hardware.
Existing solutions like quantization (e.g., INT8, FP4) often degrade model performance, while optimizer tricks and offloading to CPU RAM introduce significant speed bottlenecks. NeuZip addresses this by compressing model weights during full-parameter training without sacrificing the precision required for effective learning.
Methodology: Exploiting Floating-Point Entropy
NeuZip's core innovation stems from a fine-grained analysis of how computers store numbers in formats like BFloat16, which consists of a sign bit, 8 exponent bits, and 7 mantissa bits.
The Entropy Discovery
The authors observed that neural network weights are typically concentrated around zero. This concentration results in exponent bits having very low entropy, as they remain relatively constant across the model. In contrast, sign bits are essentially random, and mantissas are dense with information.
Lossless and Lossy Compression
For training, NeuZip employs Asymmetric Numeral Systems (ANS)—a high-throughput, parallelizable entropy coding algorithm—to compress these low-entropy exponents losslessly. Because the compression is lossless, the training mathematics remain identical to standard training, ensuring zero accuracy loss. This property holds even for randomly initialized models, allowing NeuZip to be effective from the very first iteration.
For inference, where models exhibit higher robustness to noise, NeuZip introduces a "lossy" mode. By truncating the mantissa bits (keeping only the top $k$ bits), users can trade a negligible amount of accuracy for substantial memory savings, often outperforming standard quantization methods like NF4 on the Pareto frontier.
Dynamic Execution and Orthogonality
To prevent memory spikes during decompression, NeuZip utilizes the multi-layer structure of neural networks. It decompresses weights layer-by-layer during forward and backward passes, discarding the uncompressed versions immediately after use. This approach is orthogonal to other techniques like activation checkpointing (AC), allowing them to be used in tandem to further push memory limits.
Key Results
NeuZip demonstrates significant memory efficiency across various benchmarks, including Wikitext-2, MMLU, and WMT14 En-De.
- Training Llama-3 8B: Peak memory usage was reduced from 30.97 GiB to 15.25 GiB. This allows a model that previously required an 80GB A100 to be trained on consumer-grade hardware like an RTX 3090 or 4090 (24GB).
- Training Llama-2 13B: Memory requirements dropped to 18.58 GiB, fitting comfortably within consumer GPU limits.
- Inference Efficiency: For the Yi-1.5 34B model, NeuZip halved memory usage while maintaining a perplexity significantly lower than 4-bit quantization alternatives.
- Throughput: Despite the computational overhead of ANS compression/decompression, NeuZip remains faster than CPU-offloading due to its highly parallel GPU implementation.
Conclusion and Future Work
NeuZip provides a path toward democratizing large-scale model training. While it introduces a speed trade-off (e.g., Llama-3 8B training throughput decreased from 0.77 to 0.45 iterations/sec), the memory savings are transformative. Future work will explore scaling NeuZip to trillion-parameter models and optimizing ANS kernels for non-NVIDIA hardware.
Summary updated