Private Deployment of Open-Weight LLMs: From Model Selection to Troubleshooting
This guide outlines the key considerations for deploying open-weight large language models in private environments, including license review, data compliance, hardware sizing, dependency management, version pinning, and quantized model loading. It also provides practical memory estimates and environment validation commands.
1. Three Checks Before Selecting a Model
Organizations typically choose private deployment to keep data within a controlled environment, maintain predictable latency, or support fine-tuning. However, when request volume is low, the total cost of a cloud API may be lower. Before deploying, complete the following three checks.
First, confirm the license. Open-weight models use a wide range of licenses. Some permit commercial use, while others limit monthly active users, require attribution, or prohibit use in specific scenarios. Before production deployment, read the model card and license agreement carefully, and have your legal team review them.
Second, define your data and compliance requirements. Determine whether input and output logs contain personal information, how long they should be retained, and how access permissions should be divided. Private deployment alone does not guarantee compliance. These requirements must be designed separately.
Third, estimate hardware capacity. Start by estimating the memory required for the model weights, then add KV cache and runtime overhead. The basic calculation is:
- Weight memory is approximately equal to the parameter count multiplied by the number of bytes per parameter. BF16 and FP16 use 2 bytes per parameter, INT8 uses 1 byte, and INT4 uses approximately 0.5 bytes.
- For a 70B-parameter model, BF16 weights require approximately 140 GB, INT8 weights require approximately 70 GB, and INT4 weights require approximately 35 GB.
- KV cache is approximately equal to 2 multiplied by the number of layers, the number of KV heads, the head dimension, the sequence length, and the batch size, and then multiplied by the number of bytes per element. For a model with 80 layers, 8 KV heads, and a head dimension of 128, a single 4,096-token request requires approximately 1.3 GB of GPU memory in BF16.
These figures represent only a lower bound. Activations, framework caches, and memory fragmentation also consume additional capacity. Reserving at least 20% of extra capacity is recommended. Use the config.json file in the model directory as the source of truth for the model’s specific configuration.
2. Environment Dependencies and Version Matrix
Most deployment failures are caused by version mismatches. Install the software in an isolated virtual environment and pin the versions.
| Component | Recommended version | Notes |
|---|---|---|
| Python | 3.10 to 3.12 | Follow the versions supported by the official PyTorch compatibility list |
| PyTorch | 2.x | Must match the CUDA version; use the official installation command to obtain the appropriate build |
| transformers | As required by the model card | Older versions may not recognize newer model architectures |
| accelerate | 0.27 or later | Required by device_map="auto" |
| bitsandbytes | A version compatible with PyTorch and CUDA | Required for 8-bit and 4-bit quantization; currently mainly supports NVIDIA GPUs |
| NVIDIA driver | Meets the minimum requirement for the selected CUDA version | Check with nvidia-smi |
After installation, run the following commands to validate the environment:
python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available())"nvidia-smipip freeze > requirements.lock
torch.cuda.is_available() must return True. The requirements.lock file records the verified package versions, making it easier to reproduce the environment on other nodes.
3. Quantized Loading and Inference Services
3.1 Quantized Loading
Earlier implementations passed load_in_8bit=True directly as an argument. In newer versions, quantized loading should follow the version-specific API and configuration requirements described in the relevant model and library documentation.
