The evolution of deep learning and the advancement of GPUs go hand in hand. While this has always been true, in the current era of AI — driven by Large Language Models (LLMs) — this relationship is more critical than ever.
I previously touched on why GPUs are so perfectly suited for AI in my post, Why GPUs Ate the AI World. Today, we’re going a level deeper. Let’s look under the hood of Nvidia GPUs and break down exactly what makes them so incredibly fast at running deep learning models.
1. General-Purpose Cores vs. Special-Purpose Cores
Every calculation in a GPU happens inside a core. The basic workflow is simple: move data from memory to the core, crunch the numbers, and write the results back to memory.
However, modern GPUs have evolved their cores specifically to handle the unique quirks of deep learning computations.
The Swiss Army Knife: CUDA Cores
First, let’s look at the CUDA Core, which handles traditional scalar operations. With all the recent hype around AI accelerators built for matrix math, it’s easy to forget about the CUDA Core. But its role is absolutely indispensable.
If you tear down the execution pipeline of an LLM, you’ll find essential tasks sandwiched between those massive matrix multiplications. We’re talking about calculating activation functions (like ReLU or GELU), normalizing data distributions (LayerNorm), converting logits into probabilities (Softmax), and managing the complex control flow required by Attention mechanisms.
All of these tasks run on CUDA Cores. Without them, your deep learning pipeline would grind to a halt.
The Heavy Artillery: Tensor Cores
On the flip side, over 90% of modern deep learning operations consist of gigantic matrix multiplications. To accelerate this, modern GPUs deploy a specialized task force: the Tensor Core. Tensor Cores can’t do as many different types of math as CUDA Cores, but they multiply matrices at face-melting speeds. They essentially exist to say, “I don’t care about anything else; I was born to multiply matrices!”
The secret sauce of the Tensor Core is FMA (Fused Multiply-Add). In deep learning, the most common operation is multiplying values and adding them to another value.
D = A * B + C
In traditional computing, you would multiply the numbers, save the result to a temporary register, and then perform the addition.
Tensor Cores, however, fuse these matrix multiplications and additions into a single, physical hardware instruction. Doing two things at once creates a kind of hardware magic:
First, pipeline throughput goes through the roof. It saves clock cycles and significantly reduces power consumption.
Second, it preserves numerical precision. In a non-fused approach, you have to round the decimal point immediately after the multiplication step before you can add. Fused operations perform the math with full precision internally and only round the numbers once at the very end. This prevents rounding errors from snowballing out of control.
Ultimately, a Tensor Core is just a massive engine made up of hundreds of these fused units, designed to chew through massive matrix math in one gulp.
2. Saving Memory Bandwidth with Low Precision
As mentioned earlier, to do math, you have to physically move data from memory to the processor. But your memory bandwidth is a fixed “highway,” meaning there’s a hard limit on how many “delivery trucks” can pass through at once.
What’s the most intuitive way to fix this?
Shrink the cargo. By using low-precision data formats, we shrink the footprint of the data, allowing us to pack way more numbers onto those delivery trucks.
Use Only What You Need
The 32-bit floating-point (FP32) format, once the gold standard for scientific computing, is simply too bloated for deep learning. The industry shifted to 16-bit (FP16), and now we are down to 8-bit (FP8). By swapping FP16 for FP8, you cut bandwidth usage in half, allowing you to feed twice as much data into the Tensor Cores in the exact same amount of time, using the exact same hardware.
But naturally, dropping bits increases calculation errors. So, how do we get around that?
Nvidia engineers came up with a brilliant compromise: Mixed Precision. The input data sent into the math units is compressed down to FP8. However, the “Accumulator” circuit — the part that constantly adds up the running totals — is designed to operate at a much higher precision, like FP32 or at least FP16. This gives us the best of both worlds: we save massive amounts of memory bandwidth without destroying the mathematical integrity of the final output.
This works because, statistically, the precision of a single input value doesn’t matter too much, but the precision of the accumulator — where millions of tiny values pile up — matters immensely.
Dynamic Precision and the Transformer Engine
It goes even deeper. Even within the FP8 format, there are two distinct variations based on what you’re trying to do: E4M3 and E5M2.
For forward passes and inference — where precision is more important than representing gigantic numbers — the GPU uses E4M3 (4 exponent bits, 3 mantissa bits). For backward pass training — where you might lose a little detail but absolutely need the dynamic range to capture tiny gradients or massive spikes — it switches to E5M2 (5 exponent bits, 2 mantissa bits).
This is where Nvidia’s Transformer Engine steps in. It’s a software layer that analyzes the statistical distribution of data at every layer of the model. It performs intelligent scaling: automatically dropping to 4-bit or 8-bit to save bandwidth where it’s safe to do so, and automatically scaling back up to higher bit depths in layers where precision is a matter of life and death.

3. The Factory Floor: The SM (Streaming Multiprocessor)
Pulling data directly from the GPU’s main memory is an agonizingly slow and expensive process. To fix this, GPUs use independent production lines called SMs (Streaming Multiprocessors), which are engineered for extreme efficiency.
If a GPU is a massive industrial city, an SM is an independent mega-factory operating within it.
Here is how the inside of an SM is laid out:
The Brains: Warp Scheduler and Dispatch Unit
The basic unit of execution on a GPU is called a Thread. It’s conceptually similar to a CPU thread, but it’s an ultra-lightweight version purpose-built for the GPU.
While a CPU might run a few dozen or a few hundred threads at once, a GPU runs hundreds of thousands, or even millions, of threads simultaneously. Because managing millions of individual threads is chaotic, the GPU groups them into manageable bundles called “Warps.” A Warp typically consists of 32 threads, and every thread in a Warp is forced to execute the exact same instruction at the exact same time.
For example, 32 threads tasked with adding two numbers are bundled into one Warp. The GPU issues a single command to the Warp, and all 32 threads simultaneously add their specific pairs of numbers. This architecture is called SIMT (Single Instruction, Multiple Threads).
To manage this, the SM has a Warp Scheduler and a Dispatch Unit. The Scheduler monitors the status of dozens of Warps every single clock cycle. The moment it sees that a Warp has received all its necessary data from memory and is ready to work, the Dispatch Unit instantly fires that Warp’s instructions directly into the execution units.
The Register File
The SM contains a massive Register File, which is hundreds of times faster than the GPU’s main memory. When threads are launched, they store their local variables directly in these registers, allowing them to do math at blisteringly fast speeds without waiting on slow main RAM.
However, there is a catch: if a developer writes bloated code that requires too many registers per thread, the SM can’t physically fit as many Warps inside it. This drops “occupancy,” meaning there’s less work available to feed the execution units, leaving expensive hardware sitting idle.
Execution Units
These are the actual blue-collar workers that execute the math when the Dispatch Unit tells them to:
- Tensor Core: The massive engine handling matrix multiply-accumulate pipelines at the Warp level.
- CUDA Core: The general-purpose unit handling control flow, logic, and standard scalar math.
- LD/ST (Load/Store Unit): The logistics team dedicated strictly to fetching and saving data from memory.
Supercharging Efficiency
The SM utilizes data caches and shared memory to aggressively cut down on the time wasted moving data around.
- Tiling: Instead of fetching data from main memory over and over, the LD/ST unit grabs a chunk (Tile) of a matrix just once and places it into the SM’s hyper-fast Shared Memory. From then on, the Tensor Cores just rapidly cycle data in and out of that local Shared Memory. This maximizes math operations while minimizing memory fetches — a concept known as increasing “arithmetic intensity.”
- TMA (Tensor Memory Accelerator): Introduced in architectures like Hopper, TMA is dedicated hardware that handles memory copying asynchronously in the background. It frees up the cores so they can dedicate 100% of their time to crunching numbers rather than hauling data.
- TMEM (Tensor Memory): Starting with the Blackwell architecture, Nvidia slapped a dedicated 256KB block of SRAM directly next to the Tensor Core. Previously, moving intermediate results between registers and shared memory created a bottleneck. Now, the Tensor Core has its own exclusive stash to dump and retrieve data instantly.
4. Software: CUDA
Hardware this complex requires an orchestrator, and that is where CUDA (Compute Unified Device Architecture) comes in. It’s the programming interface that lets developers direct the hardware.
CPUs and GPUs have entirely different work ethics. If CPU threads are a handful of Michelin-star chefs who meticulously cook a complex 5-course meal from start to finish, GPU threads are an army of 100,000 prep cooks whose only job is to chop carrots simultaneously.
Developers write CUDA code (usually in C++) to define what this army does.
Let’s look at a basic addVectors script—a program that adds two arrays (A and B) of 1,000,000 numbers to create array C—to see how the whole pipeline connects.
Step 1. Writing the Kernel: The Work Order
First, we write a single function that millions of threads will execute identically. The __global__ keyword tells the compiler: "The CPU will call this function, but the GPU will actually execute it."
This GPU-executed function is called a Kernel.
#include <iostream>
#include <cuda_runtime.h>
// [Kernel Definition] The work order for the GPU threads
__global__ void addVectors(float* A, float* B, float* C, int N) {
// 1. Global Indexing: Figure out exactly which piece of data *this specific thread* should process
int i = blockIdx.x * blockDim.x + threadIdx.x;
// 2. Boundary Check: Make sure we don't try to calculate past the total number of items (N)
if (i < N) {
// 3. The actual math (This is where the CUDA core fires)
C[i] = A[i] + B[i];
}
}
Step 2. Running the Pipeline: The CPU (Host) Code
Before looking at the next block of code, you need to understand Grids and Blocks.
Dumping a million threads onto a chip with no structure is a recipe for chaos. Therefore, CUDA organizes threads into a 3-tier hierarchy:
- Thread: The individual worker (e.g., a single prep cook).
- Block: A group of threads working together (e.g., a team of 256 cooks). All threads in the same block are assigned to the same SM, meaning they can talk to each other via Shared Memory.
- Grid: A collection of Blocks. It represents the entire workspace created by a single kernel launch. All blocks in a grid share the GPU’s global memory (VRAM).
Now, let’s look at the host code. We allocate memory, calculate the thread layout, and fire the kernel over to the GPU.
int main() {
int N = 1000000; // 1 million data points
size_t size = N * sizeof(float);
// 1. Allocate and initialize memory on the CPU (Host)
float *h_A = new float[N];
float *h_B = new float[N];
float *h_C = new float[N];
for (int i = 0; i < N; i++) {
h_A[i] = 1.0f;
h_B[i] = 2.0f;
}
// 2. Allocate memory on the GPU (Device Global Memory / VRAM)
float *d_A, *d_B, *d_C;
cudaMalloc((void**)&d_A, size);
cudaMalloc((void**)&d_B, size);
cudaMalloc((void**)&d_C, size);
// 3. Data Transfer (Host to Device): Copy data from CPU RAM to GPU VRAM
// *Note: This is where massive PCIe bandwidth bottlenecks usually happen!*
cudaMemcpy(d_A, h_A, size, cudaMemcpyHostToDevice);
cudaMemcpy(d_B, h_B, size, cudaMemcpyHostToDevice);
// =========================================================
// 4. [The Core Concept] Setting up the Thread Hierarchy
// =========================================================
// The developer decides to group 256 threads into a single block.
int threadsPerBlock = 256;
// How many blocks do we need to process 1,000,000 items?
// We use integer division with a ceiling formula: (N + threads - 1) / threads
int blocksPerGrid = (N + threadsPerBlock - 1) / threadsPerBlock;
// Math check: 1,000,000 / 256 = 3906.25 -> We need 3,907 blocks.
// 5. Kernel Launch: <<<Blocks, Threads per Block>>>
// Right now, 3,907 blocks * 256 threads = 1,000,192 threads are instantiated on the GPU.
addVectors<<<blocksPerGrid, threadsPerBlock>>>(d_A, d_B, d_C, N);
// 6. Return Data (Device to Host): Bring the computed results back to the CPU
cudaMemcpy(h_C, d_C, size, cudaMemcpyDeviceToHost);
// 7. Clean up memory
cudaFree(d_A);
cudaFree(d_B);
cudaFree(d_C);
delete[] h_A;
delete[] h_B;
delete[] h_C;
return 0;
}
Step 3. What happens in the GPU when this runs?
The exact millisecond you execute that main function, all the hardware architecture we discussed wakes up:
- CUDA Launch (
<<<3907, 256>>>): The GPU's global scheduler spawns 3,907 blocks. - SM Distribution: These blocks are distributed evenly across the dozens of SMs on the chip.
- Warp Splitting: Once a block of 256 threads lands inside an SM, it is immediately chopped into groups of 32, creating 8 Warps.
- Residency: These Warps claim their space in the SM’s Register File and become “resident.”
- Execution: The Warp Scheduler watches them, and the Dispatch Unit fires them into the execution units (CUDA cores, in this simple addition example) the moment their data arrives.
With just a few lines of code, you’ve orchestrated a million parallel operations across tens of thousands of physical cores.
But it doesn’t stop there. There is one final software optimization happening in the background to keep everything moving.
5. Hiding the Memory Bottleneck
You can increase bandwidth, compress data, and use tiling, but you can never overcome the speed of light. The physical latency required to fetch data from memory will never be zero. This is especially painful during the Decode phase of LLM generation, which is notoriously memory-bound.
To fight this, GPUs use another trick: if you have to wait for memory, do something else while you wait.
Zero-Overhead Context Switching
If a CPU thread stalls because it’s waiting on RAM, the operating system intervenes and performs a “context switch.” It saves the thread’s current state to memory and loads a new thread’s state. This is a very heavy, expensive operation.
GPUs do the same thing, but they do it almost instantly.
- Residency: Inside an SM, dozens of Warps have already checked into the “hotel.” Their data is fully loaded into the local registers. They are resident.
- Instant Swapping: Let’s say Warp #1 is doing math, realizes it needs a chunk of data from VRAM, and stalls. Instead of doing a heavy backup process like a CPU, the GPU’s Warp Scheduler just points to Warp #2 and says, “You’re up.” Because Warp #2 is already resident and has its local variables loaded in the registers, the switch happens with virtually zero overhead.
By having an army of Warps sitting in the registers ready to go, the GPU can perfectly hide memory latency. Whenever one Warp stalls waiting for a delivery, another Warp seamlessly tags in to keep the math cores fed at 100% utilization.
6. Summary: The Deep Learning Pipeline
Let’s pull all of this together and see how these hardware and software components orchestrate a modern LLM inference or training run.
- Data Loading: Hundreds of gigabytes of model parameters are loaded into the VRAM (Global Memory).
- Kernel Execution: The PyTorch/CUDA code launches, generating hundreds of thousands of Threads that calculate their specific target data locations.
- Warp Residency: Threads are bundled into groups of 32 called Warps, which immediately take up residence in the ultra-fast registers inside the SMs.
- Tiling Efficiency: The TMA hardware works in the background, hauling chunks of matrix data from VRAM into local Shared Memory and TMEM. The data is recycled locally to maximize math operations per byte fetched.
- Warp Scheduling: When Warps inevitably stall waiting on memory (like in the Decode phase), the Warp Scheduler instantly swaps in a fresh Warp. This zero-overhead switching keeps the execution units constantly fed.
- High-Speed Math: Data packed efficiently into FP8 (or smaller) formats floods into the FMA (Fused Multiply-Add) units inside the Tensor Cores, yielding massive throughput.
- Returning Results: The mixed-precision accumulators (running in FP32) ensure the math stays accurate. The final results are routed back through Shared Memory to their final destination.
Wrapping Up
Modern GPUs didn’t come to dominate deep learning just by cramming more cores onto a piece of silicon.
They won by using an elegant, highly orchestrated fusion of hardware and software to solve the physics problems of memory bandwidth and latency — specifically the massive memory-bound bottlenecks that plague LLMs.
As an engineer, looking past the Python code and understanding exactly where the silicon breathes and where the bottlenecks choke is more than just trivia. In the AI era, that deep system-level insight is the ultimate weapon for breaking through performance ceilings.