Deploying Ultra-Large Quantized Models on a Unified Memory Platform
This article explains how to run open-source large language models with hundreds of billions of parameters on a single machine using a unified memory architecture. It covers capacity estimation for model weights and KV cache, key considerations for mixture-of-experts models, quantization bit-width selection, the deployment workflow, performance benchmarking metrics, and troubleshooting guidance, concluding with a practical checklist for production deployment.
1. Background and Problem Statement
Running open-source large language models with tens or hundreds of billions of parameters locally has traditionally been constrained by GPU memory. Discrete GPUs typically offer only tens of gigabytes of VRAM, while model weights alone can exceed that capacity. A unified memory architecture merges the memory accessible to the CPU and the accelerator into a single shared pool, making it theoretically possible to allocate over a hundred gigabytes to inference workloads—so a single machine can host very large models.
The core question with this approach is not “can the model be loaded,” but “how well does it run once loaded, and at what cost.” Developers need to answer three questions: Can the model fit entirely in available memory? Is the accuracy loss from quantization acceptable? Is generation speed sufficient for real workloads? The following sections address these questions in turn.
2. Characteristics of Unified Memory Architecture
The advantage of unified memory is its large capacity, and because the accelerator and processor cores access the same data, the overhead of moving data between separate memory spaces is eliminated. However, there are clear constraints:
- Memory bandwidth is shared across the whole system. Throughput during generation is usually bandwidth-bound, not limited by peak compute.
- The operating system and other processes consume part of the memory, so the capacity available to the model is less than the nominal total.
- Large capacity does not mean fast performance. How many tokens per second you can generate depends mainly on bandwidth and the amount of data the model must read at each step.
In practice, first confirm the maximum memory the system allows for accelerated compute, then plan capacity. The configuration method varies significantly between systems; consult the official documentation for your platform rather than relying on assumptions.
3. Capacity Estimation
Before deployment, you need to estimate two components: model weights and the KV cache used during inference.
3.1 Weight Footprint
The approximate formula for weight footprint is:
Weight footprint ≈ parameter count × bits per parameter ÷ 8
For a model with roughly 284B (284 billion) parameters:
- 4-bit quantization: ~142 GB
- 8-bit quantization: ~284 GB
- 16-bit full precision: ~568 GB
These figures cover only the weights themselves and do not include runtime overhead.
3.2 Considerations for Mixture-of-Experts Architectures
Mixture-of-experts (MoE) models activate only a subset of experts per inference step, so the compute per token is much smaller than the total parameter count suggests. However, all expert weights must remain resident in memory, since any of them may be selected by the router at any time. The conclusion: fewer active parameters mainly reduce compute and improve speed—they do not reduce memory requirements. Always plan capacity based on the total parameter count.
3.3 KV Cache
The KV cache stores context information already processed by the attention mechanism, and its size grows with context length and the number of concurrent requests:
KV cache ≈ 2 × layers × KV heads × head dimension × context length × concurrency × bytes per element
The following function combines weights and KV cache into a single estimate:
def estimate_memory_gb(params_b, weight_bits, layers, kv_heads, head_dim,ctx_len, batch, kv_bytes=2, overhead_ratio=0.1):"""Estimate memory required for inference (GiB). overhead_ratio is anempirical value for runtime overhead and should be validated by measurement."""weights = params_b * 1e9 * weight_bits / 8kv = 2 * layers * kv_heads * head_dim * ctx_len * batch * kv_bytestotal = (weights + kv) * (1 + overhead_ratio)return total / 1024**3
Replace the number of layers, KV heads, and head dimension with the actual values from the model’s configuration file. The estimate should only be used as a screening criterion; the final reference is the actual memory footprint after loading.
4. Choosing a Quantization Bit-Width
Quantization trades capacity for reduced storage precision per parameter. Lower bit-widths mean smaller weights but greater accuracy loss. When selecting a bit-width, weigh three factors:
- Capacity: Can the target machine hold the weights, KV cache, and system overhead?
- Quality: Is the output still usable on tasks relevant to your business?
- Speed: Smaller weights usually mean less data to read, but dequantization may add compute overhead.
When comparing bit-widths, use a fixed test set rather than scattered subjective impressions. The test set can cover the following dimensions:
- Accuracy on factual question answering
- Runnable rate of generated code
- Format compliance of structured outputs (e.g., JSON)
- Retention of key information in long-text summarization
Even at the same bit-width, quantized files from different sources may differ in quality. Verify hash values after download and confirm that the files match the intended model version.
5. Deployment Workflow
Follow the steps below in order, keeping records at each step so issues can be traced back:
- Confirm the hardware and the system’s memory allocation limit for accelerated compute; record total memory, available memory, and bandwidth parameters.
- Obtain the model files, verify hash values, and confirm the license permits your intended use.
- Select an inference engine and confirm it supports the quantization format and model architecture you are using (including mixture-of-experts).
- Set context length, concurrency, and thread count, then start the service.
- Run smoke tests with a fixed prompt set, checking that outputs terminate properly and contain no garbled text or repetition.
- Run stress tests while monitoring memory usage, swap usage, and device temperature.
Parameter names in startup commands vary across inference engine versions. The following is a structural example only; refer to the documentation of the version you are using for exact parameters:
# Example only: replace with the actual startup parameters of your inference engineserve --model-path /models/target-model-q4 --ctx-size 8192 --parallel 2 --threads 16
Start with smaller values for context length and concurrency. Increase them gradually only after confirming sufficient memory headroom.
6. Performance Metrics and Measurement Methods
Evaluating local LLM performance typically focuses on the following metrics:
- Time to first token: The time from submitting a request to receiving the first token; affects interactive experience.
- Generation throughput: Tokens generated per second; determines how long long responses take.
- Tail latency under concurrency: The response time of the slower requests when multiple requests arrive simultaneously.
- Peak memory: The highest usage during loading and long-context inference.
When measuring, fix the input and output lengths, warm up before timing, and take the median of multiple runs to reduce random fluctuation. The following code demonstrates a basic framework for throughput statistics:
import statisticsimport timedef benchmark(generate, prompts, runs=3):"""generate(prompt) should return the number of tokens generated.Returns the median throughput (tokens/s)."""throughputs = []for _ in range(runs):for prompt in prompts:start = time.perf_counter()n_tokens = generate(prompt)elapsed = time.perf_counter() - startthroughputs.append(n_tokens / elapsed)return statistics.median(throughputs)
The test report should also record hardware configuration, system memory allocation settings, model file version, quantization bit-width, context length, and concurrency. Data without this information cannot be reproduced or used for cross-comparison.
7. Common Issues and Troubleshooting
- Loading fails or reports insufficient memory: First check the system’s allocation limit for accelerated compute, then reduce bit-width or context length.
- Speed well below expectations: Check whether memory swapping is occurring, verify that the thread count matches the physical core count, and confirm no other heavy processes are consuming bandwidth.
- Degraded output quality: Check the source and integrity of the quantized files, and run the same test set against a higher bit-width version for comparison.
- Instability with long contexts: When KV cache growth exceeds available memory, the system pages frequently and latency spikes. Limit context length or reduce concurrency in this case.
When troubleshooting, change only one variable at a time and keep the results of each test. Adjusting multiple parameters simultaneously makes the true cause difficult to identify.
8. Deployment Checklist
- Confirmed the system’s memory allocation limit for accelerated compute
- Completed capacity estimation covering weights, KV cache, and runtime overhead, with headroom reserved
- Verified model file hashes and confirmed the license permits the intended use
- Compared the output quality of the selected bit-width using a fixed test set
- Recorded hardware, system settings, model version, bit-width, context length, and concurrency
- Completed stress testing and observed changes in memory, swap, and temperature
