PyTorch 2.0: TorchDynamo

PyTorch · Beginner ·🧬 Deep Learning ·3y ago

Key Takeaways

PyTorch 2.0 introduces TorchDynamo, a graph capture technology that enables efficient compilation of PyTorch models, and discusses its importance for PyTorch 2.0's compilation story.

Full Transcript

do this [Music] I was waiting for all this talk for him to utter the word pie torch 2.0 and finally he said it welcome to pytorch conference this is my first one um I support the pi torch compiler team so as a compiler person PT 2.0 to a large extent is really a compeller story and you might wonder why does it take so long for us to actually fully Embrace compiler technology into the core of Pi torch and the reason is because what makes pie torch be loved by researchers is flexibility dynamism expressiveness is exactly what makes it very hard to compile so it took us five years of developing various Solutions compiler solutions to get to where we are and I want to call the inflection point of our journey searching for the right compiler solution polish Dynamo which is what I'm going to talk about so it starts with asking this question what is one thing that we could change first in the compiler stack that will fundamentally change the efficiency of Pi torch it's not a new compiler optimization it's not even a new compiler backend actually the first the key first move lies in the top part of the compiler which is the graph capture so we all know that graph mode execution can be a lot more efficient than executing Ops one at a time especially if you are a machine learning accelerator designer or if you are a production engineer unfortunately um for eager first machine learning framework like Pi torch it's actually non-trivial to get graphs reliably so that's why we care about graph capture because it's simple if you don't have reliable graph capture you don't have a reliable compiler coverage so let me introduce torch Dynamo our first out of box graph capture here's one example of a toy pytorch program and here is this one-liner change Torchlight compile and this in this example we actually allow you to specify a custom backend and in this particular example this my compiler basically takes the graph that's captured by Dynamo and do something about it which basically printed out and return a python callable so if you execute this program you'll be surprised you see actually three graphs being printed out because in this example we actually put a Twist of a data dependent control flow so this graph break actually is the feature it's a fundamental design feature of torch Dynamo that makes it out of box in sound so let me double click on what makes torch Dynamo sound and outer box number one is partial graph capture so this is our ability to skip anything unwanted and then fall back to eager and with partial graph capture we save the programmers to have to shoehorsing their models into what the back-end compiler want instead we'll just seem to be translating out in and out of between eager and the graph mode and then there is the guarded graph generation basically we want to make sure whatever we're capturing at capture time is still valid when we're replaying this graph and finally if we did find a mismatch on the guard we have the ability to just in time recapture them so basically partial guarded graph capture with just in-time recapturing is what set Dynamo apart from all our previous graph capture Technologies and by the way there's this thing called aot autograph that captures the backward part of the graph and that makes it working for training so I want to show you some numbers which assume is already highlighted in his keynote that would back the claims we made so far you have seen the 7K plus model so this demonstrates that it indeed works out of box and right now we have more than 20 experimental backends for inference that's integrated with torch Dynamo and we have more than one backhand that's integrated with torchamel for training and the number is smaller on trading side now because of Dynamo but because they're just less number of training back-ends available and we're working actively with vendors to migrate into this new stack and finally you've seen this 30 number what does it say actually it's not only talking about the performance it also demonstrates that partial graph actually works so by capturing crafts and allowing graph breaks we not only did not diminish the capability of the back end optimizing compiler we actually amplify it by bringing more models or more regions of the models into the compiler world so Dynamo is great but if you are an experienced pytorch compiler user you would ask this question so which technology do I use as of today we actually recommend using torture animal for any scenarios that can be deployed with eager so that includes most of the training scenario and some of the inference scenarios and for all the other scenarios which we call the exports past scenario our existing solution still works but in the future actually not so far future we actually want to have a con organic consolidation uh of front-end technology around torch Dynamo um it's it has always been our vision to have a unifying front end and have a vibrant thriving back-end ecosystem and the speed of our consolidation actually depends on two things number one how fast do we deliver the pytorch 2.0 export story and number two is how fast the vendors can migrate into this new stack so we look forward to that new experience of a Consolidated front end yeah so that's Dynamo and I want to bring you back to the question we asked in the beginning of the talk what is that one thing right so as a compiler optimizing compiler person for two decades and never imagine myself talk about a computer friend end but the front end part of the compiler graph capture really matters because once we're able to bring most of the pytorch models simply into the graph world the era of compiler accelerated pytorch really arrives so if you are excited about this Vision there are more Nuance aspects of the compiler story that you are going to hear today and in the following months and if you're a ml practitioner I would encourage you to try out pt2 on your workload and if you're a vendor I encourage you to talk to us to explore migrating into this new stack and finally we have some talk series that would dive deeper into the technology in in the pytorch 2.0 stack so with that I'm gonna pass the torch to Jason Enzo [Applause] thank you

Original Description

Peng Wu speaks at PyTorch Conference about TorchDynamo, the first out-of-the-box Graph Capture for PyTorch and why it matters. This short talk shares highlights on TorchDynamo, PT 2.0's new graph capture technology. It answers questions like: 1) Why is graph capture so important for PT2's compiler stack? 2) How is TorchDynamo better than previous PyTorch graph captures? 3) What is the current state of TorchDynamo? 3) What are our short- and long-term recommendations for vendors/users? Visit our website: https://pytorch.org/ Read our blog: https://pytorch.org/blog/ Follow us on Twitter: https://twitter.com/PyTorch Follow us on LinkedIn: https://www.linkedin.com/company/pyto... Follow us on Facebook: https://www.facebook.com/pytorch #PyTorch #ArtificialIntelligence #MachineLearning
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from PyTorch · PyTorch · 0 of 60

← Previous Next →
1 What is PyTorch?
What is PyTorch?
PyTorch
2 PyTorch Tutorial: A Quick Preview
PyTorch Tutorial: A Quick Preview
PyTorch
3 PyTorch Summer Hackathon 2019
PyTorch Summer Hackathon 2019
PyTorch
4 Tips and Tricks on Hacking with PyTorch: A Quick Tutorial by Brad Heintz
Tips and Tricks on Hacking with PyTorch: A Quick Tutorial by Brad Heintz
PyTorch
5 PyTorch 1.2 and PyTorch Hub: A Quick Introduction by Soumith Chintala and Ailing Zhang
PyTorch 1.2 and PyTorch Hub: A Quick Introduction by Soumith Chintala and Ailing Zhang
PyTorch
6 Torchtext 0.4 with Supervised Learning Datasets: A Quick Introduction by George Zhang
Torchtext 0.4 with Supervised Learning Datasets: A Quick Introduction by George Zhang
PyTorch
7 Torchaudio 0.3 with Kaldi Compatibility, New Transforms: A Quick Introduction by Jason Lian
Torchaudio 0.3 with Kaldi Compatibility, New Transforms: A Quick Introduction by Jason Lian
PyTorch
8 Torchvision 0.4 with Support for Video: A Quick Introduction by Francisco Massa
Torchvision 0.4 with Support for Video: A Quick Introduction by Francisco Massa
PyTorch
9 Introduction to Machine Learning for Developers at F8 2019
Introduction to Machine Learning for Developers at F8 2019
PyTorch
10 Powered by PyTorch at F8 2019
Powered by PyTorch at F8 2019
PyTorch
11 Developing and Scaling AI Experiences at Facebook with PyTorch at F8 2019
Developing and Scaling AI Experiences at Facebook with PyTorch at F8 2019
PyTorch
12 New Approaches to Image and Video Reconstruction Using Deep Learning at Facebook at F8 2019
New Approaches to Image and Video Reconstruction Using Deep Learning at Facebook at F8 2019
PyTorch
13 PyTorch Developer Conference 2018: Recap
PyTorch Developer Conference 2018: Recap
PyTorch
14 PyTorch Developer Conference 2018: Keynote & Deep Dive
PyTorch Developer Conference 2018: Keynote & Deep Dive
PyTorch
15 PyTorch Developer Conference 2018: Production & Research Sessions
PyTorch Developer Conference 2018: Production & Research Sessions
PyTorch
16 PyTorch Developer Conference 2018: Cloud & Academia Sessions
PyTorch Developer Conference 2018: Cloud & Academia Sessions
PyTorch
17 PyTorch Developer Conference 2018: Enterprise, Education, & Future of AI Panel
PyTorch Developer Conference 2018: Enterprise, Education, & Future of AI Panel
PyTorch
18 PyTorch Developer Conference 2019 | Full Livestream
PyTorch Developer Conference 2019 | Full Livestream
PyTorch
19 PyTorch Developer Conference 2019: Recap
PyTorch Developer Conference 2019: Recap
PyTorch
20 PyTorch Developer Conference Keynote - Mike Schroepfer
PyTorch Developer Conference Keynote - Mike Schroepfer
PyTorch
21 What’s new in PyTorch 1.3 - Lin Qiao
What’s new in PyTorch 1.3 - Lin Qiao
PyTorch
22 PyTorch Front-End Features: Named Tensors and Type Promotion - Gregory Chanan
PyTorch Front-End Features: Named Tensors and Type Promotion - Gregory Chanan
PyTorch
23 Research to Production: PyTorch JIT/TorchScript Updates - Michael Suo
Research to Production: PyTorch JIT/TorchScript Updates - Michael Suo
PyTorch
24 Quantization - Dmytro Dzhulgakov
Quantization - Dmytro Dzhulgakov
PyTorch
25 PyTorch ONNX Export Support - Lara Haidar, Microsoft
PyTorch ONNX Export Support - Lara Haidar, Microsoft
PyTorch
26 Apex -  Michael Carilli, NVIDIA
Apex - Michael Carilli, NVIDIA
PyTorch
27 Dataloader Design for PyTorch - Tongzhou Wang, MIT
Dataloader Design for PyTorch - Tongzhou Wang, MIT
PyTorch
28 Linear Algebra in PyTorch - Vishwak Srinivasan, CMU
Linear Algebra in PyTorch - Vishwak Srinivasan, CMU
PyTorch
29 PyTorch Mobile - David Reiss
PyTorch Mobile - David Reiss
PyTorch
30 Model Interpretability with Captum - Narine Kokhilkyan
Model Interpretability with Captum - Narine Kokhilkyan
PyTorch
31 Detectron2 - Next Gen Object Detection Library - Yuxin Wu
Detectron2 - Next Gen Object Detection Library - Yuxin Wu
PyTorch
32 Speech Extensions to Fairseq - Dmytro Okhonko
Speech Extensions to Fairseq - Dmytro Okhonko
PyTorch
33 PyTorch on Google Cloud TPUs - Google, Salesforce, Facebook
PyTorch on Google Cloud TPUs - Google, Salesforce, Facebook
PyTorch
34 PyTorch Summer Hackathon Winners - Joe Spisak, Sebastien Arnold, Tristan Deleu
PyTorch Summer Hackathon Winners - Joe Spisak, Sebastien Arnold, Tristan Deleu
PyTorch
35 PyTorch in Robotics - Yisong Yue, Caltech
PyTorch in Robotics - Yisong Yue, Caltech
PyTorch
36 StanfordNLP - Yuhao Zhang, Stanford
StanfordNLP - Yuhao Zhang, Stanford
PyTorch
37 Sotabench for Reproducible Research - Robert Stojnic, Papers with Code
Sotabench for Reproducible Research - Robert Stojnic, Papers with Code
PyTorch
38 Collaborative Natural Language Inference - Sasha Rush, Cornell
Collaborative Natural Language Inference - Sasha Rush, Cornell
PyTorch
39 Privacy Preserving AI - Andrew Trask, OpenMined
Privacy Preserving AI - Andrew Trask, OpenMined
PyTorch
40 CrypTen - Laurens van der Maaten
CrypTen - Laurens van der Maaten
PyTorch
41 PyTorch at Uber - Sidney Zhang, Uber
PyTorch at Uber - Sidney Zhang, Uber
PyTorch
42 PyTorch at Tesla - Andrej Karpathy, Tesla
PyTorch at Tesla - Andrej Karpathy, Tesla
PyTorch
43 PyTorch at Microsoft - Saurabh Tiwary, Microsoft
PyTorch at Microsoft - Saurabh Tiwary, Microsoft
PyTorch
44 PyTorch at Dolby Labs - Vivek Kumar, Dolby Labs
PyTorch at Dolby Labs - Vivek Kumar, Dolby Labs
PyTorch
45 PyTorch Developer Conference 2019 - Panel Discussion
PyTorch Developer Conference 2019 - Panel Discussion
PyTorch
46 Using deep learning and PyTorch to power next gen aircraft at Caltech
Using deep learning and PyTorch to power next gen aircraft at Caltech
PyTorch
47 Named Tensors, Model Quantization, and the Latest PyTorch Features - Part 1
Named Tensors, Model Quantization, and the Latest PyTorch Features - Part 1
PyTorch
48 TorchScript and PyTorch JIT | Deep Dive
TorchScript and PyTorch JIT | Deep Dive
PyTorch
49 Announcing the PyTorch Global Summer Hackathon 2020
Announcing the PyTorch Global Summer Hackathon 2020
PyTorch
50 Opening Up the Black Box: Model Understanding with Captum and PyTorch
Opening Up the Black Box: Model Understanding with Captum and PyTorch
PyTorch
51 PyTorch Mobile Runtime for Android
PyTorch Mobile Runtime for Android
PyTorch
52 Torchvision in 5 minutes
Torchvision in 5 minutes
PyTorch
53 3D Deep Learning with PyTorch3D
3D Deep Learning with PyTorch3D
PyTorch
54 What is Torchtext?
What is Torchtext?
PyTorch
55 TorchAudio: A Quick Intro
TorchAudio: A Quick Intro
PyTorch
56 PyTorch Mobile Runtime for iOS
PyTorch Mobile Runtime for iOS
PyTorch
57 PySlowFast: Deep learning with Video
PySlowFast: Deep learning with Video
PyTorch
58 PyTorch Pruning | How it's Made by Michela Paganini
PyTorch Pruning | How it's Made by Michela Paganini
PyTorch
59 Measuring Fairness in Machine Learning Systems
Measuring Fairness in Machine Learning Systems
PyTorch
60 PyTorch for Hackathons
PyTorch for Hackathons
PyTorch

TorchDynamo is a graph capture technology in PyTorch 2.0 that enables efficient compilation of PyTorch models. It allows for partial graph capture, guarded graph generation, and just-in-time recapture, making it a fundamental component of PyTorch 2.0's compilation story.

Key Takeaways
  1. Understand the importance of graph capture in PyTorch 2.0
  2. Learn how to use TorchDynamo for graph capture
  3. Optimize PyTorch models with TorchDynamo
  4. Improve model performance with graph capture
💡 Graph capture is a crucial component of PyTorch 2.0's compilation story, and TorchDynamo provides a robust and efficient way to capture graphs in PyTorch models.

Related Reads

Up next
RNNs Explained in 60 Seconds #ai #coding #machinelearning
Ascent
Watch →