Tinker Inference engineering

by Samy (Kondasamy Jayaraman)

1 request of 2,048 tokens: 1.7 GB of cache in a 14 GB room.1 of 8 seats busy · 0 waiting · KV cache 12% full

Chapter 2 of 7

The KV cache at scale

Decoding is fast because the model keeps every token’s keys and values. Larkspur mini’s cache is tiny, but the team’s server runs a real open model for many customers.

This chapter: How much memory does the KV cache take on a real server?

About this chapter

You will learn

  • The KV cache, from the Transformers module, in one step
  • Its size for a real open model, from its published shape
  • Why memory, not compute, caps how many requests a server can hold at once

Words you’ll meet

KV cache
The keys and values the model keeps for every token it has read, so each new token computes only its own.
KV room
The memory left for the KV cache once the model’s weights are loaded.
In flight
Requests the server is working on right now, each holding its own cache.

Step 1 of 5

Every layer keeps a key and a value for every token read: the .

Count Larkspur mini’s cache.

KV cache, counted from each model’s shape: layers × 2 (key and value) × width × tokens × 2 bytes

Recap: Transformers chapter 6, why long prompts cost more.