Skip to content
English

Switch theme

// Stage 6 · Inference, Deployment & Efficiency

Decoding, Sampling & KV Cache

Prefill and decode, temperature/top-p, KV cache and the memory-bandwidth bottleneck.

about 6 hours4 algorithms2 paperslesson text ready

01Goals

Do these first: Modern LLM Architecture

02Read on this site

03Algorithms to master

Each card has the original paper, prerequisites and resources.

04Must-read papers

05Courses & videos

06Hands-on: project, code & exercises

Free, official or author-published pages. Most run in the browser or on a free Colab GPU.

PROJECT

Add a KV cache to your small GPT and measure the speed-up when generating 1,000 tokens.

  1. 1
    Hugging Face Transformers ↗Official docs

    Compare greedy, beam, top-p and speculative decoding outputs and speed on one model.

  2. 2
    github.com ↗Reference code

    Add a KV cache to nanoGPT’s generate() and measure the speed-up.

07Self-test

Answer in your head, then open to check.

KV cache size is proportional to what?

Layers × KV heads × head dimension × sequence length × batch × 2.

What does top-p = 0.9 mean?

Sample only from the smallest set of candidates whose cumulative probability reaches 90%.

Why is GPU utilisation low during decoding?

Each step computes one token; most time goes to reading weights and the cache.

On these routes: Application Developers

Data updated: AI algorithms & curriculum(UTC+8)