Distributed Training with PyTorch: complete tutorial with cloud infrastructure and code

Umar Jamil December 19, 2023
Video Thumbnail

About

No channel description available.

Video Description

A complete tutorial on how to train a model on multiple GPUs or multiple servers. I first describe the difference between Data Parallelism and Model Parallelism. Later, I explain the concept of gradient accumulation (including all the maths behind it). Then, we get to the practical tutorial: first we create a cluster on Paperspace with two servers (each having two GPUs) and then training a model in a distributed manner on the cluster. We will explore collective communication primitives: Broadcast, Reduce and All-Reduce and the algorithm behind them. I also provide a template on how to integrate DistributedDataParallel in your existing training loop. In the last part of the video we review advanced topics, like bucketing and computation-communication overlap during backpropagation. Code: https://github.com/hkproj/pytorch-transformer-distributed PDF slides: https://github.com/hkproj/pytorch-transformer-distributed/blob/main/notes/Slides.pdf Chapters 00:00:00 - Introduction 00:02:43 - What is distributed training? 00:04:44 - Data Parallelism vs Model Parallelism 00:06:25 - Gradient accumulation 00:19:38 - Distributed Data Parallel 00:26:24 - Collective Communication Primitives 00:28:39 - Broadcast operator 00:30:28 - Reduce operator 00:32:39 - All-Reduce 00:33:20 - Failover 00:36:14 - Creating the cluster (Paperspace) 00:49:00 - Distributed Training with TorchRun 00:54:57 - LOCAL RANK vs GLOBAL RANK 00:56:05 - Code walkthrough 01:06:47 - No_Sync context 01:08:48 - Computation-Communication overlap 01:10:50 - Bucketing 01:12:11 - Conclusion

You May Also Like

Accelerate Your PyTorch Learning

AI-recommended products based on this video

Loading...
Seasonic Focus V4 GX-1000 (ATX3) - 1000W - 80+ Gold - ATX 3.0 & PCIe 5.1 Ready -Full-Modular -ATX Form Factor -Premium Japanese Capacitor -10 Year Warranty -Nvidia RTX 30/40 Super & AMD GPU Compatible

Seasonic Focus V4 GX-1000 (ATX3) - 1000W - 80+ Gold - ATX 3.0 & PCIe 5.1 Ready -Full-Modular -ATX Form Factor -Premium Japanese Capacitor -10 Year Warranty -Nvidia RTX 30/40 Super & AMD GPU Compatible

(22)
$423.35
FREE delivery Oct 8 - 10
Loading...
EZDIY-FAB PCIe 5.0 X16 Riser Cable,128GB/s Bandwidth, for RTX 50/40 & RX 9000/7000 GPUs, PCIe Extension Card, Backward Compatible with PCIe 4.0/3.0,Vertical GPU Mount,Right Angle-30cm,Black

EZDIY-FAB PCIe 5.0 X16 Riser Cable,128GB/s Bandwidth, for RTX 50/40 & RX 9000/7000 GPUs, PCIe Extension Card, Backward Compatible with PCIe 4.0/3.0,Vertical GPU Mount,Right Angle-30cm,Black

(26)
$82.39
FREE delivery Mon, Feb 16
Loading...
Gaming RTX 2060 6GB Graphics Card, GDDR6 192bit PCIE 3.0X16 Graphics Card Gaming Video Graphics Card with GPU Dual Freeze Fans for Computer Desktop

Gaming RTX 2060 6GB Graphics Card, GDDR6 192bit PCIE 3.0X16 Graphics Card Gaming Video Graphics Card with GPU Dual Freeze Fans for Computer Desktop

(0)
$358.68
FREE delivery Mar 19 - 31
Loading...
RTX 3060 Ti Graphics Card 8GB GDDR6, 256-Bit, 1410MHz Base, 1665MHz Boost, PCIe 4.0 16X, Dual Fan Cooling, 4K UHD, 1x HDMI, 3X DisplayPort, Gaming GPU

RTX 3060 Ti Graphics Card 8GB GDDR6, 256-Bit, 1410MHz Base, 1665MHz Boost, PCIe 4.0 16X, Dual Fan Cooling, 4K UHD, 1x HDMI, 3X DisplayPort, Gaming GPU

(0)
$621.22
FREE delivery Feb 27 - Mar 11
Loading...
Asus Prime Radeon™ RX 9060 XT 16GB GDDR6 OC Edition Graphics Card (PCIe 5.0, HDMI/DP 2.1, 2.5-Slot Design, axial-tech Fans, Dual Ball Fan Bearings, Dual BIOS, ASUS GPU Guard)

Asus Prime Radeon™ RX 9060 XT 16GB GDDR6 OC Edition Graphics Card (PCIe 5.0, HDMI/DP 2.1, 2.5-Slot Design, axial-tech Fans, Dual Ball Fan Bearings, Dual BIOS, ASUS GPU Guard)

(377)
$549.99
FREE delivery Tue, Jan 6
300+ bought in past month
Loading...
Asus Zenbook Duo (2024), Dual 14” FHD OLED Touch Laptop, Intel Evo Certified, Intel Core Ultra 7 155H CPU, Intel Arc Graphics, 16GB Memory, 1TB SSD, Windows 11 Home, UX8406MA-DS71T-CA

Asus Zenbook Duo (2024), Dual 14” FHD OLED Touch Laptop, Intel Evo Certified, Intel Core Ultra 7 155H CPU, Intel Arc Graphics, 16GB Memory, 1TB SSD, Windows 11 Home, UX8406MA-DS71T-CA

(29)
$1,639.97$1,074.31
FREE delivery Sat, Jan 3Only 2 left in stock.
Loading...
UCANUUP 130W Tip 4.5mm Compatible with Dell XPS 15 7590 9530 9550 9560 9570 9575 Inspiron 7348 Precision M3800 5510 5520 5530 06TTY6 AC Adapter Power Replacement Supply Cord

UCANUUP 130W Tip 4.5mm Compatible with Dell XPS 15 7590 9530 9550 9560 9570 9575 Inspiron 7348 Precision M3800 5510 5520 5530 06TTY6 AC Adapter Power Replacement Supply Cord

(61)
$35.99
FREE delivery Sun, Aug 24
Loading...
tomtoc 360° Protective Laptop Sleeve for 15-inch MacBook Air M4/A3241 2025, M3/A3114 2024, M2/A2941 2023, 15-inch MacBook Pro A1990 A1707, Dell XPS 15 Plus Laptop, Water-Resistant Computer Case Bag Global Recycled Standard

tomtoc 360° Protective Laptop Sleeve for 15-inch MacBook Air M4/A3241 2025, M3/A3114 2024, M2/A2941 2023, 15-inch MacBook Pro A1990 A1707, Dell XPS 15 Plus Laptop, Water-Resistant Computer Case Bag Global Recycled Standard

(12,968)
$39.55
FREE delivery Tue, Jun 17
Loading...
MOSISO 360 Protective Laptop Bag 15 inch, 15 inch Computer Shoulder Bag Compatible with MacBook Air 15 M4 M3 M2 2025-2023, Dell XPS 15, Side Open Messenger Case &4 Zipper Pockets&Handle, Black Global Recycled Standard

MOSISO 360 Protective Laptop Bag 15 inch, 15 inch Computer Shoulder Bag Compatible with MacBook Air 15 M4 M3 M2 2025-2023, Dell XPS 15, Side Open Messenger Case &4 Zipper Pockets&Handle, Black Global Recycled Standard

(3,362)
$39.32
FREE delivery Tue, Jun 17
Loading...
UGREEN 130W Car Charger USB C Fast Charger PD3.0 QC4.0 PPS Fast Charging Car Adapter with 100W USB C Cable Compatible with Dell XPS, MacBook, iPhone 16 15 14 Pro Max, Galaxy S25 S24 Ultra, iPad Pro

UGREEN 130W Car Charger USB C Fast Charger PD3.0 QC4.0 PPS Fast Charging Car Adapter with 100W USB C Cable Compatible with Dell XPS, MacBook, iPhone 16 15 14 Pro Max, Galaxy S25 S24 Ultra, iPad Pro

(4,725)
$31.99
500+ bought in past month
Loading...
TP-Link Tapo 2K Pan/Tilt Indoor Security WiFi Camera, Baby & Pet Camera w/ 360° Motion Tracking, 2-Way Audio, Night Vision, Cloud & Local Storage (Up to 256 GB), Works w/ Alexa & Google (Tapo C210)
Amazon's Choice

TP-Link Tapo 2K Pan/Tilt Indoor Security WiFi Camera, Baby & Pet Camera w/ 360° Motion Tracking, 2-Way Audio, Night Vision, Cloud & Local Storage (Up to 256 GB), Works w/ Alexa & Google (Tapo C210)

(46,779)
32.99
FREE delivery Saturday, June 14 on your first order
2K+ bought in past month
Loading...
TP-Link Tapo 3K 5MP Pan/Tilt Security WiFi Camera, Baby & Pet Camera, 360° Motion Tracking, 2-Way Audio, 40Ft. Night Vision, Cloud & Local Storage (Up to 512 GB), Works w/Alexa & Google (Tapo C230)

TP-Link Tapo 3K 5MP Pan/Tilt Security WiFi Camera, Baby & Pet Camera, 360° Motion Tracking, 2-Way Audio, 40Ft. Night Vision, Cloud & Local Storage (Up to 512 GB), Works w/Alexa & Google (Tapo C230)

(49,118)
$49.99
FREE delivery Wed, Aug 20
500+ bought in past month