tight enclosure of matrix multiplication with level 3 blas
play

Tight Enclosure of Matrix Multiplication with Level 3 BLAS K. Ozaki - PowerPoint PPT Presentation

Tight Enclosure of Matrix Multiplication with Level 3 BLAS K. Ozaki (Shibaura Institute of Technology) joint work with T. Ogita (Tokyo Womans Christian University) 8th Small Workshop on Interval Methods the Charles university, Prague, Czech


  1. Tight Enclosure of Matrix Multiplication with Level 3 BLAS K. Ozaki (Shibaura Institute of Technology) joint work with T. Ogita (Tokyo Woman’s Christian University) 8th Small Workshop on Interval Methods the Charles university, Prague, Czech Republic, June 10th, 2015

  2. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Introduction We focus on tight enclosure of matrix multiplication. For matrices A and B we want to obtain [ C , C ] which encloses AB by using only numerical computations (floating-point arithmetic), namely, AB ∈ [ C , C ] SWIM2015– 1

  3. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Introduction • F : set of floating-point numbers as defined by IEEE 754 • IF : set of intervals (with floating-point numbers) • u : the relative rounding error unit ( 2 − 53 for binary64) • fl( · · · ) : a computed result by floating-point arithmetic. SWIM2015– 2

  4. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Introduction For A ∈ F m × n , B ∈ F n × p , the concern is to obtain [ C ] ∈ IF m × p s.t. AB ∈ [ C ] fl △ ( · · · ) and fl ▽ ( · · · ) means a computed result with rounding upward and rounding downward, respectively. Then, we obtain [ C ] by [ C ] : = [fl ▽ ( AB ) , fl △ ( AB )] SWIM2015– 3

  5. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Introduction The code is very simple (by using INTLAB). function C = MAT(A,B) setround(-1) Cd=A*B; setround(1) Cu=A*B; C=infsup(Cd,Cu); end SWIM2015– 4

  6. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Tight Enclosure of Matrix Multiplication K. Ozaki, T. Ogita, S. Oishi: Tight and efficient enclosure of matrix multiplication by using optimized BLAS, Numerical Linear Algebra With Applications, Vol. 18:2 (2011), pp. 237-248. The following is overview in the paper. A = A (1) + A (2) , B = B (1) + B (2) , A (1) B (1) = fl( A (1) B (1) ) . Then, AB = ( A (1) + A (2) )( B (1) + B (2) ) = A (1) B (1) + A (1) B (2) + A (2) B . SWIM2015– 5

  7. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Accurate Matrix Multiplication Let a constant β be β = ⌈ (log 2 n − log 2 u ) / 2 ⌉ = ⌈ (log 2 n + 53) / 2 ⌉ . Two vectors σ ∈ F m and τ ∈ F p are defined as σ i = 2 β · 2 v i , τ j = 2 β · 2 w j , (1) where two vectors v ∈ F m and w ∈ F p are defined as (2) v i = ⌈ log 2 max 1 ≤ j ≤ n | a ij |⌉ , w j = ⌈ log 2 max 1 ≤ i ≤ n | b ij |⌉ . SWIM2015– 6

  8. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Accurate Matrix Multiplication We obtain A (1) and A (2) by ( ) ( ) a (1) a (2) a ij − a (1) (3) ij = fl ( a i j + σ i ) − σ i , ij = fl . ij Similarly, B is divided into B (1) and B (2) by ( ) ( ) b (1) b (2) b ij − b (1) (4) ij = fl ( b i j + τ j ) − τ j , ij = fl . ij SWIM2015– 7

  9. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS � log u bits = 53 bits 2 � i a ij fl ( � + a ) i ij (1) fl (( � + a ) � � ) = a i ij i ij (1) (2) fl ( a � a ) = a ij ij ij u� i Figure 1: Image of Error-Free Splitting SWIM2015– 8

  10. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Error-Free Splitting | a (1) a (1) | a (2) i j | ≤ 2 − β σ i , ij ∈ u σ i Z , ij | ≤ u σ i | b (1) b (1) | b (2) i j | ≤ 2 − β τ j , ij ∈ u τ j Z , ij | ≤ u τ j They yield n n ∑ ∑ a (1) ik b (1) | a (1) ik || b (1) u 2 σ i τ j Z ∋ kl | ≤ n 2 − 2 β σ i τ j ≤ u σ i τ j . kl ≤ k = 1 k = 1 Therefore, there is no rounding error in the dot product! SWIM2015– 9

  11. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Accurate Matrix Multiplication The matrix multiplication AB is transformed to AB = A (1) B (1) + A (1) B (2) + A (2) B = fl( A (1) B (1) ) + A (1) B (2) + A (2) B . Then, the interval matrix is obtained by AB ∈ fl( A (1) B (1) ) + [fl ▽ ( A (1) B (2) ) , fl △ ( A (1) B (2) )] + [fl ▽ ( A (2) B ) , fl △ ( A (2) B )] . SWIM2015– 10

  12. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS MATLAB Program (12 lines) function C1 = MAT2(A,B) n=size(A,2); mu=max(abs(A),[],2); temp=2.ˆ(ceil(log2(mu)+ceil(53+log2(n))/2)); sigma=repmat(temp,1,n); A1=(A+sigma)-sigma; A2=A-A1; mu=max(abs(B)); temp=2.ˆ(ceil(log2(mu))+ceil((53+log2(n))/2)); tau=repmat(temp,n,1); B1=(B+tau)-tau; B2=B-B1; C1=A1*B1+(intval(A1)*B2+intval(A2)*B); end SWIM2015– 11

  13. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Applications Andreas Frommer, Behnam Hashemi, Verified error bounds for solutions of Sylvester matrix equations, Linear Algebra and its Applications, Volume 436, Issue 2, 15 January 2012, Pages 405–420. Shinya Miyajima, Fast enclosure for solutions of Sylvester equations, Linear Algebra and its Applications, Volume 439, Issue 4, 15 August 2013, Pages 856–878. SWIM2015– 12

  14. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Extension Both A and B are divided into an unevaluated sum of three floating-point matrices, i.e. A = A (1) + A (2) + A (3) , B = B (1) + B (2) + B (3) Then, AB is transformed to AB = A (1) B (1) + A (2) B (1) + A (1) B (2) + A (1) B (3) + A (2) ( B (2) + B (3) ) + A (3) B . SWIM2015– 13

  15. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Error-Free Splitting The reason for the error-free is that n n ∑ ∑ a (1) ik b (1) | a (1) ik || b (1) u 2 σ i τ j Z ∋ kl | ≤ n 2 − 2 β σ i τ j ≤ u σ i τ j . kl ≤ k = 1 k = 1 However, it is very rare to find that the upper bound of the dot product becomes u σ i τ j . We want to make β more small but ... SWIM2015– 14

  16. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS New Error-Free Transformation Let 1 ≤ β ′ ≤ β . Replacing β with β ′ in (1) we define two vectors σ i = 2 β ′ · 2 v ( k ) τ j = 2 β ′ · 2 w ( l ) j , i , ˜ ˜ where v ( k ) and w ( l ) j are defined by i v ( k ) 1 ≤ j ≤ n | a ( k ) w ( l ) 1 ≤ i ≤ n | b ( l ) = ⌈ log 2 max ij |⌉ , j = ⌈ log 2 max ij |⌉ . i SWIM2015– 15

  17. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS We divide A and B as follows: a (1) b (1) σ i ) , ˜ ˜ i j = fl(( a i j + ˜ σ i ) − ˜ ij = fl(( b ij + ˜ τ j ) − ˜ τ j ) , a (2) a (1) b (2) b (1) i j ) , ˜ ij = fl( b ij − ˜ ˜ i j = fl( a i j − ˜ ij ) . Then, A = ˜ A (1) + ˜ B = ˜ B (1) + ˜ A (2) , B (2) , but A (1) ˜ A (1) ˜ fl( ˜ B (1) ) = ˜ B (1) ? SWIM2015– 16

  18. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS New Error-Free Transformation First, we define a constant c ∈ R by ( c ) c = 2 r , r ∈ N , fl � Inf , fl( c ) = Inf 2 For example, c is 2 1024 for binary64. Next, we set two constants d 1 and d 2 with powers of two: d 1 = 2 486 and d 2 = 2 485 for binary64 d 1 d 2 = c u , SWIM2015– 17

  19. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS New Error-Free Transformation Let two vectors x ∈ F m and y ∈ F p be x i = d 1 y i = d 2 , . u ˜ σ i u ˜ τ i A (1) and ˜ B (1) are applied as Then, diagonal scalings for ˜ follows: A = diag ( x ) ˜ ˙ A (1) , B = ˜ ˙ B (1) diag ( y ) . SWIM2015– 18

  20. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS New Error-Free Transformation After the diagonal scaling, we have ˙ a ij ∈ d 1 Z , ˙ b ij ∈ d 2 Z . Therefore, a i j ˙ ˙ b i j ∈ d 1 d 2 Z = u c Z For binary64, a ij ˙ b ij ∈ 2 971 Z ˙ SWIM2015– 19

  21. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS New Error-Free Transformation Theorem 1 Let T : = fl( ˙ A ˙ B ) . If t ij � { Inf , − Inf , NaN } is satisfied for all pairs of ( i , j ) , then ˙ A ˙ B = fl( ˙ A ˙ B ) . SWIM2015– 20

  22. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS 1024 971 2 2 53 bits (1) (1) a b i 1 1 j (1) (1) a b i 2 2 j (1) (1) a b i 3 3 j . . . (1) (1) a b in nj omputed result or omputed result Figure 2: Image of ’error-free’ SWIM2015– 21

  23. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Step 1. Compute ˜ A (1) , ˜ A (2) , ˜ B (1) , ˜ B (2) 2. Diagonal scaling ˙ A = diag ( x ) ˜ A (1) , ˙ B = ˜ B (1) diag ( y ) 3. Check T = fl( ˙ A ˙ B ) contains ± Inf or NaN 4. If not, interval computations for diag ( x ) − 1 · T · diag ( y ) − 1 + ˜ A (1) ˜ B (2) + ˜ A (2) B SWIM2015– 22

  24. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Numerical Example We compare the tightness of the enclosure of • M1: [fl ▽ ( AB ) , fl △ ( AB )] • M2: The original method • M3: A posteriori Validation for B = gallery ( ′ randsvd ′ , n , cnd , 3) , A = inv ( B ) . SWIM2015– 23

  25. Katsuhisa Ozaki Tight Enclosure of Matrix Multiplication with Level 3 BLAS Numerical Example (log 2 2 √ n − log 2 u ) / 2 ⌈ ⌉ Table 1: Maximum Radius for n = 1000 ( β ′ = ) cnd M1 M2 M3 10 2 2.1886e-14 2.2204e-16 1.1102e-16 10 4 1.1438e-12 2.2204e-16 1.6653e-16 10 6 8.1741e-11 2.2204e-16 2.2204e-16 10 8 6.3854e-09 1.1979e-14 2.9039e-15 10 10 5.4939e-07 9.1551e-13 2.2889e-13 10 12 4.7074e-05 9.1188e-11 2.1964e-11 10 14 4.0933e-03 7.7183e-09 1.9427e-09 SWIM2015– 24

Recommend


More recommend