KV Cache › Key Parameters

Michael BrenndoerferJanuary 6, 20261 min read
Language AI HandbookAll chapters
Part 42 of 67Inference Optimization
Chapter 313KV Cache › Key Parameters
Reading section 11 of 14 · Key Parameters · 1 minSection 11 of 14 · 1 min

Book contents

Section 11 of 14 · 1 min read

KV Cache › Key ParametersOne section · Sections in this chapter11 / 14 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Understanding each parameter's role helps you reason about deployment decisions when configuring inference servers:

  • d_model: The dimensionality of the model's hidden states. This appears directly in the memory formula and in the projection computation cost.
  • num_heads: The number of attention heads. Along with head_dim, it determines how the model dimension is partitioned. More heads mean more granular attention patterns but the same total cache size (since H×dh=dmodelH \times d_h = d_{\text{model}}).
  • head_dim: The dimension of each attention head, equal to dmodel/num_headsd_{\text{model}} / \text{num\_heads}. Smaller head dimensions mean more heads for the same model width.
  • max_seq_len: The maximum sequence length the cache can store. This determines the upper bound on context length and the maximum cache memory for a given model.
  • batch_size: The number of sequences processed simultaneously. Larger batches improve GPU utilization and throughput but multiply cache memory linearly.