VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
D13: GPU & CUDA Programming · The CUDA Programming Model — Grids, Blocks, Threads and Streams

The CUDA Programming Model — Grids, Blocks, Threads and Streams

15 min read·Staff+ Tier· Unrolled Pro
The CUDA Programming Model — Grids, Blocks, Threads and Streams

You already know: SMs, warps and latency hiding (GPU architecture); pointers, memory allocation and RAII in C++ (D1 C++ & memory); asynchronous programming with an event loop (D1 Async concurrency).

Why this matters for Atlas. CUDA is the programming model under PyTorch, cuBLAS, FlashAttention, vLLM's kernels and Triton's output. Even if you mostly write Python, reading a kernel, understanding a profiler trace or debugging "illegal memory access" requires the model: a kernel runs as a grid of thread blocks, each thread computes its own index and handles its own data, memory moves explicitly between host and device, and work is queued asynchronously on streams. This lesson builds that model step by step, with CUDA C++ shown as it is written and Python simulations you can run anywhere to check the logic.


1. A kernel is a function run by many threads

The question. How does one function process ten million elements on a GPU?

Start from nothing. You write the code for one thread. At launch you say how many threads to run, organized as a grid of blocks, each block holding up to 1,024 threads. Each thread reads built-in variables (blockIdx, blockDim, threadIdx) to compute which element it owns, and checks that the index is in range (the grid is usually rounded up to whole blocks).

That's the preview. The full lesson, with its code and exercises, is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "The CUDA Programming Model — Grids, Blocks, Threads and Streams"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee