[Paper Review] Sparse Tensor Algebra Optimizations with Workspaces
This paper introduces concrete index notation, a new intermediate language for sparse tensor algebra, and a workspace optimization that uses dense temporary tensors (workspaces) to accelerate sparse computations. By hoisting loop-invariant operations and eliminating expensive sparse insertions and merge loops, the method achieves performance on par with hand-optimized libraries like MKL and SPLATT, enabling previously unsupported sparse results in kernels like MTTKRP.
This paper shows how to optimize sparse tensor algebraic expressions by introducing temporary tensors, called workspaces, into the resulting loop nests. We develop a new intermediate language for tensor operations called concrete index notation that extends tensor index notation. Concrete index notation expresses when and where sub-computations occur and what tensor they are stored into. We then describe the workspace optimization in this language, and how to compile it to sparse code by building on prior work in the literature. We demonstrate the importance of the optimization on several important sparse tensor kernels, including sparse matrix-matrix multiplication (SpMM), sparse tensor addition (SpAdd), and the matricized tensor times Khatri-Rao product (MTTKRP) used to factorize tensors. Our results show improvements over prior work on tensor algebra compilation and brings the performance of these kernels on par with state-of-the-art hand-optimized implementations. For example, SpMM was not supported by prior tensor algebra compilers, the performance of MTTKRP on the nell-2 data set improves by 35%, and MTTKRP can for the first time have sparse results.
Motivation & Objective
- To address the performance gap in sparse tensor algebra compilers by enabling optimizations that use temporary dense tensors (workspaces).
- To generalize sparse tensor code generation to support kernels with sparse results, such as MTTKRP and SpMM, which were previously infeasible or slow.
- To improve performance by eliminating conditional merge loops and expensive sparse insertions during computation.
- To provide a formal, composable intermediate representation that enables aggressive optimization before sparse code generation.
Proposed method
- Introduces concrete index notation, an extension of tensor index notation that specifies loop order, sub-computation placement, and workspace usage.
- Applies a workspace optimization that rewrites tensor expressions to pre-compute sub-expressions in dense temporary tensors (workspaces) to reduce runtime cost.
- Uses scheduling constructs to request workspace insertion, enabling loop-invariant code motion and avoiding repeated sparse insertions.
- Lowers concrete index notation to iteration graphs from prior work (Kjolstad et al., 2017), enabling compilation to efficient sparse code.
- Applies the optimization to key kernels: SpMM, SpAdd, and MTTKRP, demonstrating generality and performance gains.
- Employs workspaces to replace multi-way merge loops with random access patterns, reducing conditional branching and improving data locality.
Experimental results
Research questions
- RQ1How can sparse tensor algebra be optimized using dense temporary tensors (workspaces) to improve performance?
- RQ2Can the workspace optimization be expressed and compiled in a high-level intermediate language that precisely controls when and where sub-computations occur?
- RQ3Can the optimization enable previously unsupported sparse results in tensor kernels like MTTKRP and SpMM?
- RQ4How does the performance of the optimized code compare to hand-optimized, state-of-the-art libraries like MKL and SPLATT?
- RQ5Can the optimization be generalized to a broad class of sparse tensor kernels beyond the studied cases?
Key findings
- The workspace optimization improves MTTKRP performance on the nell-2 dataset by 35% compared to prior tensor algebra compilation.
- SpMM, which was not supported by prior tensor algebra compilers, is now efficiently compiled and performs competitively with hand-optimized implementations.
- The method enables sparse results for MTTKRP for the first time, expanding the scope of supported tensor operations.
- The optimization reduces expensive sparse insertions and conditional merge loops, replacing them with efficient random access to dense workspaces.
- The resulting code achieves performance comparable to state-of-the-art libraries such as MKL, Eigen, and SPLATT, demonstrating the effectiveness of the approach.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.