Lecture 21: ML Optimizers Slides by Boehm and Surve
Announcement Open office hours tomorrow after 1pm to talk about projects. Please drop by CS4361.
Today DB optimizers ML programs Optimization Techniques
Section 1 1. DB Optimizers
Logical vs. Physical Optimization Section 1 Logical vs. Physical Optimization SQL Query Relational Algebra (RA) Plan Logical optimization: Find equivalent plans that are more efficient Intuition: Minimize # of tuples at each step by changing the order of RA operators Physical optimization: Find algorithm with lowest IO cost to execute our plan Intuition: Calculate based on physical parameters (buffer size, etc.) and estimates of data size (histograms) Optimized RA Plan Execution
Translating to RA Π 𝐴,𝐷 ( 𝜎 𝐴<10 𝑇⋈ 𝑅⋈𝑆 ) Π 𝐴,𝐷 R(A,B) S(B,C) Section 1 Translating to RA R(A,B) S(B,C) T(C,D) Π 𝐴,𝐷 R(A,B) S(B,C) T(C,D) sA<10 SELECT R.A,S.D FROM R,S,T WHERE R.B = S.B AND S.C = T.C AND R.A < 10; Π 𝐴,𝐷 ( 𝜎 𝐴<10 𝑇⋈ 𝑅⋈𝑆 )
Optimizing RA Plan Π 𝐴,𝐷 ( 𝜎 𝐴<10 𝑇⋈ 𝑅⋈𝑆 ) Section 1 Optimizing RA Plan Push down selection on A so it occurs earlier R(A,B) S(B,C) T(C,D) Π 𝐴,𝐷 SELECT R.A,S.D FROM R,S,T WHERE R.B = S.B AND S.C = T.C AND R.A < 10; sA<10 T(C,D) R(A,B) S(B,C) Π 𝐴,𝐷 ( 𝜎 𝐴<10 𝑇⋈ 𝑅⋈𝑆 )
Optimizing RA Plan Π 𝐴,𝐷 𝑇⋈ 𝜎 𝐴<10 (𝑅)⋈𝑆 Section 1 Optimizing RA Plan Push down selection on A so it occurs earlier R(A,B) S(B,C) T(C,D) SELECT R.A,S.D FROM R,S,T WHERE R.B = S.B AND S.C = T.C AND R.A < 10; Π 𝐴,𝐷 T(C,D) sA<10 S(B,C) Π 𝐴,𝐷 𝑇⋈ 𝜎 𝐴<10 (𝑅)⋈𝑆 R(A,B)
Optimizing RA Plan Π 𝐴,𝐷 𝑇⋈ 𝜎 𝐴<10 (𝑅)⋈𝑆 Section 1 Optimizing RA Plan Push down projection so it occurs earlier R(A,B) S(B,C) T(C,D) SELECT R.A,S.D FROM R,S,T WHERE R.B = S.B AND S.C = T.C AND R.A < 10; Π 𝐴,𝐷 T(C,D) sA<10 S(B,C) Π 𝐴,𝐷 𝑇⋈ 𝜎 𝐴<10 (𝑅)⋈𝑆 R(A,B)
Optimizing RA Plan Π 𝐴,𝐷 𝑇⋈ Π 𝐴,𝑐 𝜎 𝐴<10 (𝑅)⋈𝑆 Section 1 Optimizing RA Plan We eliminate B earlier! R(A,B) S(B,C) T(C,D) Π 𝐴,𝐷 In general, when is an attribute not needed…? SELECT R.A,S.D FROM R,S,T WHERE R.B = S.B AND S.C = T.C AND R.A < 10; T(C,D) Π 𝐴,𝐶 sA<10 Π 𝐴,𝐷 𝑇⋈ Π 𝐴,𝑐 𝜎 𝐴<10 (𝑅)⋈𝑆 S(B,C) R(A,B)
Physical Optimization Section 1 Physical Optimization Physical optimization: Find algorithm with lowest IO cost to execute our plan Intuition: Calculate based on physical parameters (buffer size, etc.) and estimates of data size (histograms) Index-based selections Different join algorithms
2. ML Programs
ML Program Compilation Section 2 ML Program Compilation
Distributed Matrix Representation Section 2 Distributed Matrix Representation
Distributed Matrix Representation (2) Section 2 Distributed Matrix Representation (2)
Common Workload Characteristics Section 2 Common Workload Characteristics
3. Optimization Techniques
SystemML’s Compilation Chain Section 3 SystemML’s Compilation Chain HOP = high-level operations LOP = low-level operations
Basic HOP and LOP DAG Compilation Section 3 Basic HOP and LOP DAG Compilation
Static and Dynamic Rewrites Section 3 Static and Dynamic Rewrites
Example Static Rewrites Section 3 Example Static Rewrites
Example Dynamic Rewrites Section 3 Example Dynamic Rewrites
Matrix Multiplication Chain Optimization Section 3 Matrix Multiplication Chain Optimization
Matrix Multiplication Chain Optimization (2) Section 3 Matrix Multiplication Chain Optimization (2)
Matrix Multiplication Chain Optimization (3) Section 3 Matrix Multiplication Chain Optimization (3)
Example Operator Selection: Matrix Multiplication Section 3 Example Operator Selection: Matrix Multiplication
Fused Operators: WSLoss Section 3 Fused Operators: WSLoss
Section 3 More optimizations Dynamic Recompilation to address unknown/changing sizes Sparsity of intermediates Decisions: Split HOP DAGs for recompilation Mark HOP DAGs with unknown sizes / sparsity
Section 3 Resource Optimizer
From SystemR to SystemML – A Comparison