Two Dimensional Parallelism Using Distributed Tensors at PyTorch Conference 2022

PyTorch · Beginner ·🧠 Large Language Models ·3y ago

Key Takeaways

The video introduces 2-dimensional parallelism using distributed tensors in PyTorch, combining data parallelism and tensor parallelism for efficient model training. It covers the concepts of distributed tensors, tensor parallelism, and 2D parallelism, with a focus on the vision Transformer model.

Full Transcript

hi my name is Juan Chao Liang and I'm from the pi torch distributed team at meta today we're going to print down our recent work about two-dimensional parallelism using distributed tensor we will briefly go through the background and motivation then introduce the distributed tensor concept and the tensor parallelism that builds on top of distributed tensor then we will go through the 2D parallelism that we build for the vision Transformer model let's briefly talk about the background and motivation currently the research Community trained large-scale models mainly in three ways data parallel within layer model parallel and pipeline parallel in pytorch for data parallel we are offering distributed data parallel and fully shorted data parallel to three large-scale models for pipeline parallel we are offering PP or pipeline parallel solution which is currently in the Prototype stage so what should be a general purpose within layer model parallel look like our answer to this is distributed tensor and the tensor parallelism that's built on top of it so what is distributed tensor distributed tensor also known as detensor is a common abstraction we proposed to build the bridge between different parallelism strategies it offers fundamental tensor level Primitives to describe data distribution and computation across holes details are consists of two important Concepts the first concept is device match an abstraction that describes the topology of devices within a cluster for example we could construct the U.S mesh that describes Two Hosts each with two gpus the second concept is the details replacement types there are three placement types chart where we Shard on Twitter Dimension across devices replicate where we replicate tensor across devices partial where we partition values across devices with these two concepts we can distribute the tensor in different ways for example we can chart a tensor with each piece on separate devices we can replicate a tensor across all devices or we can even shorter tensor on set of devices then replicate this shortly tensor on another side of devices even the detensor concepts now let's look at the details API data sir is fundamentally a torture tensor subclass and they really look like a normal tensor except that it's a distributed across devices with the device mesh we can create a detensor with your white starting and column wise charting and we can convert from our two local torture tensor on each rank we can read chart or redistribute the detailsor from one type of sharding to another we also offer a high level API to Shard and Scatter an existing tensor from one rank to all other ranks with the power of detailser we can build tensor parallelism apis on top of it to express model parallelism next I will hand it off to my teammate jinji to talk about tensor parallelism and 2D parallel hi I'm Jin jio Wang and I will talk about tensor parallelism and its user API first of all let's see how tensor parallelism works there are three parallelism Styles we support column wise row wise and pairwise parallelisms the first two are pretty intuitive as we just partition one dimension of a given tensor the third one pairwise parallelism is to combine the first two and Achieve calculation efficiency let's take a look at the diagram below as you can see here after multiplying with the First Column wise partition linear we don't need to do any Collective and leave the activation partitioned and this partition Matrix can then do another multiplication with a row wise partition linear directly to get the final result we just need to do one or reduce here when it comes to API users don't need to change their module or code they just need to call this high level API parallelize module with parallelized style specified per module to get the model partitioned we will handle all the hassles during model training and inference next I want to talk about 2D parallelism where we combine data parallel and tensor parallel together the way it works is that we first partition each model parameter across all gpus on each host and then the fully sharded data parallel which is also called fsdp will restart the local tensor of tensor parallelism this way we can get the benefits of both tensor parallel and data parallel the user API is also pretty simple that user just needs to create a 2d device mesh before calling the parallelized module API and user can then wrap the model with fsdp last but not least I want to talk about What preliminary result we have got so far from the experiment on the vit model we see 2.6 times faster in training a 60 billion vit model and enable the training of a 120 billion vit model on 64 gpus here we can do some backup envelope calculations if we simplify each layer of Transformer encoder as one input tensor and four linears we can calculate the peak memory ratio for 2D parallelism and fsdp only scenarios the result shows that when the batch size is 1024 fsdp is using 1.3 times more Peak memory than 2D parallelism and upon measurement this ratio is 1.1 meanwhile if we reduce the batch size to 512 this ratio increases to 2.4 the result shows that when the batch size is 1024 fsdp is using 1.3 times more Peak memory than 2D parallelism and the Palm measurement this ratio is 1.1 meanwhile if we reduce the batch size to 512 the ratio increases to 2.4 this calculation shows that when the number of gpus is limited and if we have to use small batch size for really large model 2D parallelism can indeed have some advantages

Original Description

Watch Meta AI's Wanchao Liang present his team's poster "Two Dimensional Parallelism Using Distributed Tensors" at PyTorch Conference 2022. This talk will introduce 2-dimensional parallelism with PyTorch (Data Parallelism + Tensor Parallelism) using Distributed Tensor, a fundamental distributed primitive offered by PyTorch Distributed that empowers Tensor Parallelism. We have proven that using FSDP + Tensor Parallelism together could enable us to train large models like Transformer, and increase training performance. We offer end to end training techniques that enable you to train models in 2-D parallelism fashion, and checkpoint save/load models in a distributed manner. 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

This video teaches how to use distributed tensors and tensor parallelism to achieve 2D parallelism in PyTorch, enabling faster and more efficient model training. It covers the concepts, APIs, and preliminary results of this approach.

Key Takeaways
  1. Create a device mesh to describe the topology of devices
  2. Use distributed tensors to shard and replicate data
  3. Implement tensor parallelism using column-wise, row-wise, or pairwise parallelism
  4. Combine data parallelism and tensor parallelism for 2D parallelism
  5. Use the parallelize module API to partition the model
  6. Wrap the model with fully sharded data parallel (FSDP)
💡 2D parallelism can achieve faster training times and enable the training of larger models, especially when the number of GPUs is limited and small batch sizes are used.

Related Reads

📰
The AI Jackpot: Why Prompting Feels Like Gambling
Learn why prompting AI models can feel like gambling and how to improve your odds of getting useful results
Dev.to · Brendon O'Neill
📰
Bonsai-27B & Ternary-Bonsai-27B - Updates (on PRs)
Learn about updates to Bonsai-27B and Ternary-Bonsai-27B models, including upstream status and runtime support
Reddit r/LocalLLaMA
📰
ggml-zendnn : add Q8_0 quantization support by z-sachin · Pull Request #23414 · ggml-org/llama.cpp
Learn about the addition of Q8_0 quantization support in ggml-zendnn for LLaMA.cpp and how it can improve model performance
Reddit r/LocalLLaMA
📰
Top AI Papers on Hugging Face - 2026-07-15
Explore the top AI papers on Hugging Face, focusing on agent longevity, robotics, and efficient model training methods
Dev.to AI
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →