TL;DR
Researchers at Sandia National Laboratories have developed a "write-once, run-anywhere" software framework for sparse tensor decomposition. By leveraging the Kokkos library and introducing novel abstractions like "compile-time polymorphic arrays," their implementation matches or exceeds the performance of architecture-specific codes across CPUs, manycore processors (Xeon Phi), and GPUs.
What Problem Does This Paper Address?
Tensors (multidimensional arrays) are essential for modeling complex relationships in data science, from social network analysis to health analytics. However, real-world tensors are often "sparse"—mostly filled with zeros—making them computationally difficult to process.
The "engine" of tensor decomposition is a kernel called MTTKRP (Matricized Tensor Times Khatri-Rao Product). Historically, achieving high performance for MTTKRP required writing custom, low-level code for every different type of hardware (e.g., one version for Intel CPUs, another for NVIDIA GPUs). This creates a massive maintenance burden and prevents software from being "future-proof" as new architectures emerge. The authors tackle the challenge of performance portability: creating a single codebase that is fast on everything.
Methods
The authors introduce three key innovations to achieve their goal:
- Hierarchical Parallelism via Kokkos: They use the Kokkos framework to map the MTTKRP algorithm onto three levels of hardware abstraction: Leagues (groups of teams), Teams (groups of threads), and Vector units (fine-grained SIMD/SIMT).
- TinyVec (Compile-Time Polymorphic Arrays): Standard thread-local memory allocation is often slow or limited on GPUs. The authors created
TinyVec, a wrapper that automatically stores temporary data in fast CPU stack memory or high-speed GPU registers depending on the target hardware. This avoids the overhead of "scratchpad" memory. - Permuted Traversal (MTTKRP-C): Parallel writes to the same memory location (race conditions) usually require "atomic" operations, which are notoriously slow. The authors proposed sorting the tensor's nonzeros (using permutation arrays) so that each thread processes data in an order that minimizes these conflicts, replacing expensive atomics with faster "segmented reductions."
Datasets
The implementation was evaluated using:
- Synthetic Data: A 3D tensor of size 30,000 × 40,000 × 50,000 with 10 million nonzeros.
- FROSTT Repository: A collection of real-world sparse tensors including:
- LBNL: Network traffic data.
- Uber: Pickup locations/times.
- Enron: Email metadata.
- VAST: Cyber security challenge data.
- NELL2: Language modeling data.
- Delicious: Social bookmarking data.
Key Insights and Ideas
- Data Layout vs. Hardware: The authors found that for sparse tensors, the coordinate (COO) format is superior for portability because it doesn't favor one specific "mode" or dimension of the tensor over others.
- The Cost of Atomics: On older GPU architectures (like the NVIDIA K80), atomic operations for double-precision numbers are extremely slow. The "Permuted" approach (MTTKRP-C) showed that it is often faster to spend time sorting data upfront than to fight for memory locks during the computation.
- Registers are King: By forcing temporary buffers into GPU registers via
TinyVec, the authors achieved significantly higher memory bandwidth efficiency than standard GPU programming patterns.
Key Results
- Massive Speedups: Compared to a single-core Haswell CPU, the portable code achieved a 20-fold speedup on a full Haswell node and a 147-fold speedup on an NVIDIA P100 GPU.
- Competitive with Specialists: The code (GenTen) was compared against SPLATT, a state-of-the-art library specifically hand-tuned for CPUs. The authors' portable code was often faster than SPLATT on manycore architectures like the Intel Xeon Phi (KNL).
- Efficiency: On the NVIDIA P100, the MTTKRP-C variant reached nearly 100% of the peak theoretical memory bandwidth for large numbers of components ($R=128$), proving that the abstraction layer didn't sacrifice "metal-level" performance.
Limitations and Future Work
- Memory Overhead: The "Permuted" approach requires storing additional index arrays, which roughly doubles the memory footprint of the tensor indices. This caused the largest dataset (Delicious) to exhaust the memory on older 12GB GPUs.
- Preprocessing Cost: While the sorting (permutation) makes the main algorithm faster, it adds an initial setup cost. The authors note this is usually worth it for the many iterations required in a full decomposition, but it's a factor to consider for one-off calculations.
- Next Steps: The authors plan to extend this work to distributed memory (clusters of many machines) and generalize the methods to handle different types of data, such as binary or count data.
Reference: Phipps, E., & Kolda, T. G. (2019). Software for Sparse Tensor Decomposition on Emerging Computing Architectures. arXiv:1809.09175v2 [cs.MS].
Summary updated