How LLM Inference Works

What a model call does on the GPU, token by token, and why that decides your bill and your latency: tokens, prefill and decode, the KV cache, batching, caching and the tricks providers use to go faster.

Watch lesson 01

Free preview01 What happens in one model call

Lessons
20
Modules
4
Running time
~4 hours
Before you start
Called an LLM API once
Free to watch
7 lessons
Last updated
Nov 4, 2026

Part of

[01] Access

[02] Who it's for

  • Engineers who build on LLM APIs and want to know why a call costs what it costs and takes as long as it does.
  • Developers who see words like KV cache, prefill or prompt caching in pricing pages and docs and want them to mean something.
  • No machine learning background is needed. You should be able to read a little Python and a JSON response.

[03] What you'll learn

  • 01Follow one model call from your prompt to the last streamed token, and say where the time goes
  • 02Count tokens the way the provider does and read a bill or a usage report line by line
  • 03Explain why the first token is slow and the rest are fast, using prefill and decode
  • 04Size the KV cache for a context window and see why long prompts cost memory, not just money
  • 05Know how batching, paged memory, prompt caching and speculative decoding let a provider serve many users at once
  • 06Design a feature around cost and latency: prompt layout, caching, model choice and streaming

[04] Syllabus

Module 01

One call

7 lessons75 min
  1. 01
    11m
  2. 02
    11m
  3. 03
    13m
  4. 04
    10m
  5. 05
    13m
  6. 06
    10m
  7. 07
    8m
  8. Module quiz

    5 questions, about 5 minutes

Module 02

Time and memory

4 lessons50 min
  1. 08
    12m
  2. 09
    14m
  3. 10

    The KV cache (locked)

    13m
  4. 11
    11m
  5. Module quiz

    5 questions, about 5 minutes

Module 03

Many calls

7 lessons82 min
  1. 12
    9m
  2. 13
    11m
  3. 14
    10m
  4. 15

    Paged memory (locked)

    14m
  5. 16
    14m
  6. 17
    12m
  7. 18
    12m
  8. Module quiz

    5 questions, about 5 minutes

Module 04

Your product

2 lessons25 min
  1. 19
    13m
  2. 20
    12m
  3. Module quiz

    5 questions, about 5 minutes

[05] How it's made

The curriculum is curated by karnstack and reviewed by senior engineers in the industry before it ships. Narration is an AI voice (ElevenLabs) reading human-written, human-reviewed scripts. Read how courses are made.