Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

KV cache

Topic: Training and modelsAlso called key-value cache

Definition

Memory where a transformer stores attention keys and values for tokens it has already processed, so it does not recompute them each step.

In more detail

When a model generates text it attends to every earlier token at each step. Caching the keys and values from earlier tokens makes generation far faster, at the cost of GPU memory that grows with context length and the number of parallel requests.

The KV cache explains several things users see. Long contexts need more memory and cost more to serve. Prompt caching works by keeping the KV cache of a shared prefix so later requests skip that work, which is why providers charge less for cached input. Serving engines such as vLLM and SGLang compete largely on how well they manage it.

  • Attention

    The mechanism that lets a transformer weigh how much each token should draw on every other token when building its representation.

  • Inference

    Running a trained model to produce outputs, as opposed to training it. Inference cost and speed decide what an AI feature costs to run.

  • Prompt caching

    Reusing the processed form of a repeated prompt prefix, such as a long system prompt, across requests to reduce latency and cost.

  • Time to first token

    How long a model takes to return the first token of a response after a request, the main driver of how fast a streamed reply feels.

  • Speculative decoding

    A speed-up where a small draft model proposes tokens and the large model checks them in one pass, keeping the ones it accepts.

  • Prompt caching

    Reusing the processed form of a repeated prompt prefix, such as a long system prompt, across requests to reduce latency and cost.

    Glossary

  • vLLM

    High-throughput inference and serving engine for LLMs with an OpenAI-compatible server.

    Tool

  • SGLang

    High-performance serving engine for LLMs and multimodal models with fast prefix caching.

    Tool

  • LLM serving

    Running models behind an API for many users, tuned for latency, throughput and GPU cost.

    SkillAdvanced