How Unified Memory Eases the VRAM Bottleneck for Local LLMs
Unified memory can increase the maximum model size a local device can load, but it does not remove bandwidth or software-stack limitations. This guide explains how to estimate available memory, model weight usage, KV cache requirements, and theoretical decoding speed before testing a local LLM deployment. It also covers loading checks, common failures, and when cloud collaboration may be more practical.
Key Takeaway
Unified memory can raise the upper limit of models that can be loaded locally, but it cannot eliminate bandwidth and software-stack constraints. A model fitting into memory does not necessarily run quickly. To evaluate whether a device is suitable, calculate the memory budget first, estimate performance second, and validate the results with real-world testing.
The hardware figures in this article come from the original source material and have not been independently tested. All speed figures are theoretical estimates rather than benchmark results. Always verify the manufacturer’s official specifications before purchasing hardware.
1. Where the VRAM Bottleneck Comes From
A discrete GPU has its own VRAM, which is separate from system memory. Model weights must be transferred from system memory to VRAM over the PCIe bus, adding latency. Model size is also typically limited by the GPU’s available VRAM. For example, a 24 GB GPU generally cannot load a roughly 70B-parameter model quantized to 8-bit precision.
A unified memory architecture allows the CPU, GPU, and NPU to access the same physical memory pool. Weights do not need to be copied between two separate memory pools, and applications do not need to perform repeated explicit transfers. This provides two direct benefits:
- The usable memory capacity for the model becomes larger.
- Data-transfer overhead is reduced.
Unified memory still has two important limitations.
First, all processing units share the same memory bandwidth. During inference, simultaneous access by the CPU, GPU, and NPU can create contention.
Second, a larger memory capacity does not mean higher bandwidth. During decoding, every generated token requires reading most of the model weights. As a result, bandwidth often becomes the performance bottleneck before capacity does.
2. From 192 GB to 160 GB: Estimating Allocatable Memory
The original specifications list 192 GB of total memory. The operating system, background processes, and other applications also consume memory, so the amount available for the model will be lower. This article uses 160 GB as the allocatable limit, based on an assumption in the original material. You should verify the actual value on your own device.
A basic estimate is:
Allocatable memory ≈ Total unified memory − System and application reserve − Safety margin
On an actual device, use the operating system’s memory-monitoring tools to check the current available limit, and replace the assumed 160 GB with that value.
3. Estimating Weight Memory Usage
The memory required by a quantized model’s weights can be estimated with the following formula:
Weight usage (GB) ≈ Parameter count (B) × Quantization bits ÷ 8
The parameter count is expressed in billions, and the quantization width is expressed in bits. Actual model files also include metadata and overhead from quantization groups. For a more conservative estimate, multiply the result by 1.05 to 1.1.
| Model size | Quantization | Estimated weight usage | Status with 160 GB of allocatable memory |
|---|---|---|---|
| 70B | 4-bit | Approximately 35 GB | Fits with substantial headroom |
| 70B | 8-bit | Approximately 70 GB | Fits |
| 120B | 4-bit | Approximately 60 GB | Fits |
| 120B | 8-bit | Approximately 120 GB | Fits, but context length must be tightly controlled |
| 235B, sparsely activated | 4-bit | Approximately 118 GB | Fits, but leaves little room for KV cache; suitable only for short contexts |
| 405B | 4-bit | Approximately 203 GB | Does not fit |
A sparsely activated model uses only a subset of its experts for each token, but the complete set of weights must still be loaded. Memory capacity must therefore be calculated using the total parameter count.
4. Budgeting for the KV Cache
KV cache usage grows linearly with context length and consumes memory alongside the model weights. An estimate can be calculated as follows:
KV cache (bytes) ≈ 2 × Number of layers × Number of KV heads × Head dimension × Context length × Bytes per element
The factor of 2 represents the separate Key and Value caches.
Consider the following example: 80 layers, 8 KV heads, a head dimension of 128, FP16 cache values using 2 bytes per element, and a context length of 32,768 tokens.
Cache usage per token:
2 × 80 × 8 × 128 × 2 = 327,680 bytes
This is approximately 0.31 MB per token.
For 32,768 tokens:
327,680 × 32,768 ≈ 10.7 GB
Use the following process when planning the memory budget:
- Subtract estimated weight usage from allocatable memory.
- Reserve approximately 10% of the remaining memory as a computation buffer.
- Use the remaining amount as the KV cache budget.
- Divide the KV cache budget by the per-token cache usage to estimate the maximum context length.
For a 70B model using 8-bit weights:
- 160 GB − 70 GB for weights = 90 GB remaining.
- After reserving 10% as a buffer, approximately 81 GB remains for the KV cache.
- At approximately 0.31 MB per token, the theoretical context capacity is about 240,000 tokens.
In practice, the number of layers, KV heads, and other parameters must be read from the model’s configuration file. Do not apply the example values directly to every model.
5. Theoretical Decoding Speed
During token generation, the decoding stage usually needs to read nearly the entire set of model weights for each token. A rough upper-bound estimate is:
Theoretical decoding speed (tokens/s) ≈ Effective memory bandwidth (GB/s) ÷ Weight data read per token (GB)
For a dense model, the weight data read per token is approximately the size of the entire weight file. For a sparsely activated model, it is the size of the portion of parameters activated for each token.
Assume a 70B model quantized to 4-bit precision, with approximately 35 GB of weights and an effective memory bandwidth of 200 GB/s. This bandwidth is only an example assumption, not a measured result for a specific device:
200 ÷ 35 ≈ 5.7 tokens/s
This is only a theoretical upper bound. Actual performance can be lower because of compute limitations, KV cache access, software scheduling, and contention from concurrent workloads.
6. Pre-Loading Checklist
Before loading a model, verify each of the following:
- The operating system, GPU driver, or NPU driver is compatible with the inference framework.
- The inference framework supports unified memory or the relevant GPU acceleration backend on the target platform.
- Available memory is sufficient for the combined weight and KV cache budgets.
- The model files are complete, and their checksums match the values published by the model provider.
- Background applications with high memory usage have been closed.
7. Example Loading Code
The following example uses llama-cpp-python. Install a build compiled with support for the required acceleration backend first. Adjust the model path and context length for your environment.
from llama_cpp import Llamallm = Llama(model_path="/path/to/model-q4_k_m.gguf",n_gpu_layers=-1, # Try to place all layers on the acceleration backendn_ctx=8192, # Start testing with a smaller contextverbose=True,)out = llm("Explain the advantages and disadvantages of unified memory in three sentences.", max_tokens=200)print(out["choices"][0]["text"])
Start with an 8,192-token context and confirm that the model runs correctly before increasing it gradually. Each time you increase the context length, monitor the memory-usage curve.
8. Common Problems and Troubleshooting Order
1. Out-of-memory errors during loading
First, verify the weight-size estimate. Then try a lower quantization width, close other applications, and check whether other processes are consuming unified memory.
2. Loading succeeds, but the process crashes during a long conversation
The KV cache has likely exceeded the available budget. Reduce the context length, use a lower-precision KV cache if supported, or reduce the number of concurrent requests.
3. The model runs, but performance is far below the estimate
First check whether all layers are running on the acceleration backend instead of falling back to the CPU. Then determine whether other workloads are consuming the available memory bandwidth. Finally, confirm that the inference framework has enabled the appropriate compute kernels.
4. Output quality is abnormal
Verify that the model file matches the intended quantization format, and check that the correct prompt template is being used.
The recommended troubleshooting order is:
- Check the memory budget.
- Confirm that the intended acceleration backend is active.
- Investigate performance and output quality.
9. When to Use Cloud Collaboration
Local hardware is well suited to privacy-sensitive data, low-latency interactive tasks, and everyday use of small and medium-sized models. Models that exceed the device’s loading capacity, as well as high-throughput batch workloads, may be better handled in the cloud.
One possible workflow is:
- Use a local model to create drafts, generate summaries, and preprocess sensitive data.
- After de-identification, send complex reasoning or very long-context tasks to a cloud-based model.
- Return the cloud result to the local environment for review and final formatting.
When combining local and cloud inference, apply data de-identification and transport encryption. Also review the cloud provider’s data-retention policy in advance.
10. Is This Device Suitable for Your Workload?
- If your primary models are no larger than 120B parameters and use 4-bit or 8-bit quantization, a 192 GB unified-memory platform provides substantial loading capacity.
- If speed is your main concern, estimate performance with the bandwidth formula above, then validate it with real measurements.
- If your workload depends on models in the 405B class, loading them on a single local device is not realistic. Consider cloud inference or a multi-device deployment.
