1 / 27

Large-Scale Matrix Operations Using a Data Flow Engine

Large-Scale Matrix Operations Using a Data Flow Engine. Matei Zaharia. Outline. Data flow vs. traditional network programming Limitations of MapReduce Spark computing engine Matrix operations on Spark. Problem. Data growing faster than processing speeds

trella
Download Presentation

Large-Scale Matrix Operations Using a Data Flow Engine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Large-Scale Matrix Operations Using a Data Flow Engine Matei Zaharia

  2. Outline • Data flow vs. traditional network programming • Limitations of MapReduce • Spark computing engine • Matrix operations on Spark

  3. Problem • Data growing faster than processing speeds • Only solution is to parallelize on large clusters • Wide use in both enterprises and web industry How do we program these things?

  4. Traditional Network Programming • Message-passing between nodes (e.g. MPI) • Very difficult to do at scale: • How to split problem across nodes? • Must consider network & data locality • How to deal with failures? (inevitable at scale) • Even worse: stragglers (node not failed, but slow) Rarely used in commodity datacenters

  5. Data Flow Models • Restrict the programming interface so that the system can do more automatically • Express jobs as graphs of high-level operators • System picks how to split each operator into tasks and where to run each task • Run parts twice fault recovery • Biggest example: MapReduce Map Reduce Map Reduce Map

  6. MapReduce for Matrix Operations • Matrix-vector multiply • Power iteration (e.g. PageRank) • Gradient descent methods • Stochastic SVD • Tall skinny QR • Many others!

  7. Why Use a Data Flow Engine? • Ease of programming • High-level functions instead of message passing • Wide deployment • More common than MPI, especially “near” data • Scalability to very largest clusters • Even HPC world is now concerned about resilience

  8. Outline • Data flow vs. traditional network programming • Limitations of MapReduce • Spark computing engine • Matrix operations on Spark

  9. Limitations of MapReduce • MapReduce is great at one-pass computation, but inefficient for multi-pass algorithms • No efficient primitives for data sharing • State between steps goes to distributed file system • Slow due to replication & disk storage • No control of data partitioning across steps

  10. Example: Iterative Apps file systemread file systemwrite file systemread file systemwrite iter. 1 iter. 2 . . . Input result 1 file systemread query 1 result 2 query 2 query 3 result 3 Input . . . Commonly spend 90% of time doing I/O

  11. Example: PageRank • Repeatedly multiply sparse matrix and vector • Requires repeatedly hashing together page adjacency lists and rank vector Same file grouped over and over Neighbors (id, edges) Ranks (id, rank) … iteration 1 iteration 2 iteration 3

  12. Spark Programming Model • Extends MapReduce with primitives for efficient data sharing • “Resilient distributed datasets” • Open source in Apache Incubator • Growing community with 100+ contributors • APIs in Java, Scala & Python

  13. Resilient Distributed Datasets (RDDs) • Collections of objects stored across a cluster • User-controlled partitioning & storage (memory, disk, …) • Automatically rebuilt on failure Known to behash-partitioned urls = spark.textFile(“hdfs://...”) records = urls.map(lambda s: (s, 1)) counts = records.reduceByKey(lambda a, b: a + b) bigCounts = counts.filter(lambda (url, cnt): cnt > 10) Also known map reduce filter bigCounts.cache() bigCounts.filter(lambda (k,v): “news” in k).count() bigCounts.join(otherPartitionedRDD) Input file

  14. Performance Time per Iteration (s)

  15. Outline • Data flow vs. traditional network programming • Limitations of MapReduce • Spark computing engine • Matrix operations on Spark

  16. PageRank • Using cache(), keep neighbors in RAM • Using partitioning, avoid repeated hashing partitionBy Neighbors (id, edges) Ranks (id, rank) … join join join

  17. PageRank • Using cache(), keep neighbors in RAM • Using partitioning, avoid repeated hashing partitionBy Neighbors (id, edges) samenode Ranks (id, rank) … join join join

  18. PageRank • Using cache(), keep neighbors in RAM • Using partitioning, avoid repeated hashing partitionBy Neighbors (id, edges) Ranks (id, rank) … join join join

  19. PageRank Code • # RDD of (id, neighbors) pairslinks = spark.textFile(...).map(parsePage) .partitionBy(128).cache() • ranks = links.mapValues(lambda v: 1.0) # RDD of (id, rank)foriin range(ITERATIONS): • ranks = links.join(ranks).flatMap( • lambda (id, (links, rank)): • [(d, rank/links.size) for d in links] • ).reduceByKey(lambda a, b: a + b)

  20. PageRank Results

  21. Alternating Least Squares • Start with random A1, B1 • Solve for A2 to minimize ||R – A2B1T|| • Solve for B2to minimize ||R – A2B2T|| • Repeat until convergence R A BT =

  22. Joint work withJoey Gonzales,Virginia Smith ALS on Spark • Cache 2 copies of R in memory, one partitioned by rows and one by columns • Keep A & B partitioned in corresponding way • Operate on blocks to lower communication R A BT =

  23. ALS Results

  24. Benefit for Users • Same engine performs data extraction, model training and interactive queries Separate engines DFS read DFS read DFS read parse train query DFS write DFS write DFS write … Spark train query DFS read parse DFS

  25. Other Projects on Spark • MLlib: built-in Spark library for ML • Includes ALS, K-means||, various algorithms on SGD • Frankin, Gonzales et al. [MLOSS ‘13] • MLI:Matlab-like language for writing apps • Basic ALS in 35 lines of code • Evan Sparks, AmeetTalwalkar et al. [ICDM ‘13]

  26. Spark Community • 100+ developers, 25+ companies contributing;most active development community after Hadoop

  27. Conclusion • Data flow engines are becoming an important platform for matrix algorithms • Spark offers a simple programming model that greatly speeds these up • More info: spark.incubator.apache.org

More Related