Local Deployment of Mid-Sized LLMs: Memory, Bandwidth, and Engineering Practices
Running mid-sized LLMs on local workstations or small servers is often limited first by memory capacity rather than raw compute. This article explains how to evaluate memory capacity, memory bandwidth, and acceleration hardware; estimate weight and KV-cache footprints; derive a theoretical throughput ceiling; and configure the software stack for stable deployment. It also provides an acceptance checklist and outlines when local deployment makes sense compared with cloud or hybrid options.
1. Background: The Bottleneck for Local LLMs Is Memory
When running large language models on a personal workstation or small server, a common intuition is that “more compute means faster inference.” In practice, the opposite is often true. For inference, whether the model can fit into memory usually becomes the limiting factor earlier than chip compute performance.
Model parameters must reside entirely in memory that compute units can access at high speed. For a model with a large parameter count, even if a single inference pass could complete in minutes, the system will fall back to frequent paging or external storage I/O if the weights do not fit. Response speed then drops rapidly. Therefore, the first question in local deployment is usually not “how fast does it run?” but “can it fit entirely?”
There is also a trade-off between parameter scale and usable capability. Small models in the roughly 7B parameter range have a low deployment barrier, but their capability boundaries are relatively clear on tasks such as complex reasoning, long-text understanding, and code generation. Mid-sized models in the roughly 20B to 40B parameter range often achieve better results on these tasks, but they place higher demands on memory capacity. Understanding this trade-off is the starting point for hardware selection.
2. Three Core Hardware Selection Metrics
2.1 Memory Capacity
Capacity determines whether the model can be loaded, and it also determines the context length and number of concurrent requests that can be supported at the same time. In addition to model weights, inference requires KV cache, runtime buffers, and memory used by the operating system itself. Sufficient headroom should be reserved during selection; in general, it is recommended that weight usage stay below about 70% of available memory.
2.2 Memory Bandwidth
During the generation stage, where tokens are produced one by one, the model must read most of its weights for each token generated. Generation speed is therefore mainly limited by memory bandwidth rather than peak compute. Higher bandwidth means more weight reads can be completed per unit of time, which leads to faster output.
2.3 Compute Units and Acceleration
During the prefill stage, where the input prompt is processed, the computational workload is larger, and acceleration units such as GPUs or NPUs play a more visible role. If the hardware supports a unified memory architecture, the CPU, GPU, and NPU can share the same memory, reducing data-copy overhead. This is beneficial for local deployment of mid-sized models. Whether acceleration units can actually be used depends on inference engine support for the corresponding backend, and it needs to be confirmed through testing.
3. Capacity Estimation Methods
The memory footprint of model weights can be estimated with a simple formula:
Weight footprint ≈ parameter count × bytes per parameterBytes per parameter = quantization bit width / 8
Taking a 32B parameter model as an example, the approximate weight footprint at different quantization precisions is as follows:
| Quantization precision | Bytes per parameter | Weight footprint (approx.) |
|---|---|---|
| FP16 | 2 | 64 GB |
| 8-bit (Q8) | 1 | 32 GB |
| 4-bit (Q4) | 0.5 | 16 GB |
The actual footprint also includes KV cache. KV cache grows linearly with context length and concurrency, and in long-context scenarios it may reach several GB or more. The following is an example estimation function for making a rough judgment before deployment:
function estimate_memory_gb(params_b, bits, ctx_len, kv_bytes_per_token_mb, concurrency):weights_gb = params_b * bits / 8kv_gb = kv_bytes_per_token_mb * ctx_len * concurrency / 1024overhead_gb = 2.0 # Runtime and buffers, empirical valuereturn weights_gb + kv_gb + overhead_gb
Here, kv_bytes_per_token_mb depends on the specific model’s layer count, attention head configuration, and cache precision. It should be based on parameters in the model configuration file and should not be directly assumed from experience.
4. Theoretical Throughput Ceiling
Generation speed can be roughly upper-bounded using memory bandwidth. For dense models, generating one token requires reading through most of the weights once:
Theoretical throughput ceiling (tokens/s) ≈ effective memory bandwidth (GB/s) / bytes read per token (GB)
Assuming an effective bandwidth of 200 GB/s, a 32B model at 8-bit quantization reads about 32 GB per token, giving a theoretical ceiling of about 6 tokens/s. This is a theoretical value. Actual performance is affected by factors such as compute scheduling, cache hit rate, backend implementation, and concurrency, and is usually below the ceiling.
This formula has two practical implications. First, each time quantization precision is halved, theoretical throughput roughly doubles, but the quality loss needs to be evaluated on the target task. Second, under the same memory capacity, a platform with lower bandwidth may be able to fit the model, but its generation speed may still be insufficient for interactive needs.
5. Software Stack and Deployment Considerations
Beyond hardware, software configuration also affects the final result. Deployment can start from the following areas.
Inference engine selection. Different engines have different levels of support for hardware backends. During selection, confirm whether the acceleration path for the target hardware is mature, and pay attention to stability under long context and high concurrency.
Quantization scheme. When GPU memory or system memory is limited, quantization is the most direct approach. It is advisable to compare output quality at different quantization levels on your own business dataset rather than relying only on general leaderboard scores.
Context length and concurrency. Longer context and higher concurrency increase KV cache usage. Set limits based on the real request distribution of the business, and truncate or queue requests that exceed the limits.
Service wrapping. Local models are usually exposed as services. Inference capabilities can be exposed through standard HTTP interfaces, combined with rate limiting, timeout control, and health checks, so that they can be integrated into existing systems more reliably.
Resource monitoring. Continuously collect metrics such as memory usage, bandwidth utilization, first-token latency, and output speed, and set alert thresholds. When memory approaches its limit, the system may experience noticeable jitter. Early warning can help avoid service interruptions.
6. Testing and Acceptance Checklist
Theoretical estimates can only provide direction; final conclusions should come from testing. The following steps are recommended for acceptance:
- Fix the test model, quantization level, context length, and concurrency to ensure consistent comparison conditions.
- Record first-token latency (prefill time) and steady output speed (decode throughput) separately.
- Run continuously under peak load for a period of time, and observe whether memory usage remains stable and whether there is paging or significant slowdown.
- Evaluate output quality with business samples, and record error types and frequency.
- Compare the unit cost and data compliance requirements of cloud options to determine whether local deployment provides real benefits.
7. Applicable Scenarios and Boundaries
Local deployment is suitable for scenarios with high data privacy requirements, stable call frequency, offline operation needs, or a desire to control long-term costs, such as internal knowledge base question answering, code review assistance, and document processing.
Its boundaries are also clear. A single device has limited concurrency capacity and is difficult to use for supporting large numbers of requests during peak periods. Model upgrades, dependency maintenance, and security hardening require additional operational investment. For tasks that require the capabilities of the latest large-scale models, cloud services are usually still the more appropriate choice.
A reasonable approach is therefore to first clarify business requirements, use capacity and bandwidth formulas for preliminary screening, then confirm through testing, and finally decide on a local, cloud, or hybrid deployment approach.
