Abstract
Standard computer memory represents data in a fixed linear order, yet many real-world data structures like graphs and sets are inherently unordered. This discrepancy leads to an "ordering tax"—redundant bits spent to store an arbitrary permutation. We present shuffle coding, a framework that utilizes bits-back coding to reclaim this redundancy. By treating the choice of ordering as a source of randomness, shuffle coding achieves optimal lossless compression for unordered structures, yielding significant improvements over state-of-the-art ordered codecs and neural compression methods.
Introduction
In machine learning and data science, we frequently encounter data that lacks a natural sequence, such as molecular graphs, social networks, or JSON-like multisets. However, hardware and standard compression algorithms are built for ordered sequences. When we store an unordered graph of $n$ nodes, we typically choose one of $n!$ possible permutations. This choice is arbitrary and represents information that is irrelevant to the data's structure.
Shuffle coding addresses this by effectively "undoing" the cost of this arbitrary choice. It provides a theoretical "discount" on the bit rate proportional to the number of ways the data could have been ordered, adjusted for the object's internal symmetries.
Methodology
The core of shuffle coding is the integration of bits-back coding with asymmetric numeral systems (rANS). The algorithm operates in four primary steps:
- Canonicalization: The unordered object is mapped to a unique "canonical" representative using symmetry-aware tools like
nauty. - Bits-Back Decoding: A random permutation is decoded from the existing message stream. This step "reclaims" bits already present in the buffer.
- Shuffling: The canonical object is permuted according to the decoded "random" sequence.
- Ordered Encoding: The resulting ordered instance is compressed using a standard codec (e.g., an Erdős-Rényi or Pólya Urn model).
The Symmetry Discount
A key insight of this work is that the compressibility of an object is tied to its symmetry. An asymmetric object has $n!$ distinct permutations, allowing for a maximum bits-back discount. Conversely, a highly symmetric object has fewer distinct orderings, meaning there is less "ordering information" to reclaim.
As illustrated in the table above, the discount is calculated as $\log(n!) - \log(|Aut(m)|)$, where $|Aut(m)|$ is the size of the automorphism group.
Evaluation and Results
The authors evaluated shuffle coding on diverse datasets, including small molecules (MUTAG, ZINC), bioinformatics (PROTEINS), and social networks (IMDB).
The empirical results (summarized above) show that shuffle coding consistently delivers substantial bit savings. On small molecule datasets, the method achieved a 46% reduction in bit rate compared to standard ordered Erdős-Rényi (ER) models. Notably, shuffle coding combined with simple statistical models outperformed complex neural-network-based compression methods like PnC and established structural benchmarks like SZIP.
Conclusion
Shuffle coding serves as a powerful meta-algorithm that can be applied to any existing ordered data model to achieve optimal compression for unordered structures. While the computational cost of finding canonical orderings can be high for very large graphs, the significant bit savings make it a compelling choice for efficient data storage and transmission in graph-based machine learning.
Summary updated