Caching#
Storing computed results to serve repeated requests faster.
Important
✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.
What it is#
Caching stores the results of expensive computation and reuses them instead of recomputing — trading memory for speed and cost. If the same work would produce the same answer, a cache returns it instantly.
In model serving#
The signature example is the KV cache in transformers, which keeps the key/value tensors of earlier tokens so generating each new token doesn’t re-process the whole sequence. It grows linearly with sequence length and can exceed the model weights in memory — which is why it is often quantized. Beyond that, prediction caching reuses answers to repeated requests and feature caching precomputes costly features.
The trade-offs#
A cache must handle staleness — cached values can go out of date when inputs or the model change — so it needs invalidation and eviction policies, and it consumes memory that must be budgeted against the speed it buys.
Theme: MLOps, Serving & Monitoring · All terminology
Hint
Mind map — connected ideas
Quantization · TPU Clusters · Inference Cost (Inference $) · Cloud Inference · Latency Guardrails · Compute budgets
Hint
More in MLOps, Serving & Monitoring
AWS SageMaker Endpoints · Cloud Inference · Cloud Inference with Big Payloads · Compute budgets · Continuous Retraining · Feature Values · Guardrails (in ML & Data Systems) · Inference Cost (Inference $) · Latency Guardrails · Manual review minutes · Model KPIs (Key Performance Indicators) · Model Stability · Monitoring Pipelines · Ops Health Dashboard
See also
Source article Adapted (context, re-expressed) in our own words from: Caching (insightful-data-lab.com).