Tensor-Matrix Products with a Compressed Sparse Tensor Shaden Smith George Karypis University of Minnesota Department of Computer Science & Engineering shaden@cs.umn.edu Tensor-Matrix Products with a Compressed Sparse Tensor 1 / 47 http://cs.umn.edu/~splatt/
Tensor Introduction Tensors are the generalization of matrices to ≥ 3 D Tensors have m dimensions (or modes ) and are I 1 × . . . × I m . users items words Tensor-Matrix Products with a Compressed Sparse Tensor 2 / 47 http://cs.umn.edu/~splatt/
Canonical Polyadic Decomposition (CPD) The CPD is an extension of the SVD to tensors We compute matrices A 1 , . . . , A m , each with F columns and λ , a vector of weights λ 1 λ F + · · · + ≈ Usually computed via alternating least squares (ALS) Tensor-Matrix Products with a Compressed Sparse Tensor 3 / 47 http://cs.umn.edu/~splatt/
MTTKRP Matricized Tensor Times Khatri-Rao Product (MTTKRP) MTTKRP is the core computation of each iteration A 1 = X (1) ( A m � · · · � A 2 ) I 1 I 2 F X (1) I 1 I 1 I 2 ( A 3 � A 2 ) Tensor-Matrix Products with a Compressed Sparse Tensor 4 / 47 http://cs.umn.edu/~splatt/
Related Work Tensor-Matrix Products with a Compressed Sparse Tensor 5 / 47 http://cs.umn.edu/~splatt/
Uncompressed Tensors Stored as a list of coordinates ( i , j , k ) = v represents one nonzero ← A 1 ( i , :) ← A 1 ( i , :) + X ( i , j , k ) [ A 2 ( j , :) ∗ A 3 ( k , :)] Tensor-Matrix Products with a Compressed Sparse Tensor 6 / 47 http://cs.umn.edu/~splatt/
Compressed Tensors SPLATT SPLATT uses a hierarchical storage scheme for 3D tensors This allows for operation reduction and coarse-grained parallelism ← Tensor-Matrix Products with a Compressed Sparse Tensor 7 / 47 http://cs.umn.edu/~splatt/
Contributions Tensor-Matrix Products with a Compressed Sparse Tensor 8 / 47 http://cs.umn.edu/~splatt/
Compressed Sparse Fiber (CSF) 1 2 i j k l i 1 1 1 2 1 1 1 3 j 1 2 2 1 2 1 3 → 1 2 2 1 k 1 1 2 1 2 2 2 1 1 2 2 1 3 2 3 3 1 1 3 2 l 2 2 2 2 Tensor-Matrix Products with a Compressed Sparse Tensor 9 / 47 http://cs.umn.edu/~splatt/
MTTKRP with a CSF Tensor Objective We want to perform MTTKRP on each tensor mode with only one CSF representation There are three types of nodes in a tree: root , internal , and leaf ◮ Each will have a tailored algorithm Tensor-Matrix Products with a Compressed Sparse Tensor 10 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT We do a depth-first traversal on the CSF structure Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 11 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Inner products are accumulated in a buffer Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 12 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Inner products are accumulated in a buffer Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 13 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Hadamard products are then propagated up the CSF tree Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 14 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Hadamard products are then propagated up the CSF tree Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 15 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Results are accumulated when we reach the top Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 16 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT The traversal continues... Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 17 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT The traversal continues... Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 18 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Partial results are kept in buffer Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 19 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Inner products are accumulated in a buffer Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 20 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT Inner products are accumulated in a buffer Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 21 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF This time, Hadamard products are pushed down the tree Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 22 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF This time, Hadamard products are pushed down the tree Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 23 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF This time, Hadamard products are pushed down the tree Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 24 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF This time, Hadamard products are pushed down the tree Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 25 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF Leaves designate write locations Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 26 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF Leaves designate write locations Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 27 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF The traversal continues... Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 28 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF The traversal continues... Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 29 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF The traversal continues... Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 30 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF The traversal continues... Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 31 / 47 http://cs.umn.edu/~splatt/
CSF-LEAF The traversal continues... Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 32 / 47 http://cs.umn.edu/~splatt/
CSF-INTERNAL Internal nodes use a combination of CSF-ROOT and CSF-LEAF Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 33 / 47 http://cs.umn.edu/~splatt/
CSF-INTERNAL Hadamard products are pushed down to the output level Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 34 / 47 http://cs.umn.edu/~splatt/
CSF-INTERNAL CSF-ROOT next pulls up to the output level Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 35 / 47 http://cs.umn.edu/~splatt/
CSF-INTERNAL CSF-ROOT next pulls up to the output level Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 36 / 47 http://cs.umn.edu/~splatt/
CSF-INTERNAL CSF-ROOT next pulls up to the output level Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 37 / 47 http://cs.umn.edu/~splatt/
CSF-INTERNAL CSF-ROOT next pulls up to the output level Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 38 / 47 http://cs.umn.edu/~splatt/
CSF-INTERNAL CSF-ROOT next pulls up to the output level Z 1 A 1 A 2 A 3 A 4 1 2 1 1 2 2 3 3 1 Tensor-Matrix Products with a Compressed Sparse Tensor 39 / 47 http://cs.umn.edu/~splatt/
Parallelism – Tiling A 1 A 3 A 2 Tensor-Matrix Products with a Compressed Sparse Tensor 40 / 47 http://cs.umn.edu/~splatt/
Datasets Dataset I 1 I 2 I 3 nnz NELL-2 12K 9K 28K 77M Beer 33K 66K 960K 94M Netflix 480K 18K 2K 100M Delicious 532K 17M 3M 140M NELL-1 3M 2M 25M 143M Amazon 5M 18M 2M 1.7B Tensor-Matrix Products with a Compressed Sparse Tensor 41 / 47 http://cs.umn.edu/~splatt/
Storage Comparison SPLATT COORD CSF-M CSF-T 99.3 10 2 51.9 47.5 36.4 Tensor storage (GB) 10 1 8.8 8.2 5.0 4.5 4.2 4.3 4.0 3.7 3.6 3.0 2.8 2.6 2.4 2.3 2.1 1.8 1.6 1.4 1.2 1.1 10 0 NELL-2 Beer Netflix Delicious NELL-1 Amazon Dataset Tensor-Matrix Products with a Compressed Sparse Tensor 42 / 47 http://cs.umn.edu/~splatt/
CSF-ROOT 90 SPLATT CSF-M CSF-T 80 Speedup over COORD with 16 threads 70 60 50 40 30 20 10 0 NELL-2 Beer Netflix Delicious NELL-1 Amazon Dataset Tensor-Matrix Products with a Compressed Sparse Tensor 43 / 47 http://cs.umn.edu/~splatt/
Recommend
More recommend