How to choose a local LLM: VRAM, context length, and quantization
Choose a local model that fits the whole workload, not just its weights. Includes memory arithmetic, an Ollama configuration example, and a diagnostic decision table.
Sources are linked in the guide. Read our editorial policy.
On this page 5 sections
Choose the smallest local model that satisfies your task at the context length and concurrency you actually need. A model file fitting on disk—or even in VRAM—does not establish that your full workload will fit or feel responsive. Budget for weights, working memory, context cache, and simultaneous requests.
This is a selection process, not a fastest-model ranking. No benchmarks were run for this guide, and hardware anecdotes from social posts are not treated as performance guarantees.
Start with the local AI learning path if you are choosing a workflow. Use the VRAM calculator to adjust weights, cache architecture, context, and concurrency; its estimate is a planning aid, not a measured allocation.
Filter for the task before counting gigabytes
Start with a concrete job: extracting fields from short documents, explaining code, generating patches, or answering questions over a long document. These jobs have different quality and context requirements.
Read the publisher’s model card for intended use, limitations, license, supported languages, and the actual model variant. Hugging Face’s model-card documentation explains the metadata, including base-model relationships and licenses. A community quantization may be derived from a different checkpoint than you expected; inspect its provenance rather than trusting a similar name.
For tool-using agents, verify the model and runtime support the required tool-call format. Text generation alone does not establish reliable tool selection. For commercial work, downloadable weights do not automatically imply unrestricted commercial permission.
The text-generation directory is a discovery starting point. Return to the publisher’s current card before downloading or deploying.
Estimate weights, then leave room for the workload
A simplified lower-bound calculation is:
weight bytes ≈ parameter count × bits per parameter ÷ 8
For an illustrative dense 8-billion-parameter model at exactly four bits per parameter, that is 4 billion bytes, or about 3.73 GiB. This is arithmetic, not a claim that a particular 8B model requires only 3.73 GiB of VRAM.
Real formats add scales, metadata, mixed-precision tensors, and other overhead. The runtime needs buffers, and the context cache consumes additional memory. Available VRAM is also lower than the GPU’s nominal capacity when other applications are using it.
Mixture-of-experts models add another trap: the number of parameters active per token is not the same as the full weight-storage requirement. Do not size a machine using only an “active parameters” headline. CPU offloading can make a larger model runnable, but it changes the latency and memory-bandwidth tradeoff.
Set context explicitly instead of trusting defaults
Ollama’s context-length documentation says larger context requires more memory. Its context page and FAQ describe defaults differently, so do not assume a universal default across versions and hardware. Set the value deliberately and inspect the loaded model.
The following is an illustrative Unix-shell request using the model name from Ollama’s FAQ. It is a small functional starting point, not a coding-agent recommendation or measured performance configuration:
ollama pull llama3.2
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Explain the difference between a process and a thread.",
"stream": false,
"options": {
"num_ctx": 8192,
"num_predict": 256,
"temperature": 0
}
}'
ollama ps
Use a context within the model’s supported range. For reproducibility, record the resolved model ID and runtime version; a mutable tag alone is insufficient. Temperature zero reduces sampling variation but does not guarantee identical output across all backends.
In ollama ps, inspect the allocated context and PROCESSOR split. Partial CPU/GPU loading is a useful explanation for latency, not necessarily an error. Ollama’s context page recommends at least 64,000 tokens for large-context agent and coding workloads; an 8,192-token configuration cannot stand in for evaluating that workload.
If the loaded model uses the CPU unexpectedly, follow the Ollama GPU diagnostic before changing drivers or reinstalling the runtime.
Change one resource lever at a time
| Observation | First action | Tradeoff to evaluate |
|---|---|---|
| Model cannot load | Close competing workloads or choose a smaller model/weight quantization | Reduced model capacity or quantization quality |
| Short prompt works; long prompt fails | Lower configured context and inspect memory usage | Less source material available per request |
| One request works; concurrent requests fail | Reduce parallel requests and loaded models | Lower throughput, potentially more queuing |
| Generation is slow with CPU offloading | Try a model that fits fully on the supported GPU | Smaller model may reduce answer quality |
| Plenty of memory, but answers are poor | Check chat template, task fit, and representative examples | More memory may not address the cause |
The Ollama FAQ explains that parallel requests increase context-memory allocation. A model working in a one-user demo does not establish capacity for several simultaneous users.
Weight quantization and KV-cache quantization are separate settings. Ollama documents cache types such as f16, q8_0, and q4_0, with memory/precision tradeoffs and backend requirements. Evaluate cache changes on long examples; do not assume their impact is identical across model architectures.
Measure quality and latency separately
Prepare a small set of real, non-sensitive examples with known acceptable outcomes. Include your longest likely input, a refusal or invalid-input case where relevant, and the tool-call shape your application requires.
Record correctness, wall-clock latency, peak memory, context setting, model ID, and concurrency. Separate a cold load from a warm request. The generation API reports load and evaluation durations; generation tokens per second can be calculated as eval_count / eval_duration × 1e9 because duration is in nanoseconds. That rate excludes important parts of end-to-end latency and says nothing about correctness.
Finally, local execution is not automatically private end to end. Check editor extensions, remote connectors, cloud-model selection, and logging. Follow the MCP checklist for integrations, the context diagnostic flow for oversized inputs, and the coding-agent workflow for task-level acceptance.
Research note: X search surfaced local-inference hardware discussions, but direct thread access was blocked. Their unverified model and speed claims are intentionally not reproduced.