Open-Weight LLM Private Deployment: VRAM Planning, GPU Selection, and Quantization
This article explains what open-weight LLM releases change for teams running models on their own infrastructure. It covers how to estimate VRAM for model weights, KV cache, and runtime overhead; how to select GPUs beyond memory capacity; how to evaluate quantization and define rollback conditions; and what prerequisites and code patterns are needed for 8-bit loading.
Open-Weight LLM Private Deployment: VRAM Planning, GPU Selection, and Quantization
I. What Open Weights Change
In the API model, developers can only submit prompts and receive outputs. The model’s internal parameters and intermediate states are not visible. With open weights, teams can download model files, run them on their own hardware, and perform fine-tuning, inference optimization, and customization based on business requirements.
This freedom has practical value. Teams can use internal data for LoRA fine-tuning and adjust inference framework configurations according to hardware characteristics. However, two boundaries need to be clear: open weights do not mean model behavior can be fully explained, nor do they mean safety alignment issues are automatically solved. Models can still produce hallucinations or inappropriate outputs, so they need separate evaluation and safeguards before launch.
II. Calculate VRAM Before Buying Hardware
The most common mistake in private deployment is underestimating VRAM. VRAM usage can be broken into three parts:
Total VRAM ≈ model weight VRAM + KV Cache VRAM + runtime overhead
- Model weight VRAM equals the number of parameters multiplied by the number of bytes per parameter.
- FP16 or BF16 uses 2 bytes per parameter. A 10B-parameter model requires about 20 GB, and a 100B-parameter model requires about 200 GB.
- INT8 uses 1 byte per parameter, so weight VRAM is about half of FP16.
- INT4 uses about 0.5 bytes per parameter, with a theoretical value of one quarter of FP16. Quantization also needs to store scaling factors, and some layers may remain unquantized, so actual usage will be higher than the theoretical value.
- KV Cache VRAM grows with concurrency and context length. The formula is:
KV Cache ≈ 2 × layers × KV heads × head dimension × sequence length × concurrency × bytes per element
Example: 32 layers, 8 KV heads, head dimension 128, sequence length 4096, FP16 storage. At concurrency 1, KV Cache is about 0.5 GB; at concurrency 16, it is about 8 GB. Concurrency is the most easily overlooked variable in VRAM planning.
- Runtime overhead includes CUDA context, framework memory pools, activations, and so on. As an engineering rule of thumb, reserve 10% to 20% of headroom. This is an empirical value and should be based on actual measurements.
Planning can follow these steps:
- Determine peak QPS, average input length, average output length, and maximum context.
- Calculate KV Cache based on peak concurrency, not average concurrency.
- Use the formulas above to calculate weight and KV Cache usage, add headroom, and then determine hardware.
- If a single card cannot hold the model, evaluate communication bandwidth between multiple cards. NVLink is usually significantly faster than PCIe, and slow communication directly increases latency.
III. How to Choose GPUs
When selecting a GPU, do not look only at VRAM capacity. Consider the following dimensions together:
- VRAM capacity: determines whether the weights and the KV Cache for target concurrency can fit.
- VRAM bandwidth: affects decode speed. During text generation, the decode phase is usually limited by VRAM bandwidth.
- Interconnect: determines communication overhead in multi-GPU deployment.
- Precision support: confirm that the hardware and drivers support the target precision, such as BF16 or INT8.
- Software ecosystem: confirm that PyTorch, CUDA, driver versions, and the inference framework are compatible.
- Budget and power: includes purchase cost, data center power supply, and cooling conditions.
In practice, run a small-scale stress test with the target model and typical workloads before deciding purchase quantity. This is more reliable than estimating only from parameter tables. The same applies to accelerator cards from local vendors: rely on vendor-provided specifications and measured data on your own workloads.
IV. How to Choose Quantization and Plan Rollback
Quantization can reduce VRAM usage and bandwidth pressure, but it does not necessarily bring speedup. When loading with 8-bit, some compute kernels may be slower than FP16, so you must measure throughput and latency rather than looking only at how much VRAM is reduced.
| Precision | Weight VRAM (relative to FP16) | Main risk | Suitable scenario |
|---|---|---|---|
| FP16/BF16 | Baseline | High VRAM usage | Sufficient VRAM; use as the precision baseline |
| INT8 | About 1/2 | Some accuracy loss; some kernels may be slower | Tight VRAM but still requires relatively high output quality |
| INT4 | About 1/4 | More obvious accuracy loss; results depend on the specific quantization method | Severely limited VRAM and tolerable quality fluctuation |
Quantization rollout can proceed as follows:
- Build an internal evaluation set covering typical business questions and edge cases.
- Run the evaluation at FP16 and the target quantization precision, recording metrics such as accuracy, refusal rate, and format error rate.
- Stress test latency, throughput, and peak VRAM.
- Define rollback conditions in advance. If any core metric falls below the threshold, switch back to FP16, quantize only layers that are insensitive to precision, or use another quantization method.
V. Loading Code and Prerequisites
The following code shows the basic flow for 8-bit loading and inference. Before running it, meet these conditions:
- Have a CUDA-capable NVIDIA GPU with a matching driver installed.
- Install dependencies:
pip install torch transformers accelerate bitsandbytes. bitsandbytes has requirements for CUDA versions and operating systems; after installation, first validate whether it can be imported normally with a minimal example. - Newer versions of transformers recommend passing quantization parameters through
BitsAndBytesConfigrather than directly passingload_in_8bit. - Only after confirming that the model source is trusted and reviewing custom code in the repository should you set
trust_remote_code=True.
import torchfrom transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfigmodel_path = "/path/to/open/weights" # Local model directory; must contain weights and tokenizer filestokenizer = AutoTokenizer.from_pretrained(model_path, trust_rem
