# AI model local deployment: budget the KV cache, not just the weights

- **Canonical URL:** https://www.probackend.com/ai-local-model-deployment/ai-model-local-deployment-budget-the-kv-cache-not-just-the-weights
- **Section:** AI Models
- **Published:** 2026-11-30
- **Summary:** Learn how to deploy an AI model locally while budgeting KV-cache memory: a November 2026 RTX 4070 benchmark shows context can exceed VRAM before weights do.

---

## AI model local deployment: context is a memory budget

The weights fit. The context doesn't.

That is the practical result from a November 2026 workstation benchmark: Hy-MT3-7B Q4_K_M has 5.1 GB of weights, but on an RTX 4070 12 GB it exceeded the machine's stated 11,258 MiB usable budget at both 131072 and 81920 context. It held at 71680, where the measured footprint was 10,577 MiB. If you are asking how to deploy an AI model locally, that difference matters more than the model-card headline. A model that loads is not necessarily a model that can serve the context your application needs.

The benchmark points to the KV cache as the moving cost. Weights are a fixed residency cost; the cache grows as the sequence grows. With q8_0 KV enabled in this test, cache demand was reduced, not erased. The decision is therefore not simply “does the GGUF fit?” It is “does the full inference workload fit at the context I intend to use?”

## What the 12 GB card actually held

The RTX 4070 results are a set of context rungs, not a general GPU ranking. Hy-MT3-7B Q4_K_M measured 11,975 MiB at 131072 and 11,313 MiB at 81920. Both are above the bench's stated 11,258 MiB budget. At 71680, the footprint was 10,577 MiB and the configuration held. K2-Horizon-7B Q4_K_M showed the same demand pattern and also topped out at 71680.

The contrast is useful. Ternary-Bonsai-2.5-27B Q2_0 reached 81920 at 11,067 MiB, a practical edge for this card in this run. Ornith-1.5-9B Q4_K_M reached the full 131072 window at 8,491 MiB. Ling-3.0-tiny Q4_K_M also reached 131072, at 6,043 MiB. Parameter count alone doesn't predict the usable context ceiling across these model and quantization combinations.

That isn't a claim that the larger model is universally easier to run. The numbers describe these specific builds and settings. But they do make one point plainly: a small weight file can leave too little headroom for a requested context, while a different model/quantization combination can fit a longer one.

## Why the KV cache changes with context

Autoregressive generation processes tokens in sequence. Rather than recompute the past at each step, inference keeps the past keys and values available in a KV cache. The CAS-NLP tutorial describes those tensors as stored separately per layer, with cost proportional to layers, batch size, attention heads, sequence length, and head dimension. Sequence length is the lever that matters here: as more context is retained, more cache storage is required. [CAS-NLP's KV-cache walkthrough](https://cas.org.pk/nlp-series/kv-cache) lays out the mechanism and the per-layer accounting.

This is why quantizing weights does not settle the VRAM question. Weight quantization changes the fixed model-residency cost. The cache has its own footprint and continues to grow with context. The bench used q8_0 KV, but even that setting did not make the 131072 or 81920 Hy-MT3 configurations fit inside the stated budget. A compressed cache is still a cache with a context-dependent cost.

The [Transformers quantization overview](https://huggingface.co/docs/transformers/main/en/quantization/overview) describes quantization configurations for loading model weights and notes that GGUF checkpoints bundle weights, configuration, and tokenizer. That packaging is useful for deployment, but a compact GGUF should not be mistaken for a complete estimate of runtime memory. The weight artifact is only one part of the live workload.

## Context capacity is not the same as useful context

There is a second limit after memory: whether the model makes good use of the available window. In *Lost in the Middle*, researchers tested multi-document question answering and key-value retrieval and found that performance can depend on where relevant information appears. Models often performed better when information was near the beginning or end, with degradation when it was in the middle of long inputs. The result is not a measurement of this workstation or these models, but it is a useful caution against treating a larger context setting as automatic application value. [The paper](https://arxiv.org/abs/2307.03172) reports the positional effect directly.

So plan for two ceilings. One is technical: can weights, cache, and runtime overhead coexist in available memory? The other is product-level: does the model reliably use the information your application places in the window? More context can be necessary, but it is not a substitute for testing retrieval quality and prompt structure.

## A practical way to deploy an AI model locally

Start from the intended workload, not the weight size. Choose the model and quantization, then measure the exact serving configuration at the context length you need. Record the cache type, batch or parallel sequence setting, attention options, and the memory available to the process. Lower the context rung if the complete configuration crosses the device budget; don't assume a load that succeeds at a short prompt will remain stable at the production window.

For local inference, [llama.cpp](https://github.com/ggml-org/llama.cpp) provides an inference runtime for a range of hardware, with repository documentation covering topics such as performance troubleshooting and multi-GPU use. The runtime choice is part of the deployment setup, not a guarantee that two systems will have identical memory behavior. Pin the build and settings you test, and keep a record of the actual context and footprint. For another measured local-deployment example, see [AI Model Local Deployment: Long-Context Fit on the R9700, Measured](/articles/assessing-long-context-model-memory-budgets-and).

The benchmark's other card is a reminder to measure rather than extrapolate. On the Radeon AI PRO R9700 32 GB Vulkan system, every tested model reached 131072 except Ling-3.0-tiny Q8_0. For that same window, its Vulkan footprint was 16,155 MiB versus 9,345 MiB on CUDA. That is a notable backend difference within this test, not a basis for a general claim that one backend or vendor always uses more memory.

## Setup and limits of this evidence

**Setup.** Two-card workstation with an RTX 4070 12 GB (CUDA) and Radeon AI PRO R9700 32 GB (Vulkan), running llama.cpp. Models tested were Ornith-1.5-9B Q4_K_M, Ling-3.0-tiny Q4_K_M and Q8_0, K2-Horizon-7B Q4_K_M, Ternary-Bonsai-2.5-27B Q2_0, and Hy-MT3-7B Q4_K_M. The tests were run in November 2026 with `-np 1`, q8_0 KV, flash attention enabled, 2048 ubatch, and the largest context that fit from the 131072 → 81920 → 71680 ladder.

These are the authors' own measurements. Raw logs and configuration files are not publicly linked, and independent replication is not implied. Verify the logs, artifact identities, configuration, methodology, and date before citing the result. The bench is one workstation, one server build, and one test suite on the stated date. Results vary with hardware, software version, settings, and load. They are not a general ranking or a recommendation.

The operational takeaway is narrower, and stronger: budget the cache alongside the weights. For this particular RTX 4070 test, a 5.1 GB weight footprint did not buy Hy-MT3-7B a 131072 or 81920 context. The held context was 71680. That is the figure to plan around if the same setup is your reference—not the number printed on the model file.

![ai model local deployment](https://assets.probackend.com/91f7b203-1b1b-475a-908c-285d63756a20?token=ast_7b9ee8975a4b187969d396286e3f9717c42f2331)
