Topics / Inference / Reading series

Inference engineering, step by step

30 short articles by Amit Shekhar (Outcome School), in the order that builds on itself: the generation loop, memory and attention, throughput and latency, serving engines, model-level tricks, then the hardware. Each one links to interview questions to test yourself and to the matching week of the hands-on roadmap.

0/30articles read
6parts
10 XPper article

Part 1: The Basics 0/3

Everything in inference optimization builds on one fact: an LLM generates text one token at a time. Let's understand that generation loop and the two phases behind it first.

  • Autoregressive Modelsroadmap week 1
    Autoregressive Models, the family of models that generate one piece at a time by predicting the next step from the past.
    What it covers (11)
    • What is an Autoregressive Model?
    • The Chain Rule of Probability
    • The Generation Loop
    • Step-by-Step Numeric Example
    • Why GPT-style Models are Autoregressive
    • Why Autoregressive Models Need Causal Masking
    • The Connection with KV Cache
    • Autoregressive vs Non-Autoregressive Generation
    • Popular Autoregressive Models we should know
    • Pros and Cons of Autoregressive Models
    • Quick Summary
  • Prefill vs Decode: LLM Inference Optimizationroadmap week 1
    Prefill vs Decode, the two phases of LLM inference, and how understanding them helps us optimize the speed of an LLM.
    What it covers (12)
    • What is LLM inference
    • The two phases: Prefill and Decode
    • Prefill explained in simple words
    • Decode explained in simple words
    • A diagram of the two phases and the KV cache flow
    • The KV cache as the bridge between the two phases
    • A step-by-step walkthrough of a few decode steps
    • Prefill vs Decode comparison table
    • Why this split matters: compute-bound vs memory-bound
    • The key metrics: TTFT, TPOT, throughput, and end-to-end latency
    • Optimization techniques mapped to each phase
    • Conclusion
  • Prefill-Decode Disaggregationroadmap week 8
    Prefill-Decode Disaggregation, a way of running a large language model where the reading of the prompt and the writing of the answer happen on separate machines.
    What it covers (13)
    • How an LLM answers a request
    • What is the KV Cache?
    • Prefill is compute-heavy, Decode is memory-heavy
    • The problem when both run on the same GPU
    • TTFT vs TPOT
    • The naive approaches and their issues
    • What is Prefill-Decode Disaggregation?
    • How Prefill-Decode Disaggregation works
    • Walkthrough of one request
    • Advantages of Prefill-Decode Disaggregation
    • Disadvantages of Prefill-Decode Disaggregation
    • Where it works well and where it is overkill
    • Co-located vs Disaggregated serving

Part 2: Memory and Attention Optimizations 0/6

Now that we understand the generation loop, let's attack its biggest bottlenecks: repeated computation, wasted GPU memory, and the cost of attention itself.

Part 3: Throughput and Latency 0/7

With memory under control, the next goal is to serve more users per GPU and make every response feel faster.

  • Continuous Batching in LLMsroadmap week 4
    Continuous Batching, a technique that lets LLM servers handle many more users at the same time by keeping the GPU busy at every single step of generation.
    What it covers (13)
    • The Big Picture
    • Quick Recap: How an LLM Generates Tokens
    • Why Batching Matters for LLMs
    • The Old Way: Static Batching
    • The Problem with Static Batching
    • What is Continuous Batching?
    • The Ride-Share Analogy
    • How Continuous Batching Works Step by Step
    • A Numeric Example
    • Real Numbers and Speedup
    • Benefits of Continuous Batching
    • A Few Important Notes
    • Quick Summary
  • Speculative Decodingroadmap week 7
    Speculative Decoding - what it is, why LLM generation is slow without it, how a small draft model and a big target model work together to produce tokens faster, the rejection sampling math that guarantees no quality loss, real numbers showing the 2x to 3x speedup, where it is used in production, and the trade-offs to watch out for.
    What it covers (10)
    • What problem does Speculative Decoding solve?
    • The Big Picture
    • Why is LLM generation slow?
    • The core idea behind Speculative Decoding
    • Step-by-step walkthrough
    • The verification step
    • Real numbers and speedup
    • Where it is used
    • Trade-offs
    • Quick Summary
  • Decoding Medusaroadmap week 7
    Medusa, a simple way to make a language model generate text 2 to 3 times faster by giving it several extra heads that guess multiple future tokens at once.
    What it covers (10)
    • What is Medusa
    • Why text generation is slow
    • A quick recap of speculative decoding
    • The problem with needing a draft model
    • The big idea: many heads on one model
    • How tree attention checks many guesses at once
    • The math behind the speedup with small numbers
    • The results
    • How Medusa lives on today
    • Quick Summary
  • Decoding EAGLEroadmap week 7
    EAGLE, a state-of-the-art way to speed up language model generation by drafting tokens at the feature level instead of the token level.
    What it covers (9)
    • What is EAGLE
    • A quick recap of speculative decoding
    • The problem with token-level drafting
    • The big idea: draft at the feature level
    • Resolving the uncertainty by feeding back the token
    • The math behind the speedup with small numbers
    • EAGLE-2 and dynamic draft trees
    • How EAGLE lives on today
    • Quick Summary
  • N-gram Speculation in LLMsroadmap week 7
    N-gram Speculation in LLMs, a simple trick that makes a language model write its answer faster by guessing the next few words from the text it has already seen.
    What it covers (10)
    • How an LLM generates text
    • Why generating text is slow
    • What is Speculative Decoding
    • The cost of a draft model
    • What is an N-gram
    • What is N-gram Speculation
    • N-gram Speculation step by step
    • Why the output stays exactly the same
    • Where it works well and where it fails
    • N-gram Speculation vs Draft Model Speculative Decoding
  • How does Token Streaming work?roadmap week 3
    How Token Streaming works.
    What it covers (10)
    • What is token streaming
    • A quick recap of how an LLM generates text
    • Why we need streaming at all
    • What is SSE
    • How the HTTP connection stays open
    • The format of a streamed message
    • A full walkthrough from server to screen
    • The [DONE] marker that ends the stream
    • SSE vs WebSockets
    • Token streaming in the real world
  • How does Prompt Caching work?roadmap week 4
    How Prompt Caching works.
    What it covers (10)
    • What is a prompt
    • A quick recap of how an LLM reads a prompt
    • What is Prompt Caching
    • Why we need Prompt Caching
    • The core idea behind Prompt Caching
    • The exact-prefix rule
    • Cache write vs cache read and TTL
    • What we should put in the cache
    • The benefits of Prompt Caching
    • Prompt Caching in the real world

Part 4: Engines and Formats 0/6

These optimizations come together inside real serving engines and model formats. Let's see how the most important ones work.

Part 5: Architecture-Level Optimizations 0/4

Beyond serving techniques, the model itself can be designed, picked, or shrunk for cheaper and faster inference.

Part 6: Hardware 0/4

Finally, all of this runs on hardware. Understanding how GPUs and TPUs actually work explains why every optimization above matters.

Series index from llm-inference-engineering by Amit Shekhar, Outcome School (Apache-2.0). The articles live on outcomeschool.com. See Credits.