Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 08 · AI · Serve the GPT you built · with code: Python · about 12 min to read

Play it as a journeyTutor comes with a plan

The Prefix Cache: Computed Once

Prefix Caching
Prefix Caching · Open board

The Prefix Caching board shows two messages that start with the same standing instructions, and the trick that reads those instructions once. This lesson builds that trick on the toy engine. Stage 4 of the serving series, after Build Your Own Inference Engine.

Before you start. Serve 01: The KV Cache built the cache, the saved keys and values that mean a position is never recomputed. Paged Attention: The Cache in Blocks cut that cache into fixed blocks of positions, and this lesson names those same blocks. Batching: A Slot That Frees Early is the engine around them. The no-code version of this idea sits later in this track as Prefix Caching (the same start, computed once), and this lesson only builds it.

Lesson 74 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • December 2023: a lab notices that its traffic starts the same way
  • The one fact that makes sharing safe
  • Naming a block so a lookup can find it
  • What the cache is judged by
  • What the toy cannot show
  • The tag on each drawer
  • One letter walks the drawers
  • Was the saving real?
  • What if the tag forgot the one before it?
  • All of it in code

Terms it explains: RadixAttention, prefix, block name, hit rate, fingerprint.

Related paper

Review AI