You write a + b and think of it as one step. It isn't — that line is a lookup that ends in a compiled kernel, and PyTorch pays that lookup every single time the op runs. This video follows one Python line down through the dispatcher to the exact kernel it launches, runs the same a + b four different ways — CPU, CUDA, half precision, with gradients — and measures what the dispatch lookup itself actually costs: about 27 microseconds, every call.
What you'll learn:
• Why a + b names an op, not a function — and what the dispatcher does with it
• The dispatch path: Python line → op → dispatcher → chosen kernel → device
• The dispatcher's three keys: device, dtype, and whether gradients are needed
• The same a + b run four ways, landing on four different kernels
• Measuring the fixed dispatch cost: about 27 microseconds per call
• Why "the GPU does the work, so Python is free" is only half true
Chapters:
0:00 Intro & roadmap
1:18 The Dispatch Path
3:35 One Line, Different Kernels
4:59 The Fixed Cost
6:18 Recap & what's next
Playlists:
▶ Full course — Practical PyTorch (Tensors to Transformers): https://www.youtube.com/playlist?list=PLXMgPBl0Q1-w
▶ CUDA & PyTorch Performance: https://www.youtube.com/playlist?list=PLUhE7Cufy7-o
Every number on screen is a real measurement, timed on an NVIDIA L4 (torch 2.12.0+cu130), not asserted. Practical PyTorch teaches one idea per picture — for people who can already code and want to actually understand the framework.
#PyTorch #DeepLearning #CUDA #GPU #Performance #Python #MachineLearning