Abstract
Standard inference in dynamic graphical models, such as Hidden Markov Models (HMMs) and Conditional Random Fields (CRFs), typically relies on the forward-backward algorithm, which suffers from a linear $O(T)$ memory requirement relative to sequence length. This paper presents the "Archipelagos Algorithm" (AA), a novel approach that leverages multi-core processors to perform memory-efficient inference. By utilizing redundant computations across concurrent threads, AA reduces memory requirements exponentially to $O(T^{1/d})$ for $d$ cores without increasing overall runtime.
Introduction
In sequence modeling applications ranging from bioinformatics to natural language processing, the forward-backward (FB) algorithm is a fundamental tool. However, its $O(T)$ memory complexity—necessitated by storing forward messages for the backward pass—poses a significant bottleneck for long sequences or large state spaces. While the "Island Algorithm" (IA) offers memory savings by storing sparse checkpoints and recomputing gaps, it introduces a linear runtime penalty. The Archipelagos Algorithm aims to achieve the memory efficiency of IA while maintaining the execution speed of standard FB by parallelizing the recomputation process.
The Archipelagos Algorithm
The Archipelagos Algorithm (AA) repurposes multi-core architectures to handle redundant recomputations simultaneously. Unlike traditional parallelization that splits a sequence into independent chunks, AA uses a hierarchical thread structure:
- Top-level threads compute sparse "islands" across the entire sequence.
- Intermediate threads consume these islands to generate denser sub-islands.
- The backward pass thread consumes fully dense forward messages just-in-time as they are produced by the lowest-level forward thread.
By running these processes concurrently, the latency of recomputing messages is hidden. The backward thread never stalls, ensuring the total runtime matches that of the standard FB algorithm.
Mechanism and Scaling
The hierarchical nature of AA allows for exponential memory reduction. With $d$ cores, the memory footprint is reduced to $O(T^{1/d})$. As the number of levels increases, the granularity of the "islands" becomes finer, further shrinking the amount of data that must be stored at any given time.
Beyond the basic algorithm, the authors propose extensions such as Double-ended Archipelagos, which initiates inference from both ends of a sequence for a 2x speedup, and adaptations for Structured State Spaces using temporal junction trees to minimize per-frame memory usage.
Experimental Results
Evaluation on synthetic HMMs with varying hidden states ($n_Y$ up to 10,000) and sequence lengths ($T$ up to $10^7$) demonstrated significant benefits:
- Memory Efficiency: For a sequence of $10^7$ steps, AA reduced memory usage from 8 GB (standard FB) to just 319 KB using 4 cores—a ~25,000x reduction.
- Runtime Performance: AA maintained parity with standard FB runtime (e.g., 301s vs 297s), whereas the single-core Island Algorithm was over twice as slow (624s).
- Cache Benefits: In several scenarios, the drastically reduced memory footprint allowed data to fit within the CPU's L2 cache, resulting in AA occasionally outperforming standard FB due to fewer main memory accesses.
Discussion and Conclusion
The primary performance guarantee of AA—that it will not exceed the runtime of standard FB—relies on the forward pass being at least as fast as the backward pass. If the forward pass is significantly slower, AA could potentially take up to twice as long. However, the double-ended variant can mitigate this risk.
In conclusion, the Archipelagos Algorithm demonstrates that extra computational cores can be effectively traded for massive reductions in memory footprint. This "parallel-for-memory" paradigm is particularly valuable as datasets grow and compute becomes increasingly multi-core, providing a practical solution for large-scale graphical model inference on modern hardware.
Summary updated