TL;DR
This paper introduces re-hybd, a hybrid compression strategy that enables efficient matrix-vector multiplication (MVM) directly on compressed data. By partitioning matrices into grammar-compressible and entropy-compressible components, the authors significantly reduce the memory footprint of large machine-learning matrices—especially dense ones with many unique values—while maintaining competitive computation speeds.
What Problem Does This Paper Address?
In modern machine learning, iterative algorithms (like gradient descent or power iteration) spend most of their time performing matrix-vector products. For massive matrices, the bottleneck isn't the processor's speed; it's memory bandwidth. Moving billions of real-valued entries from RAM to the CPU is slow and energy-intensive.
Lossless compression can help, but standard tools like gzip require you to decompress the entire matrix before you can use it, which defeats the purpose. The existing mm-RePair framework solved this by using grammar compression to allow math directly on the compressed format. However, mm-RePair has a "repetition" problem: it excels at sparse matrices with few distinct values but struggles with dense matrices or those containing millions of unique floating-point numbers (like word embeddings), where patterns rarely repeat.
Methods
The authors propose a multi-stage hybrid pipeline called re-hybd:
- Partitioning: The system analyzes the matrix's Compressed Sparse Row/Value (CSRV) sequence. If a pair of symbols appears more than twice, it is routed to the grammar component ($M_A$) to be compressed via RePair. Symbols that don't repeat enough to justify a grammar rule are routed to the entropy component ($M_B$).
- Entropy Coding: The $M_B$ component is encoded using
ans-fold, an entropy coder designed for large alphabets. - Ordered List Encoding (OLE): Because the order of entries within a CSR row doesn't affect the result of a multiplication, the authors sort the entries and use delta encoding. This turns large, absolute identifiers into small "gaps," which are much easier for the entropy coder to compress.
- Alphabet Remapping: If a matrix uses a sparse range of identifiers, the system remaps them to a contiguous range to save bits, provided a cost model predicts a net memory saving.
- Compressed Computation: Crucially, the MVM is performed as $Mx = M_Ax + M_Bx$. The grammar part uses the standard
mm-RePairmultiplication algorithm, while the entropy part is decoded on the fly during the dot product.
Datasets
The authors evaluated their method on ten real-valued matrices common in ML:
- Sparse Matrices:
airline78,census,covtype,imagenet, andmnist2m. - Dense/High-Entropy Matrices:
glove(word embeddings),higgs,optical,pgsf(GPT-2 hidden states), andsusy. - Quantized Variants: They also created six quantized versions of the
glovematrix (from 64 to 64k levels) to specifically study how the number of distinct values impacts compression.
Key Insights and Ideas
- The "Aha" Moment in Partitioning: The authors realized that forcing a grammar compressor to handle non-repetitive data is a waste of space. By siphoning off the "noise" into an entropy coder, the grammar for the remaining data becomes smaller and more efficient.
- Exploiting Mathematical Invariance: The use of OLE (sorting + delta encoding) is a clever use of the fact that $a \cdot x + b \cdot y = b \cdot y + a \cdot x$. By reordering data to make it more compressible, they gain efficiency without changing the mathematical output.
- Direct Stream Processing: The system never reconstructs the original matrix in memory. It treats the compressed data as a stream, performing the multiplication as it decodes, which keeps the "peak memory" usage very low.
Key Results
- Superior Compactness:
re-hybdwas more compact than the originalmm-RePairon every single test case. - Massive Gains on Dense Data: On the
susymatrix (which has over 20 million distinct values),re-hybdreduced the compressed size from 66.6% to 57.1% of the original dense matrix size. - Memory Efficiency: Peak memory during multiplication was reduced by up to 26.1% (on the
pgsfdataset) compared to the previous state-of-the-art. - Scalability: The hybrid approach scales linearly with thread count, matching the parallel performance of the original
mm-RePairwhile maintaining a smaller memory footprint.
Limitations and Future Work
- The Value Array Bottleneck: While the structure of the matrix is compressed, the
Varray (the actual floating-point values) remains uncompressed. In matrices with millions of unique values, this array itself becomes a significant portion of the memory footprint. - Compression Time: When combined with column reordering (the
re-hybd-pcvariant), compression can take a very long time (hours or even days for the largest matrices), making it best suited for "write-once, read-many" scenarios. - GPU Integration: The current implementation is CPU-based. The authors suggest that a GPU-friendly version of the entropy decoder could further accelerate performance.
Summary updated