INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The...

23
INFRASTRUCTURE

Transcript of INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The...

Page 1: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

INFRASTRUCTURE

Page 2: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

AI Infrastructure

Distributed Training @ Facebook

Mohamed Fawzy, Kutta Srinivasan

Page 3: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• ML @ Facebook scale

• The role of Distributed Training

• Challenges & Solutions Agenda

Page 4: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

ML @ FB Scale

(Mohamed’s slides go in this section)

Page 5: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

Why Distributed Training?

Page 6: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Complex models train on multi-PB datasets

• Would take years to run on single machine

• Data-parallelism to the rescue

Improve ML Productivity

Page 7: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Sparse architectures for ranking, personalization, language

• Range from 100s of GB → TBs per model

• Both model- and data-parallelism required

Support Huge Scale

Page 8: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

Model Model Model

Batch 3

Batch 1

Batch 2

Sync

Data Parallelism

Sub model 1

Sub model 2

Sub model 3

Batch

Model Parallelism

Sub model 1

Sub model 2

Sub model 3

Batch 2

Sub model 1

Sub model 2

Sub model 3

Batch 3

+ Data Parallelism

Page 9: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

Distributed Training is HARD

Page 10: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Gang scheduling means resources are required all-or-

nothing

• Failed node → failed job

Inherently less reliable

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 1 2 3 4 5 6 7

Gang Job Reliablity

N=1 N=10 N=20 N=100

Page 11: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• HPC workloads sensitive to hardware types, generations

• Scheduling more complex than just {x GB RAM, y CPU} per task

• Multiple gen GPUs, CPUs, ASICs

Heterogeneous Hardware

Page 12: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Unlike data pipelines, majority of ML jobs are ad hoc

• Long running jobs complicate demand prediction & control

• Cost & efficiency

• ROI for jobs hard to estimate

• Sub-linear scaling + huge scale = easy to waste resources

Expensive & Experimental

Page 13: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

Affordable Productivity is the Goal

Page 14: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

A Layered Solution

PyTorch Elastic Distributed Training

ML-Aware Cluster Scheduling

Elastic Compute (Spot Instances)

Page 15: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Fault tolerance for failed nodes

• For transient errors, re-sync workers and keep going

• Jobs don’t need baby-sitting

• Auto-scaling

• Start fewer nodes under resource contention, adjust hyper

params[1][2]

• Eliminate bottlenecks, improve utilization

PyTorch Elastic Distributed Training

[1] https://arxiv.org/abs/1706.02677 [2] https://openreview.net/pdf?id=B1Yy1BxCZ

Page 16: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

while not finished:

# discover peers, use rank and size to update model hyperparams

rank, size = rendezvous(min_nodes, max_nodes)

sync_model(rank, size) # most tenured worker broadcasts state

while not finished:

try:

train_step() # forward/backward pass + allreduce

except TransientError:

break # allreduce will raise if any worker fails

if detect_new_workers():

break # allow job to scale up if new workers arrive

Elastic Training Pseudocode

Page 17: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Maximize throughput & utilization

• Subject to quota & priority constraints

• Allow users to borrow unused resources; evict to reclaim

• Ongoing work

• Gang-awareness for draining, preemption

• Time-slicing jobs for improved fairness

• Globally federated scheduling for efficiency & DR

ML-Aware Cluster Scheduling

Page 18: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• FB uses power-efficient servers w/autoscaling[3]

• Significant capacity available off-peak

• Idle machines for growth & DR buffers

• Think “Spot Instances”

Elastic Compute

[3] https://engineering.fb.com/data-center-engineering/tupperware/

Page 19: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...
Page 20: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

Sources of Elastic Capacity [OPTIONAL]

Buffer capacity

Off-peak idle capacity

Actively used capacity

ML goes here!

Time →

Page 21: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Machines reclaimed at anytime by donor service

• End-to-end job latency higher on off-peak

• Primarily useful for CPU workloads

Elastic Compute Challenges

Page 22: INFRASTRUCTURE · 2019-10-30 · Mohamed Fawzy, Kutta Srinivasan • ML @ Facebook scale • The role of Distributed Training • Challenges & Solutions Agenda . ML @ FB Scale ...

• Distributed Training key to pushing state-of-the-art ML

modeling

• “Affordable Productivity” a key focus of AI Infrastructure @

FB

• Investments required across entire stack

Conclusion