Works on My GPU
GPU & Systems
Deep DiveInference

KV Cache Quantization: The Same Cache, in Fewer Bits

Grouped-Query Attention shrank the KV cache by cutting how many key/value heads exist. This leaves the head count alone and asks a more granular question: how many bits does each individual number in that cache actually need?

Read more →·Beyzanur Zeybek
ML & AI
Deep DiveArchitecture

Grouped-Query Attention: Shrinking the KV Cache Itself

PagedAttention changed how the KV cache gets allocated. Prefix caching changed whether it has to be recomputed at all. Neither touches how big it is per token in the first place. Grouped-query attention is the lever that does.

Read more →·Beyzanur Zeybek
GPU & Systems
Deep DiveInference

Prefix Caching: Sharing the KV Cache Across Requests

PagedAttention let two branches of the same request share a KV cache block via copy-on-write. Prefix caching asks the more useful version of that question: what about two different requests, arriving minutes apart, that happen to start with the same tokens?

Read more →·Beyzanur Zeybek
GPU & Systems
Deep DiveInference

Disaggregated Serving: Splitting Prefill and Decode Across GPUs

Continuous Batching flagged this and moved on: mixing a new request's prefill into a batch of in-flight decode steps spikes latency for everyone else sharing that iteration. Disaggregated serving's answer is blunt — stop sharing GPUs between the two phases at all.

Read more →·Beyzanur Zeybek
GPU & Systems
Deep DiveInference

Expert Parallelism: How MoE Models Actually Get Served

The Mixture of Experts post ended on a deliberately unfinished sentence: serving an MoE model means shuffling tokens between GPUs mid-layer, a genuinely different bottleneck than anything else on this blog. This is that problem — and the bandwidth cliff that makes it hard.

Read more →·Beyzanur Zeybek
ML & AI
Deep DiveArchitecture

Mixture of Experts: How Sparse Models Save Compute

Every post in this section's Foundations series described one dense feed-forward network every token has to pass through. Mixture of Experts replaces that one FFN with dozens, and routes each token through only a couple of them — decoupling how much a model knows from how much compute each token actually costs.

Read more →·Beyzanur Zeybek
ML & AI
FoundationsAttention

RoPE: How Rotary Position Embeddings Actually Work

How the Transformer Actually Works left one sentence unexplained: most modern LLMs moved on from sinusoidal position encoding to something called RoPE. The trick behind it is almost mechanical — rotate the query and key vectors by an angle proportional to position, and relative position falls out of the dot product for free.

Read more →·Beyzanur Zeybek
GPU & Systems
Deep DiveInference

Continuous Batching: Why LLM Serving Isn't Just Bigger Batches

Static batching forces a GPU to wait for the slowest sequence in a batch before it can serve anything new. Orca's iteration-level scheduling — the idea vLLM calls continuous batching — schedules at the granularity of a single decoding step instead, and the throughput gap is not small.

Read more →·Beyzanur Zeybek
ML & AI
FoundationsMultimodal

CLIP: Connecting Text and Images in One Embedding Space

The last three posts built a text encoder and an image encoder separately. CLIP's entire contribution is refusing to keep them separate: train both at once so a caption and its matching image land at the same point in a shared embedding space, and classification falls out for free.

Read more →·Beyzanur Zeybek
ML & AI
FoundationsVision

Vision Transformers: Attention for Images

Split an image into patches, treat each patch as a token, and feed the sequence into the exact same Transformer encoder from the NLP posts on this blog. No convolutions, no vision-specific architecture — just enough data to make up for what CNNs get for free.

Read more →·Beyzanur Zeybek
ML & AI
FoundationsNLP

Tokenization: How Text Becomes Numbers

The previous post started from 'token embeddings' without saying where tokens come from. Byte-Pair Encoding builds a vocabulary by repeatedly merging the most frequent adjacent pair — a small, mechanical rule that ends up deciding how expensive every prompt is.

Read more →·Beyzanur Zeybek
ML & AI
FoundationsAttention

How the Transformer Actually Works

Self-attention, in one formula: softmax(QKᵀ/√d_k)V. Everything else in the Transformer — multi-head splitting, positional encoding, the residual stack — exists to make that one computation usable at scale.

Read more →·Beyzanur Zeybek
GPU & Systems
Deep DiveInference

PagedAttention: How vLLM Stopped Wasting GPU Memory

Existing LLM serving systems were wasting 60–80% of KV cache memory before a single token got generated. PagedAttention borrows a 60-year-old idea from operating systems — virtual memory paging — to bring that down to under 4%.

Read more →·Beyzanur Zeybek
GPU & Systems
Deep DiveCUDA

Why FP8 Needs Register Shuffles in WGMMA

FP16 lets you feed one WGMMA's output straight into the next — the layouts already match. FP8 doesn't get that for free: the accumulator and the next operand disagree on which thread owns which value, and fixing that costs real shuffle instructions.

Read more →·Beyzanur Zeybek
GPU & Systems
FoundationsCUDA

WGMMA and Register Fragments, Explained

WGMMA showed up unexplained in two earlier posts — as a row in a diagram, then as a building block of FlashAttention-3. Here's what it actually is: an async, 128-thread-wide matrix multiply, and the register layout that makes it usable.

Read more →·Beyzanur Zeybek
GPU & Systems
FoundationsCUDA

Understanding CuTe Layouts: Shape and Stride

Every CuTe layout is just a pair — a Shape and a Stride. That one idea, applied recursively, is what lets CUTLASS 3.x describe a whole GEMM's tiling — from the full matrix down to a single thread's registers — with one abstraction instead of a class per level.

Read more →·Beyzanur Zeybek
GPU & Systems
FoundationsCUDA

What Is CUTLASS, and Why Does It Exist?

cuBLAS gives you a fast, opaque matrix multiply. CUTLASS gives you the same speed as composable C++ building blocks, so you can fuse, customize, and specialize — matched to the GPU's own execution and memory hierarchy.

Read more →·Beyzanur Zeybek