Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges Shaden Smith & George Karypis University of Minnesota Department of Computer Science & Engineering shaden@cs.umn.edu Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Talk Outline Introduction 1 Compressed Sparse Fiber 2 Cache-Friendly Reordering & Tiling 3 Distributed-Memory MTTKRP 4 Conclusions 5 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Table of Contents Introduction 1 Compressed Sparse Fiber 2 Cache-Friendly Reordering & Tiling 3 Distributed-Memory MTTKRP 4 Conclusions 5 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Tensor Introduction Tensors are the generalization of matrices to ≥ 3 D Tensors have m dimensions (or modes ) and are I 1 × . . . × I m ◮ We’ll usually stick to I × J × K in this talk users contexts items Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Applications Dataset I J K 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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Canonical Polyadic Decomposition (CPD) We compute matrices A , B , C , each with F columns ◮ We will use A (1) , . . . , A ( m ) when ≥ 3 modes ≈ + · · · + Usually computed via alternating least squares (ALS) Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Matricized Tensor Times Khatri-Rao Product MTTKRP MTTKRP is the core computation of each iteration A = X (1) ( C � B ) J · K F X (1) I J · K ( C � B ) Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Alternating Least Squares 1: while not converged do A ⊺ = ( C ⊺ C ∗ B ⊺ B ) − 1 � � ⊺ X (1) ( C � B ) 2: B ⊺ = ( C ⊺ C ∗ A ⊺ A ) − 1 � � ⊺ X (2) ( C � A ) 3: C ⊺ = ( B ⊺ B ∗ A ⊺ A ) − 1 � � ⊺ X (3) ( B � A ) 4: 5: end while Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Tensor Storage – Coordinate Form i j k l v 1 1 1 2 1 . 1 1 1 3 1 . 1 2 1 3 3 . 1 2 2 1 8 . 2 2 1 1 1 . 2 2 1 3 3 . 2 2 2 2 8 . Why don’t we unfold? We need a representation of X for each mode NELL has dimensions 3 M × 2 M × 25 M ◮ Add a fourth mode and we exceed 2 64 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
MTTKRP A C i ← k B j A ( i , :) ← A ( i , :) + X ( i , j , k ) [ B ( j , :) ∗ C ( k , :)] Limitations Memory bandwidth Parallelism Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Table of Contents Introduction 1 Compressed Sparse Fiber 2 Cache-Friendly Reordering & Tiling 3 Distributed-Memory MTTKRP 4 Conclusions 5 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Can we do better? Consider three nonzeros in the fiber X ( i , j , :) (a vector) A ( i , :) ← A ( i , :) + X ( i , j , k 1 ) [ B ( j , :) ∗ C ( k 1 , :)] A ( i , :) ← A ( i , :) + X ( i , j , k 2 ) [ B ( j , :) ∗ C ( k 2 , :)] A ( i , :) ← A ( i , :) + X ( i , j , k 3 ) [ B ( j , :) ∗ C ( k 3 , :)] Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Can we do better? Consider three nonzeros in the fiber X ( i , j , :) (a vector) A ( i , :) ← A ( i , :) + X ( i , j , k 1 ) [ B ( j , :) ∗ C ( k 1 , :)] A ( i , :) ← A ( i , :) + X ( i , j , k 2 ) [ B ( j , :) ∗ C ( k 2 , :)] A ( i , :) ← A ( i , :) + X ( i , j , k 3 ) [ B ( j , :) ∗ C ( k 3 , :)] A little factoring... � � 3 � A ( i , :) ← A ( i , :) + B ( j , :) ∗ X ( i , j , k x ) C ( k x , :) x =1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
SPLATT: The S urprisingly P aralle L sp A rse T ensor T oolkit ← [Smith, Ravindran, Sidiropoulos, and Karypis 2015] Fibers are sparse vectors Slice X ( i , : , :) is almost a CSR matrix... But, we need m representations of X Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 1 1 2 1 2 k 2 2 1 1 2 2 1 3 2 3 3 1 1 3 2 l 2 2 2 2 [Smith and Karypis 2015] Modes are recursively compressed Values are stored in the leaves (not shown) Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 ◮ root and leaf are special cases of internal Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF The leaf nodes determine the output location Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF 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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF 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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF 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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF The traversal continues... Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF The traversal continues... Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF The traversal continues... Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF The traversal continues... Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-LEAF The traversal continues... Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-ROOT Results are written to A (1) Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-ROOT The traversal continues... Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
CSF-ROOT The traversal continues... Z 1 A (1) A (2) A (3) A (4) 1 2 1 1 2 2 3 3 1 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
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 Sparse Tensor Factorization: Algorithms, Data Structures, and Challenges shaden@cs.umn.edu
Recommend
More recommend