Deploying Ultra-Large Models on Unified Memory: Capacity Planning, Quantization, and Inference Tuning
Large-memory APU and SoC platforms make it possible to run quantized models with hundreds of billions of parameters on a single local system. This guide explains how to estimate memory requirements, choose a quantization level, allocate KV cache, enable speculative decoding, and benchmark inference performance without running into memory or bandwidth limits.
Why Run Large Language Models Locally?
Cloud APIs are convenient, but local deployment remains valuable when data privacy, offline operation, cost control, or customized inference workflows are important. In the past, GPU memory was the main obstacle to local deployment. A consumer GPU typically provides only a few dozen gigabytes of VRAM, which is not enough for models with hundreds of billions of parameters.
APUs and SoCs with large unified memory pools change this limitation. Because the CPU and GPU share the same memory, the GPU can use a large portion of system memory. As a result, running a quantized ultra-large model becomes technically feasible rather than impossible.
This article focuses on three practical questions: Does the model fit? Which quantization level should you choose? How can inference be tuned for stable performance?
Step 1: Calculate the Memory Budget
Before deployment, first determine whether the model can fit in memory. Total memory consumption can be divided into the following components:
- Model weights: parameter count × bits per parameter ÷ 8, measured in bytes.
- KV cache:
2 × number of layers × number of KV heads × head dimension × bytes per element × context length × concurrency - Activations and inference framework overhead: Reserve approximately 10% to 20% of the model weight size.
- Operating system and background processes: Check the system monitor for available memory before setting the memory budget for the inference process.
Consider a Mixture-of-Experts model with approximately 284B total parameters. A theoretical estimate of its weight size is:
- FP16: approximately 568 GB
- Q8: approximately 284 GB
- Q6: approximately 213 GB
- Q4: approximately 142 GB
Actual quantized files also store scale parameters for each block. Therefore, a Q4 file commonly occupies around 150 GB. Always use the actual model card or file size as the final reference.
KV cache requirements depend on the model architecture. The following example uses assumed values:
- 60 layers
- 8 KV heads
- Head dimension of 128
- FP16 cache, with 2 bytes per element
- Context length of 32,768
- Concurrency of 1
The estimated KV cache size is:
2 × 60 × 8 × 128 × 2 × 32768 ≈ 8.05 GB
At a concurrency level of 4, the requirement increases to approximately 32 GB. For an actual deployment, replace these assumptions with the layer count, number of KV heads, and head dimension listed in the model configuration.
The capacity test is straightforward: add the memory required for the weights, KV cache, and framework overhead, then reserve additional capacity for the operating system. The deployment is viable only if the total remains below the available memory.
Step 2: Choose the Quantization Level
Once the available memory is sufficient, select an appropriate quantization level. The following estimates use a 284B model as an example:
| Precision | Estimated Weight Size | Relative to FP16 | Quality Risk | Typical Use Case |
|---|---|---|---|---|
| Q8 | Approximately 284 GB | Approximately 1/2 | Low | Precision-sensitive workloads with sufficient memory |
| Q6 | Approximately 213 GB | Approximately 3/8 | Low to medium | Balancing quality and memory usage |
| Q4 | Approximately 142 GB; files commonly around 150 GB | Approximately 1/4 | Medium | General question answering and document summarization |
| Q3 and below | Below 107 GB | 3/16 or less | High | Requires task-specific evaluation |
Q4 is often a practical compromise for local deployment. Its theoretical size is about one quarter of FP16, and the quality loss is usually acceptable for general-purpose tasks. However, Q3 and lower levels can noticeably affect complex reasoning and code generation.
A gradual evaluation process is recommended. Start with a lower precision level to verify the complete deployment workflow. Then increase the precision of important layers for critical tasks such as programming and mathematics. Finally, validate the model with your own evaluation set instead of relying only on general-purpose benchmarks.
Step 3: Tune the Inference Workflow
After the model fits and runs successfully, several factors still affect the user experience.
Set a KV Cache Budget
Inference frameworks generally allow you to configure the maximum context cache. Work backward from the target context length and concurrency to estimate the required capacity, and leave enough headroom to avoid out-of-memory errors during execution.
If the framework supports an FP8 KV cache, it may reduce cache usage further. However, output quality should be validated before using it in production.
Enable Speculative Decoding
Speculative decoding requires a sufficiently small draft model. The draft model and the main model must use the same vocabulary; otherwise, they cannot work together directly.
The draft model also consumes additional memory. Before enabling speculative decoding, estimate its weight and cache requirements using the same capacity calculations, then determine whether the system has enough remaining memory.
Monitor Memory Bandwidth
On a unified-memory architecture, decoding speed is primarily limited by memory bandwidth. An MoE model activates only part of its experts for each token, which can reduce some of the bandwidth pressure, but it does not eliminate the bottleneck.
Monitor and Benchmark the System
After deployment, run multiple rounds of testing with a fixed prompt set and record the following metrics:
| Metric | Measurement Method |
|---|---|
| Time to first token | Report the median and P95 across multiple runs |
| Steady-state throughput | Output tokens per second, excluding the warm-up phase |
| Peak memory usage | Highest memory consumption observed during execution |
Before benchmarking, back up the configuration and set a concurrency limit. During testing, watch for out-of-memory errors, swap usage, or severe system lag. If any of these occur, reduce the context length or concurrency before continuing.
Common Troubleshooting Cases
- Out-of-memory error during startup: Reduce the context length, lower concurrency, or switch to a lower quantization level.
- The system becomes noticeably sluggish during inference: Check swap usage and reduce the KV cache budget if necessary.
- Throughput is lower than expected: Check whether memory bandwidth is saturated and confirm that the draft and main models use aligned vocabularies.
Conclusion
Large unified-memory platforms make it technically practical to run models with hundreds of billions of parameters on a single local machine. A reliable deployment process has three stages:
- Use formulas to estimate total memory requirements and confirm that the hardware has sufficient capacity.
- Choose a suitable balance between quantization level, model size, and task quality.
- Tune inference through KV cache budgeting, speculative decoding, and systematic performance testing.
For teams that require data sovereignty or offline inference, this approach is worth considering during infrastructure and model deployment evaluations.
