How DeepSeek's Multi-Head Latent Attention Works

MLA caches one 512-dimensional latent per token instead of 128 heads’ worth of keys and values, and matrix absorption means it never has to decompress them. We derive it step by step: joint compression, absorption, why RoPE breaks it, and the decoupled RoPE branch that fixes it.

Date: October 27, 2026  |  Estimated Reading Time: 13 min  |  Author: Chi Zhang

How Continuous Batching Enables High-Concurrency LLM Inference

Naive batching holds every slot until the longest request finishes. Continuous batching swaps requests in and out at every forward step, which means packing prefill and decode tokens into one flat input and splitting attention back out per request with a cu_seqlens boundary table.

Date: October 9, 2026  |  Estimated Reading Time: 10 min  |  Author: Chi Zhang

How RoPE Improves on Sinusoidal Positional Encoding

Sinusoidal encoding has a neat rotation property, but it breaks once the encoding goes through attention’s projection matrices. We expand the dot product to see why, then put RoPE through the same expansion and watch the absolute positions cancel out.

Date: September 13, 2026  |  Estimated Reading Time: 9 min  |  Author: Chi Zhang

Why Transformers Need Positional Encoding

Attention can’t tell “dog bites man” from “man bites dog”. We try integer, fractional and binary encodings, see where each one breaks, and arrive at sines and cosines: a set of clock hands spinning at different speeds.

Date: September 5, 2026  |  Estimated Reading Time: 9 min  |  Author: Chi Zhang

Why FlashAttention is So Fast

FlashAttention does every multiplication standard attention does, yet runs several times faster. We build it up step by step from the GPU memory hierarchy: kernel fusion, safe softmax, online softmax, and tiling.

Date: August 23, 2026  |  Estimated Reading Time: 13 min  |  Author: Chi Zhang

How Much GPU Memory Does the KV Cache Really Take?

We build the KV cache size formula one factor at a time, from single-head attention to multi-head, stacked layers and MQA/GQA, then check it against a real calculator: 13.73 GiB for 100,000 tokens on Qwen3-8B.

Date: July 21, 2026  |  Estimated Reading Time: 8 min  |  Author: Chi Zhang

KV Cache vs. Prompt Cache: What's the Difference?

A prompt cache doesn’t store your last answer. We walk through prefill, decode and attention to see what the KV cache keeps, and how a prompt cache reuses it across requests.

Date: May 24, 2026  |  Estimated Reading Time: 8 min  |  Author: Chi Zhang