AdvancedAbout 22 min

    LLM Inference Optimization

    Read the full article on Substack

    7 min read.

    Understand how production LLM serving achieves low latency and high throughput — explore KV cache mechanics, continuous batching, quantization tradeoffs, and speculative decoding side by side.

    Think of it this way: Serving an LLM without optimization is like a chef who re-reads the entire recipe from scratch before adding each ingredient. The KV cache is sticky-notes for each step already read; continuous batching is running multiple orders in parallel on the same stove; quantization is using a smaller measuring cup that's accurate enough for most dishes; speculative decoding is having a fast sous-chef who guesses the next few steps while the head chef reviews them in bulk.

    KV cache for one request0.67 GB
    Sequence length2,048 tokens

    2,048 tokens need 0.67 GB of KV cache, so 80 GB fits 119 requests this long.

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Prefill or decode?

    Sort

    Sort each property by the inference phase it describes.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Prefill

    Drop items here

    Decode

    Drop items here
    6 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    What does the KV cache store during autoregressive LLM generation?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going