When Lempel-Ziv-Welch Meets Machine Learning: A Case Study of Accelerating Machine Learning using Coding

Fengan Li, Lingjiao Chen, Arun Kumar, Jeffrey F. Naughton, Jignesh M. Patel, Xi WuarXiv 2017 · DOI

Abstract

Data compression is a popular technique for improving the efficiency of data processing workloads such as SQL queries and more recently, machine learning (ML) with classical batch gradient methods. But the efficacy of such ideas for mini-batch stochastic gradient descent (MGD), arguably the workhorse algorithm of modern ML, is an open question. MGD's unique data access pattern renders prior art, including those designed for batch gradient methods, less effective. We fill this crucial research gap by proposing a new lossless compression scheme we call tuple-oriented compression (TOC) that is inspired by an unlikely source, the string/text compression scheme Lempel-Ziv-Welch, but tailored to MGD in a way that preserves tuple boundaries within mini-batches. We then present a suite of novel compressed matrix operation execution techniques tailored to the TOC compression scheme that operate directly over the compressed data representation and avoid decompression overheads. An extensive empirical evaluation with real-world datasets shows that TOC consistently achieves substantial compression ratios by up to 51x and reduces runtimes for MGD workloads by up to 10.2x in popular ML systems.

Introduction

Mini-batch Stochastic Gradient Descent (MGD) is the fundamental algorithm for training modern machine learning models. However, as training datasets grow exponentially, they frequently exceed available RAM. When this occurs, the system must constantly load mini-batches from disk, turning a compute-heavy task into a sluggish I/O-bound bottleneck.

Standard data compression methods often fall short for MGD. General-purpose compressors (e.g., Gzip, Snappy) achieve high ratios but require full decompression before matrix operations, creating a CPU overhead that negates I/O savings. Conversely, Lightweight Matrix Compression (LMC) formats allow math directly on compressed data but struggle to achieve significant compression on the small data chunks (mini-batches) used in MGD.

Conceptual comparison of MGD workflows and the performance trade-offs between compression ratio and decompression overhead.

Tuple-Oriented Compression (TOC)

To address these challenges, we propose Tuple-Oriented Compression (TOC), a lossless scheme that operates in three layers to maximize compression while enabling direct execution of matrix operations:

  1. Sparse Encoding: As a baseline, TOC ignores zero values and stores only non-zero values paired with their column indices.
  2. Logical Encoding: Drawing inspiration from Lempel-Ziv-Welch (LZW), TOC identifies repeating sequences of column-value pairs across different rows and builds a prefix tree (dictionary). Crucially, unlike standard LZW, TOC strictly preserves row and column boundaries (tuples) so the mathematical structure remains intact.
  3. Physical Encoding: Finally, TOC uses bit-packing and value indexing to minimize the byte footprint of the resulting integers and tree pointers.
The three-step TOC encoding process: Sparse Encoding, Logical Encoding via a prefix tree, and Physical Encoding.

Because structural boundaries are preserved, matrix operations (like matrix-vector multiplication) can be reformulated to execute by scanning the compressed prefix tree and encoded tables directly. This eliminates the need for costly decompression.

Empirical Evaluation

We evaluated TOC on six real-world datasets with varying degrees of sparsity, including US Census, ImageNet, and Rcv1. To test out-of-core performance, we generated scaled-up versions of these datasets to exceed memory capacity.

Key Results

  • High Compression: On moderately sparse datasets, TOC achieves compression ratios up to 51x, which is comparable to Gzip and up to 3.8x better than state-of-the-art LMC schemes.
  • Execution Speed: By skipping decompression, matrix operations on TOC-compressed data are up to 20,000x faster than operations on data compressed with general formats like Gzip.
  • End-to-End Training: When training models on datasets that exceed memory, TOC reduces overall MGD runtimes by up to 10.2x compared to standard encodings used in popular systems like TensorFlow and Scikit-Learn.

Conclusion and Future Work

TOC demonstrates that adapting classic text compression for tabular ML data is highly effective, provided the structural boundaries are respected. While TOC is not a silver bullet for extremely dense or extremely sparse data, it offers massive speedups for enterprise datasets with moderate redundancy. Future work will explore extending TOC to Convolutional Neural Networks (CNNs), where the data replication in "image-to-column" operations offers significant potential for compression-driven acceleration.

Summary updated

BibTeX
@misc{li2017when,
  author = {Fengan Li and Lingjiao Chen and Arun Kumar and Jeffrey F. Naughton and Jignesh M. Patel and Xi Wu},
  title = {{When Lempel-Ziv-Welch Meets Machine Learning: A Case Study of Accelerating Machine Learning using Coding}},
  year = {2017},
  eprint = {1702.06943},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1702.06943},
}

Loading related content...

Figure