Apache Hadoop, since its humble beginning as an execution engine for web crawler and building search indexes, has matured into a general purpose distributed application platform and data store. Large Scale Machine Learning (LSML) techniques and algorithms proved to be quite tricky for Hadoop to handle, ever since we started offering Hadoop as a service at Yahoo in 2006. In this talk, I will discuss early experiments of implementing LSML algorithms on Hadoop at Yahoo. I will describe how it changed Hadoop, and led to generalization of the Hadoop platform to accommodate programming paradigms other than MapReduce. I will unveil some of our recent efforts to incorporate diverse LSML runtimes into Hadoop, evolving it to become *THE* LSML platform. I will also make a case for an industry-standard LSML benchmark, based on common deep analytics pipelines that utilize LSML workload.
2. About Me
• http://www.linkedin.com/in/milindb
• Founding member of Hadoop team atYahoo! [2005-2010]
• Contributor to Apache Hadoop since v0.1
• Built and led Grid SolutionsTeam atYahoo! [2007-2010]
• Parallel Programming Paradigms [1989-today] (PhD cs.illinois.edu)
• Center for Development of Advanced Computing (C-DAC), National Center
for Supercomputing Applications (NCSA), Center for Simulation of Advanced
Rockets, Siebel Systems (acquired by Oracle), Pathscale Inc. (acquired by
QLogic),Yahoo!, LinkedIn, and Pivotal (formerly Greenplum)
Wednesday, December 18, 2013
3. Acknowledgements
•Developers of various Open-Source, and
Proprietary Data Platforms
•Ex-Colleagues atYahoo! Research
•Colleagues at Data ScienceTeam, Pivotal
•Vijay Narayanan, Microsoft
Wednesday, December 18, 2013
12. ML in MapReduce:Why ?
• High data throughput: 100TB/hr using 500 mappers
Wednesday, December 18, 2013
13. ML in MapReduce:Why ?
• High data throughput: 100TB/hr using 500 mappers
• Framework provides fault tolerance
• Monitors and and re-starts tasks on other machines should
one of the machines fail
Wednesday, December 18, 2013
14. ML in MapReduce:Why ?
• High data throughput: 100TB/hr using 500 mappers
• Framework provides fault tolerance
• Monitors and and re-starts tasks on other machines should
one of the machines fail
• Excels in counting patterns over data records
Wednesday, December 18, 2013
15. ML in MapReduce:Why ?
• High data throughput: 100TB/hr using 500 mappers
• Framework provides fault tolerance
• Monitors and and re-starts tasks on other machines should
one of the machines fail
• Excels in counting patterns over data records
• Built on relatively cheap, commodity hardware
Wednesday, December 18, 2013
16. ML in MapReduce:Why ?
• High data throughput: 100TB/hr using 500 mappers
• Framework provides fault tolerance
• Monitors and and re-starts tasks on other machines should
one of the machines fail
• Excels in counting patterns over data records
• Built on relatively cheap, commodity hardware
• Large volumes of data already stored on Hadoop clusters
running MapReduce
Wednesday, December 18, 2013
17. ML in MapReduce:Why ?
• Learning can become limited by computation
time and not data volume
• With large enough data and number of machines
• Reduces the need to down-sample data
• More accurate parameter estimates compared to
learning on a single machine for the same amount of
time
Wednesday, December 18, 2013
18. Learning Models in
MapReduce
• Data parallel algorithms are most appropriate for
MapReduce implementations
• Not necessarily the most optimal implementation for a
specific algorithm
• Other specialized non-MapReduce implementations
exist for some algorithms, which may be better
• MR may not be the appropriate framework for exact
solutions of non data parallel/sequential algorithms
• Approximate solutions using MR may be good enough
Wednesday, December 18, 2013
19. Types of Learning in MapReduce
•Parallel training of multiple models
•Train either in Mappers or Reducers
•Ensemble training methods
•Train multiple models and combine them
•Distributed learning algorithms
•Learn using both Mappers and Reducers
Wednesday, December 18, 2013
20. ParallelTraining of
Multiple Models
• Train multiple models simultaneously using a learning algorithm that can
be learnt in memory
• Useful when individual models are trained using a subset, filtered or
modification of raw data
• Train 1 model in each reducer
• Map:
• Input:All data
• Filters subset of data relevant for each model training
• Output: <model_index, subset of data for training this model>
• Reduce
• Train model on data corresponding to that model_index
Wednesday, December 18, 2013
21. Distributed Learning
Algorithms
• Suitable for learning algorithms that are
• Compute-Intensive per data record
• One or few iterations for learning
• Do not transfer much data between iterations
• Typical algorithms
• Fit the Statistical query model (SQM)
• Divide and conquer
Wednesday, December 18, 2013
22. k-Means Clustering
• Choose k samples as initial cluster centroids
• In each MapReduce Iteration:
• Assign membership of each point to closest cluster
• Re-compute new cluster centroids using assigned members
• Control program to
• Initialize the centroids
• random, initial clustering on sample etc.
• Run the MapReduce iterations
• Determine stopping criterion
Wednesday, December 18, 2013
24. k-Means Clustering in MapReduce
• Map
• Input data points: x_i
• Input cluster centroids: c_i
• Assign each data point to closest cluster
• Output
Wednesday, December 18, 2013
25. k-Means Clustering in MapReduce
• Map
• Input data points: x_i
• Input cluster centroids: c_i
• Assign each data point to closest cluster
• Output
• Reduce
• Compute new centroids for each cluster
Wednesday, December 18, 2013
26. Complexity of k-Means
Clustering
• Each point is compared with each cluster
centroid
• Complexity = N*K*O(d) where O(d) is the
complexity of the distance metric
• Typical Euclidean distance is not a cheap
operation
• Can reduce complexity using an initial canopy
clustering to partition data cheaply
Wednesday, December 18, 2013
27. Apache Mahout
• Goal
• Create scalable, machine learning algorithms under the
Apache license
• Contains both:
• Hadoop implementations of algorithms that scale linearly
with data.
• Fast sequential (non MapReduce) algorithms
• Wiki:
• https://cwiki.apache.org/confluence/display/MAHOUT/
Mahout+Wiki
Wednesday, December 18, 2013
28. Algorithms in Mahout
• Classification:
• Logistic Regression, Naïve Bayes, Complementary Naïve
Bayes, Random Forests
• Clustering
• K-means, Fuzzy k-means, Canopy, Mean-shift clustering,
Dirichlet Process clustering, Latent Dirichlet allocation,
Spectral clustering
• Parallel FP growth
• Item based recommendations
• Stochastic Gradient Descent (sequential)
Wednesday, December 18, 2013
29. Challenges for ML with
MapReduce
•MapReduce is optimized for large batch data
processing
•Assumes data parallelism
•Ideal for shared-nothing computing
•Many learning algorithms are iterative
•Incur significant overheads per iteration
Wednesday, December 18, 2013
30. Challenges (contd.)
•Multiple scans of the same data
•Typically once per iteration: High I/O
overhead reading data into mappers per
iteration
•In some algorithms static data is read into
mappers in each iteration
•e.g. input data in k-means clustering.
Wednesday, December 18, 2013
31. Challenges (contd.)
•Need a separate controller outside the
framework to:
•Coordinate the multiple MapReduce jobs
for each iteration
•Perform some computations between
iterations and at the end
•Measure and implement stopping criterion
Wednesday, December 18, 2013
32. Challenges (contd.)
• Incur multiple task initialization overheads
• Setup and tear down mapper and reducer
tasks per iteration
• Transfer/shuffle static data between mapper
and reducer repeatedly
• Intermediate data is transferred through
index/data files on local disks of mappers
and pulled by reducers
Wednesday, December 18, 2013
33. Challenges (contd.)
•Blocking architecture
•Reducers cannot start till all map jobs
complete
•Availability of nodes in a shared environment
•Wait for mapper and reducer nodes to
become available in each iteration in a
shared computing cluster
Wednesday, December 18, 2013
35. Iterative Algorithms in MapReduce
Overhead per Iteration:
• Job setup
• Data Loading
• Disk I/O
PassResult
Wednesday, December 18, 2013
36. Enhancements to
MapReduce
• Many proposals to overcome these challenges
• All try to retain the core strengths of data
partitioning and fault tolerance of Hadoop to
various degrees
• Proposed enhancements and alternatives to
Hadoop
• Worker/Aggregator framework, HaLoop,
MapReduce Online, iMapReduce, Spark,Twister,
Hadoop ML, ...
Wednesday, December 18, 2013
39. HaLoop
• Programming model and architecture for iterations
• New APIs to express iterations in the framework
• Loop-aware task scheduling
• Physically co-locate tasks that use the same data
in different iterations
• Remember association between data and node
• Assign task to node that uses data cached in that
node
Wednesday, December 18, 2013
40. HaLoop (contd.)
• Caching for loop invariant data:
• Detect invariants in first iteration, cache on local
disk to reduce I/O and shuffling cost in subsequent
iterations
• Cache for Mapper inputs, Reducer Inputs, Reducer
outputs
• Caching to support fixpoint evaluation:
• Avoids the need for a dedicated MR step on each
iteration
Wednesday, December 18, 2013
41. Spark
• Open Source Cluster Computing model:
• Different from MapReduce, but retains some basic
character
• Optimized for:
• Iterative computations
• Applies to many learning algorithms
• Interactive data mining
• Load data once into multiple mappers and run
multiple queries
Wednesday, December 18, 2013
42. Spark (contd.)
• Programming model using working sets
• applications reuse intermediate results in multiple parallel
operations
• preserves the fault tolerance of MapReduce
• Supports
• Parallel loops over distributed datasets
• Loads data into memory for (re)use in multiple iterations
• Access to shared variables accessible from multiple machines
• Implemented in Scala,
• www.spark-project.org
Wednesday, December 18, 2013
52. Provides data-parallel implementations
of mathematical, statistical and machine-learning
methods
for structured and unstructured data.
In-Database Analytics
Wednesday, December 18, 2013
55. k-Means Usage
SELECT * FROM madlib.kmeanspp (
‘customers’, -- name of the input table
‘features’, -- name of the feature array column
2 -- k : number of clusters
);
centroids | objective_fn | frac_reassigned | …
------------------------------------------------------------------------+------------------+-----------------+ …
{{68.01668579784,48.9667382972952},{28.1452167573446,84.5992507653263}} | 586729.010675982 | 0.001 | …
Wednesday, December 18, 2013
57. Pivotal R
•Interface is R client
•Execution is in database
•Parallelism handled by PivotalR
•Supports a portion of R
R> x = db.data.frame(“t1”)
R> l = madlib.lm(interlocks ~ assets + nation, data = t)
Wednesday, December 18, 2013
64. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
Wrapper of objects in database
x = db.data.frame("table")
Wednesday, December 18, 2013
65. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
Wrapper of objects in database
x = db.data.frame("table")
Resides in R only
x[,1:2],
merge(x, y, by="column"),
etc.
Wednesday, December 18, 2013
66. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
Wrapper of objects in database
x = db.data.frame("table")
Resides in R only
x[,1:2],
merge(x, y, by="column"),
etc.
Wednesday, December 18, 2013
67. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
Most operations
Wrapper of objects in database
x = db.data.frame("table")
Resides in R only
x[,1:2],
merge(x, y, by="column"),
etc.
Wednesday, December 18, 2013
68. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
Most operations
Wrapper of objects in database
x = db.data.frame("table")
Resides in R only
x[,1:2],
merge(x, y, by="column"),
etc.
Wednesday, December 18, 2013
69. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
as.db.data.frame(...)
Most operations
Wrapper of objects in database
x = db.data.frame("table")
Resides in R only
x[,1:2],
merge(x, y, by="column"),
etc.
Wednesday, December 18, 2013
70. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
as.db.data.frame(...)
Most operations
Wrapper of objects in database
x = db.data.frame("table")
Resides in R only
x[,1:2],
merge(x, y, by="column"),
etc.
MADlib
wrapper
functions
Wednesday, December 18, 2013
71. Pivotal Confidential–Internal Use Only 49
db.obj
db.data.frame db.Rquery
db.table db.view
as.db.data.frame(...)
Most operations
Wrapper of objects in database
x = db.data.frame("table")
Resides in R only
x[,1:2],
merge(x, y, by="column"),
etc.
MADlib
wrapper
functions
preview
Wednesday, December 18, 2013
72. In-Database Execution
•All data stays in DB: R objects merely point
to DB objects
•All model estimation and heavy lifting done
in DB by MADlib
•R→ SQL translation done in the R client
•Only strings of SQL and model output
transferred across ODBC/DBI
Wednesday, December 18, 2013
73. Beyond MapReduce
•Apache Giraph - BSP & Graph Processing
•Storm onYarn - Streaming Computation
•HOYA - HBase onYarn
•Hamster - MPI on Hadoop
•More to come ...
Wednesday, December 18, 2013
74. Hamster
• Hadoop and MPI on the same
cluster
• OpenMPI Runtime on Hadoop
YARN
• Hadoop Provides: Resource
Scheduling, Process monitoring,
Distributed File System
• Open MPI Provides: Process
launching, Communication, I/O
forwarding
Wednesday, December 18, 2013
79. About GraphLab
•Graph-based, High-Performance distributed
computation framework
•Started by Prof. Carlos Guestrin in CMU in
2009
•Recently founded Graphlab Inc to
commercialize Graphlab.org
Wednesday, December 18, 2013
81. Only Graphs are not
Enough
• Full Data processing workflow required ETL/
Postprocessing,Visualization, Data Wrangling, Serving
• MapReduce excels at data wrangling
• OLTP/NoSQL Row-Based stores excel at Serving
• GraphLab should co-exist with other Hadoop
frameworks
Wednesday, December 18, 2013