Local Deployment of Open-Source LLMs: Quantization, Model Selection, and Memory Planning

    Deploying a very large open-source LLM locally starts with memory planning, not hardware selection. This article explains how quantization affects model size and quality, what memory estimates really mean, and how to choose between unified-memory, multi-GPU, and CPU+GPU offload paths. It also covers deployment steps, inference parameters, KV Cache estimation, and pre-launch checks.

    Start with memory, not hardware

    Large language models have moved from tens of billions to hundreds of billions of parameters. A 744B-parameter open-source Mixture-of-Experts (MoE) model, for example, activates about 40B parameters per inference. Sparse activation reduces compute, but all model weights must still fit somewhere in memory. That means the first step in local deployment is estimating memory requirements, not choosing hardware.

    Quantization: reducing model size

    Quantization converts weights from high-precision floating point formats such as FP16 or BF16 into low-precision integer representations. The bytes needed for each weight drop, so the whole weight file shrinks. Dynamic quantization computes scaling factors during inference and does not require a calibration dataset, which makes it practical for very large models.

    Quantization quality should not be judged by a single metric. KL divergence (KLD) measures how much the output probability distribution changes after quantization. Perplexity and task-specific scores show downstream performance on knowledge QA, code, and long-document understanding. Reported accuracy figures for 1-bit and 2-bit quantization should not be treated as proof of overall model capability unless the evaluation set and methodology are disclosed.

    Memory requirements: file size is not runtime memory

    The table below shows reference estimates. Treat these numbers as reference values and verify with the model card and real measurements before deployment.

    Quantization Approximate weight file size Suggested minimum total memory
    1-bit 217 GB 223 GB
    2-bit 239 GB 245 GB
    4-bit 372 GB to 475 GB Determine by testing
    8-bit 810 GB Determine by testing

    “Total memory” means system RAM plus VRAM, or the total unified-memory pool. The runtime also needs memory for the operating system, inference framework, and KV Cache. The lower bounds above include no headroom, so the actual available memory should be larger.

    Three hardware paths

    Unified-memory devices

    Devices such as Apple Silicon let the CPU and GPU share one memory pool, so data does not need to be copied between separate system memory and VRAM. To run 2-bit weights, the device needs far more than 245 GB of total memory because system and KV Cache overhead consume the same pool. A 256 GB machine only means there is a chance to try; stable operation must be tested.

    Multi-GPU

    A model can be sharded across multiple GPUs by layer or by tensor. Two 48 GB GPUs provide 96 GB of VRAM total, and large system memory is still needed to hold the remaining weights when the model is larger than that. Interconnect bandwidth between GPUs—PCIe or NVLink—affects throughput. Enough capacity does not guarantee enough speed.

    CPU+GPU offload

    When VRAM is insufficient, expert weights can be kept in system memory and moved to the GPU only when needed. This works for MoE models because only a small subset of experts is activated per token. The tradeoff is speed: the lower the expert hit rate, the more transfers are required, and the slower inference becomes.

    Deployment steps: follow the official documentation

    1. Read the official documentation for both the inference framework and the model. Record version numbers and dependency requirements.
    2. Install the framework in a virtual environment or container to avoid polluting the system environment. Copy install commands from the official docs and pin versions.
    3. Download model files from official sources, then verify file hashes against the release page.
    4. Start the service with a small context length, confirm the model loads, then increase context length gradually.
    5. Record first-token latency, tokens per second, and peak memory as a baseline for later tuning.

    Inference parameters and thinking mode

    Many open-source models support a thinking mode that switches between simple question answering and complex reasoning. The exact switch name and values depend on the model and framework, so consult the corresponding documentation. With thinking mode enabled, each response produces more tokens, which increases both latency and memory usage. It is reasonable to keep it off for daily conversation and enable it for hard reasoning tasks.

    Use the sampling parameters—temperature and top_p—from the model card as starting points, then adjust them for your own workload. A longer context length increases KV Cache consumption, so set it according to actual need instead of always using the maximum supported value.

    Estimating KV Cache

    In long-context scenarios, KV Cache memory can exceed the model weights. A common estimate is:

    KV Cache bytes ≈ 2 × number of layers × number of KV heads × head dimension × context length × bytes per element

    The factor of 2 accounts for storing both Key and Value. Layer count, KV head count, and head dimension are available in the model configuration file. For models that use compressed attention or other variants, adjust the formula accordingly. Treat the result as a lower bound and reserve additional headroom.

    Pre-launch checklist

    • License: confirm the model license permits the intended use, especially commercial use.
    • Source: download only from official or trusted mirrors, and verify hashes.
    • Accuracy: compare quantized and unquantized outputs on your own business test set, focusing on core tasks.
    • Access control: if the local service is exposed to a LAN, enable authentication; do not expose it directly to the public internet.
    • Logging: redact user privacy and secrets when logging requests.
    • Performance: benchmark on the target hardware and record peak memory plus long-run stability.

    Closing thoughts

    Successful local deployment of a very large model depends on memory headroom, quantization precision, and acceptable speed. If those conditions are met, start with a small pilot before scaling out. If memory or speed is insufficient, choosing a smaller model or a lower quantization level is often more practical than aiming for the largest possible parameter count.