Back to course syllabus
Automate with permission, recovery, and cost controlsIf needed: model and deployment · 2 / 10

How much VRAM does a local LLM need? Budget weights and KV cache

Estimate raw model weights and KV cache separately, test context length and concurrency, then measure the missing peak costs on your serving stack.

DECISION TOPICLocal model deployment
LESSON OUTPUT · VRAM budget and peak testUPDATED · Oct 1, 2026
PATH READ0 / 10
HOW TO USE THIS LESSON

Read with one real task in mind, then complete the workbench. The lesson is done when another person can review what you made.

A local model can fail to start even when the weight file looks smaller than the GPU’s advertised memory. The file is only one part of the running process. Generated tokens keep key and value tensors; concurrent requests keep their own cache; the framework also needs buffers and memory for work that this page cannot infer from a model name.

Use the calculator below as a bounded arithmetic check, not a fit certificate. It answers a useful first question: do the raw weights plus a conventional KV cache already exceed the physical VRAM entered for one GPU? Only that condition rules out full residency under the stated single-GPU assumptions. Crossing a separate reserve line means the plan missed your preferred margin; neither result below physical capacity proves the model will run.

Read the model configuration before calculating

The input called “14B” is a rounded family name, not enough for a memory budget. Record the model version, total parameter count, number of transformer layers, number of KV heads, and dimension of each head. The last three describe the shape of a conventional attention cache. For a model with grouped-query attention, use KV heads, not query heads.

The official Qwen2.5-14B-Instruct card reports 14.7 billion parameters, 48 layers, 40 attention heads and 8 KV heads. Its configuration reports a hidden size of 5,120, so 5,120 ÷ 40 gives a head dimension of 128. These values make a reproducible example. Another model, revision, adapter, or serving format needs its own checked configuration.

Keep weight and cache arithmetic separate

The calculator uses these raw payload equations, with decimal billions for the parameter count:

TermCalculationWhat it covers
Weight bytesparameters in billions × 1,000,000,000 × weight bits ÷ 8A theoretical value for all named parameters at one bit width
KV cache bytes2 × layers × KV heads × head dimension × bytes per KV element × cached tokens per request × resident requestsConventional full-attention K and V tensor elements

“Cached tokens” means the peak input plus generated token slots held for a request, not just the prompt length. Concurrency means requests resident at the same time. If requests have different lengths, add their cached token counts rather than multiplying one average by the number of requests. The form deliberately assumes each request reaches the same entered peak; that makes the load assumption visible.

Results show GiB and GB because they are different units: 1 GiB is 1,073,741,824 bytes; 1 GB is 1,000,000,000 bytes. Enter the GPU’s actually reported usable physical capacity in GiB, or convert a decimal GB specification before entering it. The calculator shows physical capacity minus known terms separately from your planning line. The prefilled 4 GiB reserve is just a worked assumption that you may change; it is not an official or universal overhead coefficient.

Example: BF16 versus 4-bit for four Qwen requests

For the official Qwen2.5-14B-Instruct values above, BF16 weights have a raw payload of 27.38 GiB. Each 8,192-token request with 16-bit KV values adds 1.50 GiB. Four resident requests bring KV to 6.00 GiB and the known total to 33.38 GiB, already more than an entered 24 GiB of physically available VRAM. Full single-GPU residency with those exact assumptions is ruled out before runtime overhead is added.

Choosing “4-bit” changes only raw weight arithmetic: 14.7 billion parameters at four bits produce 6.85 GiB of raw weights, or 12.85 GiB with the unchanged four-request KV cache. That falls below 24 GiB physical capacity and a separate 20 GiB planning line after an illustrative 4 GiB reserve. A real 4-bit package can hold scales, zero points, grouping metadata, and tensors at other precisions. Neither positive margin proves full residency, speed, or task quality.

Example: 16 concurrent requests change the answer

Keep 4-bit raw weights and 8,192 cached tokens per request, but make 16 requests resident. One request’s KV cache is still 1.50 GiB; concurrent KV rises to 24.00 GiB. Added to 6.85 GiB of raw weights, the known total is 30.85 GiB, above even the entered 24 GiB physical capacity. Reducing weight precision did not cancel the cache load created by concurrency.

Qwen2.5-14B-Instruct scenarioRaw weightsKV per requestConcurrent KVKnown total24 GiB physical minus known
BF16, 4 requests27.38 GiB1.50 GiB6.00 GiB33.38 GiB−9.38 GiB
4-bit raw, 4 requests6.85 GiB1.50 GiB6.00 GiB12.85 GiB+11.15 GiB
4-bit raw, 16 requests6.85 GiB1.50 GiB24.00 GiB30.85 GiB−6.85 GiB

The table remains readable without JavaScript. The calculator’s three presets reproduce these cases; you can then replace the model dimensions and load with your own values.

Measure the costs the formula leaves out

Run the same model revision, quantization format, server version, target context and concurrent load you plan to use. Record a cold load, warm requests, peak GPU allocation or device memory, out-of-memory events, first-token latency and sustained throughput. PyTorch exposes a peak allocated-memory counter, but that counter alone does not describe every CUDA, framework, or device allocation; also inspect the GPU’s reported usage. Keep the batch and cache settings beside each result so another person can repeat it.

Write down whether the model and active cache were fully resident on this GPU. If the server silently offloads to CPU or distributes tensors across devices, a “fit” observation answers a different question. Treat a reported free margin as a trigger for the peak test, and keep the measured margin for traffic spikes and software updates.

Common questions

Can the weight file size replace the parameter calculation? It is useful evidence for a specific artifact, but compression, serialization, shards, and mixed precision affect disk size. Measure loaded device memory for the exact artifact.

Does an 8-bit KV setting always halve memory? The raw KV element term halves when one byte replaces two. Cache blocks, scales, supported kernels, quality, and the rest of the process do not automatically halve.

Can I add several GPUs together? This calculator models one GPU and does not assign layers, weights, or KV across devices. A distributed plan needs per-device placement and measured communication overhead.

Boundary

Use this calculation for dense decoder models with a conventional per-layer K/V cache and a known single-GPU placement. It does not model mixture-of-experts active and total parameter behavior, multi-head latent attention, sliding-window or hybrid cache layouts, speculative decoding, multimodal tensors, adapters, CPU offload, tensor or pipeline parallelism, or training. A positive remaining budget is never proof that the model will run. The workbench below records the missing configuration and the real peak test that can resolve that uncertainty.

SOURCES CHECKED

Which first-party sources informed this guide?

Sources anchor definitions, risk boundaries, or operational facts. The decision framework and workbench are original to AI Vista.

  1. Qwen2.5-14B-Instruct official model cardChecked 2026-10-01
  2. Qwen2.5-14B-Instruct official configurationChecked 2026-10-01
  3. Hugging Face KV cache explanationChecked 2026-10-01
  4. PyTorch CUDA peak allocated memory referenceChecked 2026-10-01

AI tools may assist with research, outlining, and language editing. Facts, cases, and final wording are reviewed by the editor. Report an error through the contact page.

INTERACTIVE WORKBENCH / VRAM BUDGET

Estimate visible payloads, then measure the peak

Enter a model configuration and a budget for one GPU. Weight and KV cache payloads are separate; a number below budget still needs a real peak-memory test.

TRY THREE SCENARIOS
01Model and precision
Use the total parameter count from the model card.
Excludes quantization scales, zero points, and unquantized layers.
02KV cache shape and load
Qwen example: 5,120 hidden dimensions ÷ 40 attention heads = 128.
Verify that the serving stack supports the selected KV format.
Use peak cached input plus generated tokens.
Assumes every resident request reaches that token count.
03Single-GPU planning budget
Enter the reported usable value; convert any GB specification first.
The prefilled 4 GiB is an illustrative choice, not an official or universal factor.

Prefilled example: official Qwen2.5-14B-Instruct model card and config, 8,192 tokens per request and four resident requests; the reserve is illustrative.

RAW TENSOR PAYLOAD / THEORETICALGiB is binary; GB is decimal
Weights
27.38 GiB · 29.40 GB
KV cache per request
1.50 GiB · 1.61 GB
KV cache across requests
6.00 GiB · 6.44 GB
Combined
33.38 GiB · 35.84 GB
Entered physical VRAM
24.00 GiB · 25.77 GB
Physical VRAM minus known payloads
-9.38 GiB · -10.07 GB
Planning line after your reserve
20.00 GiB · 21.47 GB

Raw known payloads exceed the entered physical VRAM. Full residency is impossible under this single-GPU assumption; measure any revised deployment.

Omitted: quantization metadata, other model tensors, framework and CUDA use, activations, temporary buffers, fragmentation, and cache allocation policy. 1 GiB = 1,073,741,824 bytes; 1 GB = 1,000,000,000 bytes.

TAKEAWAY TOOL

Single-GPU VRAM budget and peak test

Carry the raw estimate into a reproducible deployment test.

vram / budget
USE THIS WHENBefore choosing hardware or raising local-model concurrency
YOU WILL GETA bounded raw-memory estimate plus a measured single-GPU deployment decision
HOW TO USE01—03
  1. 01
    Describe the taskDescribe the result with a sanitized summary.
  2. 02
    Fill the decision fieldsRecord input categories, risk, evidence pointers, and handoff.
  3. 03
    Ask a colleague to reviewThe tool is ready when someone else can restate the decision.
DONE WHENFields are complete, boundaries are clear, and the result is reviewable.
Edits save automatically

LESSON READ

Finish the workbench, then mark it read.

The read state updates the syllabus and your course progress.

  1. 01Fields filled
  2. 02Case tested
  3. 03Reviewable

GUIDE PRACTICE NOTES

Leave a judgment you can review later.

The fictional examples below show the format. Your own notes stay in this browser. Record what worked, which boundary failed, or one question worth testing.

↗
RELATED GUIDEHow much VRAM does a local LLM need? Budget weights and KV cacheSee examples and local notes →
0 examples and local notesINSIGHTS · QUESTIONS · IDEAS