Skip to content
sinc-LLMBook a 15-minute call
Page signal: 16 sections as samples, joined by sinc reconstruction; computed from this page's text.

KV Cache Memory for Long-Context LLM Serving: How to Size, Compress, and Budget GPU VRAM

A practical guide to sizing the KV cache from a model config, then fitting weights, cache, and overhead into real GPU memory.

Quick Answer & Verified Key Facts

Direct Answer: KV cache size scales linearly with context length and depends on model architecture, with FP8 quantization halving memory use compared to BF16.

On this page

The KV cache is the memory a model uses to remember the keys and values of every token it has already seen. Its size grows in a straight line with context length and batch size, so it, not the weights, sets how many long requests one GPU can hold. You can size it exactly from four numbers in the model config.

By Mario AlexandreLLM Performance & Reliability

Most teams find out about the KV cache the hard way. The model loads fine. A short test prompt works. Then a real user sends a long document, or ten users arrive at once, and the server queues work, slows down, or runs out of memory.

The cause is almost always the same. Weights are a fixed cost. The KV cache is a cost that grows with every token of every live request. This guide shows how to size that cost from a model config, how to split GPU memory, and which tools shrink it.

This page is about memory. Our guide to continuous batching for LLM inference covers how a scheduler shares the GPU fairly between requests. Our post on time to first token vs throughput covers the speed side. Here we answer a narrower question: how many tokens fit, and why.

What the KV cache is and why it exists

The KV cache is a store of the key and value vectors for every token a model has already processed. The model keeps them so it does not have to compute them again for each new token. It is the main reason long-context serving is a memory problem.

The short mechanism

A decoder model writes one token at a time. To pick the next token, each attention layer compares a new query against the keys of all earlier tokens. It then mixes the matching values. Without a cache, the model would recompute every earlier key and value at every step.

So the server saves them. Each layer keeps a key vector and a value vector for each KV head and each token. When the next token arrives, the layer adds one more key and one more value to the store. Old entries never change, so the store only grows until the request ends.

The PagedAttention paper puts the problem plainly. It says the KV cache memory for each request is huge and grows and shrinks dynamically. That one sentence explains most serving pain. The cache is large, and its size is not known when a request starts.

Why it matters more than FLOPs

Attention during decoding reads a lot of memory for each bit of math. The multi-query attention paper named this cost early. It pointed to the memory-bandwidth cost of repeatedly loading the large "keys" and "values" tensors. Every new token reads the whole cache for that request.

FlashAttention attacks the same limit from another side. Its authors describe an exact attention method that uses tiling to reduce the number of memory reads/writes between GPU high bandwidth memory (HBM) and GPU on-chip SRAM. That helps speed. It does not shrink the cache you must store. Storage is what this guide is about.

Two terms to keep apart

Weights are the model's learned numbers. Their size is fixed once you pick a model and a data type. KV cache is the per-token state of live requests. Its size depends on how many tokens are in flight right now.

A third bucket, overhead, covers everything else. That means activations, CUDA graphs, buffers, and the runtime itself. We will budget all three below.

The KV cache sizing formula per token and per batch

The size of the cache for one token is: 2 x layers x KV heads x head dimension x bytes per element. Multiply by the total tokens held across all live requests to get the full cache size. Every term comes from the model config and your chosen cache data type.

Each term in plain words

  • 2: one key and one value for each head.
  • layers: num_hidden_layers in the config. Every layer keeps its own cache.
  • KV heads: num_key_value_heads in the config. This is often smaller than the number of query heads.
  • head dimension: hidden_size divided by num_attention_heads, unless the config lists head_dim directly.
  • bytes per element: 2 for BF16 or FP16, 1 for FP8.

Note that the head count in the formula is the KV head count, not the query head count. This is the most common mistake in KV math. Using the query head count can overstate the cache by a large factor on modern models.

From one token to a whole batch

The total cache is the per-token size times the sum of tokens over all live requests. A request counts its prompt tokens plus the output tokens produced so far. So the total is bytes per token x (sum over requests of prompt plus generated tokens).

For planning, a simple upper bound is bytes per token x max context x concurrent requests. Real loads use less, because most requests are shorter than the max. But the upper bound is what breaks a server at peak, so plan with both numbers.

A quick sanity rule

Write the per-token size in KiB, then think in thousands of tokens. A model with 56 KiB per token needs 56 MiB for each 1,024 tokens. That rule makes it easy to check a number in your head before you trust a tool.

How MHA, MQA, and GQA change cache size

The attention design decides how many KV heads each layer stores. Multi-head attention keeps one KV head per query head. Multi-query attention keeps one KV head per layer. Grouped-query attention sits in between. Fewer KV heads means a smaller cache in direct proportion.

Multi-head attention

In classic multi-head attention, or MHA, every query head has its own key and value head. If a layer has 28 query heads, it stores 28 key heads and 28 value heads per token. That is simple, but it is the most expensive layout for memory.

Multi-query attention

Noam Shazeer proposed multi-query attention, or MQA, to cut decode cost. In MQA the keys and values are shared across all of the different attention "heads". One KV head serves every query head in the layer. The cache shrinks by a factor equal to the query head count.

The catch is quality. The GQA paper notes that MQA can lead to quality degradation. One shared head can carry less detail than many separate heads.

Grouped-query attention

GQA is the middle path. It uses an intermediate (more than one, less than number of query heads) number of key-value heads. Groups of query heads share one KV head each. The authors report that uptrained GQA achieves quality close to multi-head attention with comparable speed to MQA.

They also show you need not train from scratch. According to the paper, a multi-head checkpoint can be converted and uptrained using 5% of original pre-training compute. That is part of why GQA spread so fast across open models.

What GQA saves on real configs

Both Qwen models in this guide use GQA. Qwen2.5-7B-Instruct has 28 query heads and 4 KV heads. So each KV head serves 7 query heads, and the cache is 7 times smaller than an MHA version of the same model would need.

Qwen2.5-14B-Instruct-1M has 40 query heads and 8 KV heads. Each KV head serves 5 query heads. The cache is 5 times smaller than full MHA. These ratios come straight from the configs, as shown in the next section.

Layout KV heads per layer Cache vs MHA Quality note
MHA Same as query heads 1x (baseline) Full detail per head
GQA Between 1 and query heads Query heads / KV heads smaller Close to MHA per the GQA paper
MQA 1 Query heads times smaller Can lose quality per the GQA paper
Qwen2.5-7B (GQA) 4 of 28 7x smaller From the published config
Qwen2.5-14B-1M (GQA) 8 of 40 5x smaller From the published config

Worked examples with real Qwen2.5 configs

The examples below use the published config files and plain arithmetic. They are illustrative arithmetic, not measured results. Use them to check your own math, then confirm with the numbers your serving engine prints at start.

Qwen2.5-7B-Instruct inputs

The Qwen2.5-7B-Instruct config lists "hidden_size": 3584, "num_attention_heads": 28, "num_key_value_heads": 4, and "num_hidden_layers": 28. It also lists "max_position_embeddings": 32768 and "torch_dtype": "bfloat16".

Head dimension is 3584 / 28 = 128. Per-token cache in BF16 is 2 x 28 x 4 x 128 x 2 = 57,344 bytes. That is exactly 56 KiB per token. In FP8 it is 28,672 bytes, or 28 KiB.

Qwen2.5-14B-Instruct-1M inputs

The Qwen2.5-14B-Instruct-1M config lists "hidden_size": 5120, "num_attention_heads": 40, "num_key_value_heads": 8, and "num_hidden_layers": 48. Its "max_position_embeddings": 1010000 is set for very long input.

Head dimension is 5120 / 40 = 128. Per-token cache in BF16 is 2 x 48 x 8 x 128 x 2 = 196,608 bytes. That is 192 KiB per token. In FP8 it is 98,304 bytes, or 96 KiB. So the 14B model needs about 3.4 times the cache of the 7B model for each token.

Cache for one request at 32K, 128K, and 1M tokens

The table uses binary units, where 1 GiB is 1,073,741,824 bytes. 32K means 32,768 tokens and 128K means 131,072 tokens. 1M means 1,000,000 tokens. Each cell is for one request at full length.

Model and cache type Per token 32K tokens 128K tokens 1M tokens
Qwen2.5-7B, BF16 56 KiB 1.75 GiB 7.00 GiB 53.41 GiB
Qwen2.5-7B, FP8 28 KiB 0.88 GiB 3.50 GiB 26.70 GiB
Qwen2.5-14B-1M, BF16 192 KiB 6.00 GiB 24.00 GiB 183.11 GiB
Qwen2.5-14B-1M, FP8 96 KiB 3.00 GiB 12.00 GiB 91.55 GiB

Two notes keep this honest. The 7B config lists a 32,768 position limit, so its 128K and 1M rows are pure arithmetic. They show the scale of the problem, not a setting you should run as is. The 14B-1M model is the one built for long input.

What the table tells you

A single 1M token request on the 14B model needs about 183 GiB of cache in BF16. No single 80 GB card holds that, even before weights. FP8 cuts it to about 92 GiB, which still needs more than one GPU.

Even at 128K, the 14B model needs 24 GiB of cache per request in BF16. Four such requests at once need 96 GiB of cache. That is why long context is a capacity choice, not just a model choice.

The MHA comparison

Suppose the 7B model used full MHA with 28 KV heads. Its per-token cache would be 2 x 28 x 28 x 128 x 2 = 401,408 bytes, or 392 KiB. That is 7 times the GQA number. A 32K request would need 12.25 GiB instead of 1.75 GiB. GQA is doing a lot of quiet work in every modern long-context server.

How to split VRAM between weights, KV cache, and overhead

GPU memory splits into three parts: weights, KV cache, and overhead. The weights and overhead are roughly fixed. Whatever remains after them is the KV cache pool, and that pool sets your real context and concurrency.

Weights from the config

You can estimate weight size from the config. Count embedding and output matrices, attention matrices, MLP matrices, and norms, then multiply by bytes per parameter. In this example, that count gives about 7.62 billion parameters for Qwen2.5-7B-Instruct and about 14.77 billion for Qwen2.5-14B-Instruct-1M.

In BF16, at 2 bytes per parameter, that is about 14.19 GiB for the 7B model and about 27.51 GiB for the 14B model. These are illustrative estimates from the config shapes. Your engine's load log gives the exact figure, and weight quantization changes it.

Overhead you cannot skip

Overhead covers activation buffers for the largest batch step, CUDA graph memory, and the runtime itself. It varies by engine, batch size, and settings. Do not guess it once and forget it. Read it from the startup log and from a memory profile under peak load.

For the arithmetic below, suppose overhead is 1.5 GiB. That is an illustrative value only. Swap in your own observed number.

A worked budget

Suppose a 24 GiB card, a memory share of 0.90, and the 7B model in BF16. The engine may use 24 x 0.90 = 21.6 GiB. Take away 14.19 GiB of weights and 1.5 GiB of overhead. About 5.91 GiB is left for the KV cache.

At 56 KiB per token, 5.91 GiB holds about 110,000 tokens. That is about 3.4 full 32K requests, or less than one full 128K request. With an FP8 cache, the same pool holds about 221,000 tokens, or about 6.8 full 32K requests.

Illustrative setup (share 0.90, 1.5 GiB overhead) KV pool Tokens, BF16 cache Tokens, FP8 cache Full 32K requests, BF16 / FP8
7B on 24 GiB 5.91 GiB about 110,000 about 221,000 3.4 / 6.8
7B on 48 GiB 27.51 GiB about 515,000 about 1,030,000 15.7 / 31.4
14B-1M on 80 GiB 42.99 GiB about 235,000 about 470,000 7.2 / 14.3

Look at the 24 GiB row. Doubling the card to 48 GiB more than quadruples the cache pool. That is because the weight cost is fixed. Every extra GiB after the weights goes straight to the cache.

Where the budget leaks

Several things eat into the pool that a quick sum misses. Other processes on the same GPU take memory outside the engine's share. Tensor parallel splits weights and cache across cards but adds its own buffers. A large output limit reserves room even if most replies are short. Track all three.

PagedAttention and memory fragmentation

PagedAttention stores the KV cache in small fixed-size blocks instead of one long slab per request. That lets a server use nearly all of its cache pool. It is the core idea behind vLLM.

The problem it solves

Early servers gave each request one contiguous slab sized for the max context. A request that stopped after 50 tokens still held room for the full window. In this example, a 32K slab for the 7B model that holds only 50 tokens wastes about 1.75 GiB. The paper says this kind of memory can be significantly wasted by fragmentation and redundant duplication, limiting the batch size.

There are two kinds of waste. Internal waste is space reserved inside a request's slab but never used. External waste is free memory split into gaps too small for a new slab. Both cut the number of requests that fit.

How paging fixes it

PagedAttention is an attention algorithm inspired by the classical virtual memory and paging techniques in operating systems. The cache is cut into blocks of a fixed number of tokens. A block table maps each request's logical blocks to physical blocks anywhere in the pool.

A request takes a new block only when it fills its last one. So the most it can waste is the unused part of one block. The authors report near-zero waste in KV cache memory for vLLM.

Block size math

In vLLM, --block-size is the size of a contiguous cache block in number of tokens. As illustrative arithmetic, a 16 token block on the 7B model in BF16 holds 16 x 56 KiB = 896 KiB. On the 14B model it holds 3 MiB.

On average, a request wastes about half a block at its tail. For the 7B model with 16 token blocks, that is about 448 KiB per request. Even with hundreds of live requests, the waste stays small next to the pool. That is why the block size default is rarely the first thing to tune.

Sharing blocks

Paging also makes sharing cheap. The paper describes flexible sharing of KV cache within and across requests to further reduce memory usage. Two requests with the same prefix can point at the same physical blocks. This is the base for prefix caching, covered below.

Paging decides where blocks live. The scheduler decides which requests get blocks first. If you want the scheduling side, read our guide to continuous batching.

KV cache quantization with FP8 and KIVI

KV quantization stores keys and values in fewer bits. FP8 uses one byte per element and halves the cache versus BF16. Research methods such as KIVI go down to 2 bits. Fewer bits means more tokens per GiB, with some risk to quality.

FP8 in vLLM

The vLLM docs say quantizing the KV (Key-Value) cache to FP8 format can significantly reduce its memory footprint. They add that this lets you store more tokens in memory, leading to improved throughput and support for longer context windows.

You turn it on with --kv-cache-dtype. The engine arguments page lists choices that include auto, bfloat16, float16, fp8, fp8_e4m3, and fp8_e5m2. The list is long and changes between versions, so check the docs for the build you run.

One detail matters for testing. With the Flash Attention 3 backend and an FP8 cache, the docs note that queries are quantized to FP8 in addition to keys and values. So the attention math itself runs at lower precision. Test quality on the exact backend you will ship.

KIVI and 2-bit caches

KIVI is a tuning-free 2bit KV cache quantization algorithm. Its key finding is that keys and values need different treatment. The authors say the key cache should be quantized per-channel, while the value cache should be quantized per-token.

As reported in the paper, KIVI used 2.6 times less peak memory (including model weight) on the models they tested. They also report that this reduction in memory usage enables up to 4 times larger batch size. Those are the authors' results on their setups, not a promise for yours.

As illustrative arithmetic, 2 bits per element would cut the 7B model's 56 KiB per token to 7 KiB. That math ignores the scales and the small full-precision window that real methods keep. So treat 7 KiB as a floor, not a plan. KIVI is a research method, so check whether your serving engine supports it before you budget around it.

Choosing a cache precision

Cache type Bytes per element 7B per token 14B-1M per token When to use
BF16 or FP16 2 56 KiB 192 KiB Default; safest for quality
FP8 1 28 KiB 96 KiB Memory bound; after an eval pass
2-bit (KIVI style) 0.25 plus scales about 7 KiB floor about 24 KiB floor Research; only with engine support

The rule is simple. Start in BF16. Move to FP8 when memory is the limit and your evals pass. Treat anything below 8 bits as a project, not a flag.

Prefix caching and CPU offload tradeoffs

Prefix caching reuses cache blocks that requests share, such as a long system prompt. CPU offload parks cache or weights in host memory. Both stretch a fixed GPU, but in different ways and at different costs.

How prefix caching works

The vLLM docs say automatic prefix caching caches the KV cache of existing queries, so that a new query can directly reuse the KV cache if it shares the same prefix with one of the existing queries. The new request skips the prefill work for the shared part.

It shines when many requests start with the same text. Think of a long system prompt, a shared tool list, or many questions about one document. It does little when every prompt is unique. It saves compute and time to first token far more than it saves memory.

In vLLM, the switch is --enable-prefix-caching. The flag help reads whether to enable prefix caching. To get hits, put the stable text first and the changing text last. A single changed token early in the prompt breaks reuse for all that follows. Our post on measuring prompt cache coverage shows how to check hit rates on a hosted API, and the same habit applies here.

CPU offload options

vLLM has two related levers. --cpu-offload-gb sets the space in GiB to offload to CPU, per GPU. Default is 0, which means no offloading. It moves part of the model to host memory, which frees GPU memory that the cache pool can use.

There is also --kv-offloading-size. The docs say that when set, vLLM will enable KV cache offloading to CPU. This moves cache blocks, not weights, to host memory.

The cost of offload

Host memory is large and cheap. But every offloaded byte must cross the PCIe link to be used, and that link is far slower than GPU memory. Offloaded weights add delay to every forward pass. Offloaded cache adds delay when a parked request comes back.

So offload fits cold data. Idle chat sessions and long shared prefixes you will reuse later are good fits. The hot cache of requests that are decoding now should stay on the GPU. Measure tokens per second and time to first token with and without offload before you commit.

The vLLM flags that matter for KV memory

Five flags do most of the work: --gpu-memory-utilization, --max-model-len, --kv-cache-dtype, --enable-prefix-caching, and --block-size. Set them on purpose, and read the startup log to see the cache size they produce.

Flag What it controls Typical move
--gpu-memory-utilization Share of GPU memory one instance may use, from 0 to 1 Raise to grow the cache pool if nothing else shares the GPU
--max-model-len Context length, prompt plus output Lower it to what your users need
--kv-cache-dtype Cache precision Try fp8 after an eval pass
--enable-prefix-caching Reuse of shared prefix blocks Turn on when prompts share long prefixes
--block-size Tokens per cache block Leave at default unless you have a reason

gpu-memory-utilization

This is the fraction of GPU memory to be used for the model executor, which can range from 0 to 1. The docs add that this is a per-instance limit, and only applies to the current vLLM instance. Two instances on one card must split it between them.

max-model-len

This is the model context length (prompt and output). If you leave it unset, vLLM derives it from the model config. For the 14B-1M model, that default is huge. Set it to the length your product needs, not the length the model allows.

kv-cache-dtype, prefix caching, block size

The cache dtype sets bytes per element in the sizing formula. Prefix caching sets how much prefill you can reuse. Block size sets the paging granularity. Change one at a time and log the cache size and token capacity vLLM reports after each change.

A capacity-planning procedure for long-context serving

Capacity planning means turning a traffic target into a GPU plan with numbers you can check. The steps below take you from a config file to a tested launch.

  1. Read the config. Note layers, attention heads, KV heads, hidden size, and any head_dim field.
  2. Compute bytes per token. Use 2 x layers x KV heads x head dimension x bytes per element. Do it for BF16 and FP8.
  3. Set the real context need. Look at your prompt and output length logs. Pick a max that covers your long tail, not the model's max.
  4. Set the concurrency target. Decide how many requests must run at once at peak.
  5. Compute the cache need. Multiply bytes per token by the max context and the concurrency. That is your upper bound.
  6. Estimate weights and overhead. Use the load log for weights. Use a profile under load for overhead.
  7. Compare need with pool. Pool equals GPU memory x utilization share, minus weights, minus overhead. If need exceeds pool, change something.
  8. Pick levers in order. Lower --max-model-len, then try an FP8 cache, then add GPUs or tensor parallel, then consider offload.
  9. Launch and read the log. Confirm the cache size and max concurrency the engine reports match your math.
  10. Load test with real lengths. Replay real prompt lengths, not a fixed short prompt, and watch queueing and preemption.

Check quality, not just fit

Fitting a long context in memory does not mean the model uses it well. Pair this plan with a test of real recall at length. Our guide on effective context length shows how to test that before you pay for the memory.

When a smaller local model is the answer

Sometimes the cheapest plan is to keep the long-context work small. A 7B model at 56 KiB per token holds far more context per GiB than a 14B model at 192 KiB. You can route the hard cases to a larger or hosted model. Our post on LLM cascades with frontier escalation covers that design.

Failure modes and how to detect them

Most KV memory failures show up as slow or failed requests, not crashes. Each has a signal you can watch.

Startup fails to fit max-model-len

Symptom: the engine refuses to start, or warns that the cache cannot hold one full request. Cause: the max context times bytes per token exceeds the pool. Fix: lower --max-model-len, use an FP8 cache, or add GPUs.

Queueing and preemption at peak

Symptom: time to first token jumps under load while GPU compute looks idle. Cause: the cache pool is full, so new requests wait or running ones are paused. Detect: watch cache usage and the count of waiting requests in the engine metrics. Our post on time to first token vs throughput explains why these two numbers move against each other.

Out of memory after a change

Symptom: memory errors appear after you raise batch limits or add a second process. Cause: overhead grew, or another process took memory outside the engine's share. Detect: compare nvidia-smi totals with the engine's own budget.

Quality drops after quantization

Symptom: answers at long length get worse after a switch to FP8. Cause: lower precision in keys, values, or queries. Detect: run the same long-context eval set with both cache types and compare.

Prefix cache misses

Symptom: prefix caching is on, but prefill time does not fall. Cause: prompts differ early, so no blocks match. Detect: log prompt prefixes and check the hit rate. Move changing fields to the end.

Offload stalls

Symptom: decode speed drops sharply after you enable offload. Cause: hot data now crosses the PCIe link. Detect: compare tokens per second with offload on and off at the same load.

KV cache budgeting checklist

Use this list before every launch or model change.

  • Head dimension computed from the config, not assumed.
  • Bytes per token computed with KV heads, not query heads.
  • Cache need computed for real max context and peak concurrency.
  • Weights and overhead read from logs, not guessed.
  • --max-model-len set to the product need.
  • --gpu-memory-utilization set with other GPU users in mind.
  • FP8 cache tested on your own evals before rollout.
  • Prefix caching on only when prompts share long prefixes.
  • Offload limited to cold data, with latency measured.
  • Load test run with real prompt lengths.

sinc-LLM helps teams design and test this kind of serving plan. The math is simple, but only if every input comes from a config, a log, or a test you ran yourself.

Frequently asked questions

How do I calculate KV cache size per token?

Multiply 2 by the number of layers, the number of KV heads, the head dimension, and the bytes per element. The 2 covers keys and values. Take layers and KV heads from the model config, and get head dimension by dividing hidden size by the number of attention heads. Then multiply by the tokens you plan to hold across all live requests to get the total cache size.

How much KV cache does Qwen2.5-7B-Instruct need at 32K tokens?

Its config lists 28 layers, 4 KV heads, and a head dimension of 128 (3584 divided by 28). In BF16 that is 57,344 bytes, or 56 KiB, per token. A full 32,768 token request therefore needs 1.75 GiB of cache. With an FP8 cache it needs 0.875 GiB. These are exact arithmetic results from the published config, not measured numbers.

Why does a one million token context need so much memory?

The cache grows in a straight line with tokens. Qwen2.5-14B-Instruct-1M stores 192 KiB per token in BF16, because it has 48 layers and 8 KV heads of size 128. One million tokens times 192 KiB is about 183 GiB for a single request, which is more than one 80 GB GPU holds. FP8 cuts that to about 92 GiB, which is still more than one 80 GB GPU holds, so you need at least two.

Does FP8 KV cache hurt model quality?

It can, so you should test it on your own tasks. FP8 halves cache memory compared with BF16, which lets you hold twice the tokens. The vLLM docs say it improves throughput and supports longer context. Run your long-context evals with the BF16 cache and the FP8 cache, and compare answers on the same prompts before you switch production traffic.

What does gpu-memory-utilization do in vLLM?

It sets the fraction of GPU memory, from 0 to 1, that one vLLM instance may use. vLLM loads the weights and reserves working space inside that budget, and whatever is left becomes the KV cache pool. Raising the value gives more cache but less room for other processes. It is a per-instance limit, so two instances on one GPU need separate shares.

Is prefix caching the same as a bigger KV cache?

No. Prefix caching reuses cache blocks that requests already computed for a shared prefix, such as a long system prompt. It saves prefill compute and lets many requests point at the same blocks. It does not add memory. If your prompts share little text, prefix caching gives little benefit, and the cache pool size stays the limit.

When should I offload the KV cache to CPU memory?

Offload when you have idle sessions or long prefixes you will reuse later and can accept slower access. CPU memory is larger and cheaper, but moving blocks over the PCIe bus is much slower than reading GPU memory. Offload works best for parked data. It is a poor fit for the hot cache of requests that are decoding right now.

Sources

  1. Efficient Memory Management for Large Language Model Serving with PagedAttention: PagedAttention and vLLM: fragmentation, paging, and KV block sharing.
  2. GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints: Grouped-query attention and the tradeoff between MHA and MQA.
  3. Fast Transformer Decoding: One Write-Head is All You Need: The original multi-query attention paper.
  4. KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache: 2-bit KV cache quantization with per-channel keys and per-token values.
  5. Qwen2.5-1M Technical Report: How Qwen extended context to one million tokens and served it.
  6. vLLM: Quantized KV Cache: FP8 KV cache support in vLLM.
  7. vLLM: Engine Arguments: Flags for memory use, context length, cache dtype, block size, and offload.
  8. vLLM: Automatic Prefix Caching: How vLLM reuses KV cache for shared prefixes.
  9. Qwen2.5-14B-Instruct-1M config.json: Layer, head, and context values used in the worked examples.
  10. Qwen2.5-7B-Instruct config.json: Layer, head, and context values used in the worked examples.
  11. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness: Why attention is bound by memory traffic between HBM and SRAM.
Original source record

Skip to content

sinc-LLMAboutBlogServices