Self-Hosting Open-Weight LLMs: GPU Memory Sizing, Hardware, and Security

    Learn how to plan a private LLM deployment, from estimating GPU memory for weights and KV cache to checking hardware compatibility, licensing, and security requirements. This guide also covers hardware selection and introduces INT8 and INT4 quantization.

    The release of a frontier language model’s full weights gives developers the option to download the model, run it on their own infrastructure, and adapt it to business requirements.

    Compared with API-only access, self-hosting gives organizations greater control over inference, data flows, and operating costs. It also brings new responsibilities for hardware, operations, and security. The following sections walk through the main considerations in deployment order.

    1. Moving from API Access to Self-Hosting

    APIs are quick to adopt, but they come with three main limitations:

    • Limited visibility and control: The service runs as a black box, making it difficult to modify inference logic or inspect internal behavior.
    • Third-party data processing: Business data must be sent to an external service, requiring privacy and compliance assessments.
    • Scaling costs and latency: At high request volumes, network latency and token-based charges become increasingly important.

    With access to model weights, an organization can build an inference service on its own infrastructure. Data can remain within the private network, and fine-tuning can adjust model behavior.

    However, the organization also takes on responsibility for maintaining GPU infrastructure, implementing access controls, auditing, and managing keys. It must also verify whether the model license permits commercial use. Self-hosting does not automatically guarantee data security; that depends on how these controls are implemented.

    2. Estimating GPU Memory Before Deployment

    The first step after obtaining model weights is to determine the hardware requirements. GPU memory consumption has four main components:

    1. Total GPU memory ≈ Model weights + KV cache + Activations + Framework and runtime overhead

    Model Weight Memory

    Weight memory is the easiest component to estimate: multiply the parameter count by the number of bytes per parameter.

    • FP16: 2 bytes per parameter
    • INT8: 1 byte per parameter
    • INT4: Approximately 0.5 bytes per parameter

    For example, the FP16 weights of a 10-billion-parameter model require approximately:

    1. 10B × 2 bytes ≈ 20 GB

    KV Cache Memory

    KV cache memory grows with context length and the number of concurrent sequences:

    1. KV cache ≈ 2 × Number of layers × Number of KV heads
    2. × Head dimension × Sequence length
    3. × Concurrent sequences × Bytes per element

    Consider a 7B model with 32 layers, 32 KV heads, and a head dimension of 128. With FP16, the KV cache per token is approximately:

    1. 2 × 32 × 32 × 128 × 2 bytes ≈ 0.5 MB

    At a context length of 4,096 tokens and one concurrent sequence, the KV cache requires approximately 2 GB.

    Models using grouped-query attention (GQA) have fewer KV heads and therefore substantially lower KV cache requirements. Always use the actual values in the model configuration rather than assuming that models of similar parameter counts have the same cache requirements.

    Activations and Runtime Overhead

    Activation memory and framework overhead are harder to estimate precisely. In practice, allow an additional 10%–20% above the estimated requirements.

    The table below shows weight memory only. It excludes KV cache and framework overhead. Actual INT4 memory use is slightly higher because of quantization-related parameters.

    Model size FP16 weights INT8 weights INT4 weights
    7B Approx. 14 GB Approx. 7 GB Approx. 3.5 GB
    13B Approx. 26 GB Approx. 13 GB Approx. 6.5 GB
    70B Approx. 140 GB Approx. 70 GB Approx. 35 GB

    Pre-Deployment Checklist

    Before deployment, verify the following:

    • GPU model and memory capacity: Confirm that available memory covers the total estimate plus headroom.
    • CUDA, drivers, and inference framework: Check that their versions are compatible.
    • Disk space: Allow sufficient storage for weight files, caches, and logs.
    • Networking: Check inter-GPU bandwidth and, for multi-node deployments, communication latency.
    • Model license: Verify commercial-use permissions and any usage restrictions.
    • Weight provenance and integrity: Download from a trusted repository and verify file hashes against those supplied by the publisher.

    3. Choosing Hardware for Private Deployment

    Hardware selection depends primarily on three factors:

    • GPU memory capacity determines whether the model fits.
    • Memory bandwidth affects generation speed.
    • Supported numerical precision determines whether low-precision acceleration is available.

    For multi-GPU deployments, the interconnect between GPUs also matters.

    When considering alternative accelerator hardware, first confirm that the chosen inference framework supports the required operators and quantization methods on that hardware. Then benchmark the actual model. Base decisions on measured throughput and latency, not just specifications.

    Edge devices typically have less memory and are generally suitable only for small, quantized models. For example, a 7B model’s INT4 weights require approximately 3.5 GB. KV cache and system memory usage must also be included before deciding whether the device has enough capacity.

    4. INT8 and INT4 Quantization

    Quantization reduces GPU memory requirements by lowering weight precision. INT8 is generally the more conservative choice.