Local LLM Deployment: Four Approaches and How to Choose

    A practical guide to running large language models on your own hardware. It covers the memory math that should drive any decision, then compares four widely used deployment patterns—consumer single or dual GPU with low-bit quantization, multi-GPU tensor and expert parallelism, CPU-GPU hybrid offloading, and domestic accelerator adaptation—along with their costs, scale limits, and latency tradeoffs. The article also outlines a minimal production setup with an OpenAI-compatible gateway, queueing, load balancing, and observability metrics such as TTFT, TPOT, cache hit rate, and GPU memory usage, and closes with a selection order that takes a team from prototype to infrastructure.

    1. Background: Why Move Inference Back On-Premises

    Over the past two years, sparse Mixture-of-Experts (MoE) models with very large parameter counts have become the mainstream direction in the open-source community. Total parameter counts can reach the trillions, yet only a small fraction of those parameters are actually activated per token. Combined with very long context windows, these models perform strongly on agentic tasks, domain-specific question answering, and multi-step reasoning.

    API pricing is the counterweight. Looking at publicly available industry rate ranges, output pricing for flagship models typically lands at roughly a dozen to a couple dozen yuan per million tokens, while lightweight models still cost a few yuan per million tokens. For teams that embed a model directly into a production pipeline and need uninterrupted 24/7 calls, the monthly bill easily climbs into five figures. More importantly, sensitive data leaving your network, tail latency caused by network jitter, and provider quota limits are all problems that spending more money does not fully solve.

    The value of local deployment therefore goes beyond cost savings. It delivers three forms of certainty: a defined data boundary, defined performance capacity, and a defined unit cost. Below are four approaches in wide use across real data centers and workstations.

    2. Prerequisites: Size the Memory First, Then Pick an Approach

    Any selection should start from a few simple formulas:

    1. Weight memory ≈ parameter count × bytes per parameter
    2. Activation/KV cache memory ≈ 2 × layers × KV heads × head_dim × context length × concurrency × bytes
    3. Usable memory = physical memory × 0.85 (reserved for fragmentation and runtime overhead)

    Take a 1.6T-total-parameter MoE model. FP16 requires roughly 3.2TB of memory, which a single machine cannot hold. At 4-bit quantization it needs about 0.8TB, still beyond the comfort zone of an 8-GPU node (8 × 141GB ≈ 1.1TB), so expert parallelism or offloading becomes mandatory. A lighter 284B-total-parameter variant, by contrast, needs about 150GB after 4-bit quantization and fits on two to four cards—which is where most teams actually start.

    One point deserves emphasis: for MoE models, the memory bottleneck is total parameters, while the speed bottleneck is activated parameters. Memory determines whether you can run the model at all; activation volume determines how fast it runs.

    3. Approach 1: Consumer Single or Dual GPU with Low-Bit Quantization

    Best fit: individual developers, prototype validation, internal knowledge base Q&A, with QPS requirements below 5.

    The approach is to convert weights to 4-bit or lower precision and keep them entirely resident on a single 24GB–48GB card, paired with paged KV cache management to improve concurrency. The advantages are a very simple deployment, the lowest cost, and no code changes. The tradeoff is noticeable cache growth under long contexts—a single request at 128K context can consume several gigabytes of memory on its own.

    Practical recommendations:

    • Trim context length to the real business distribution; 8K–32K is enough for most customer support scenarios.
    • Fix sampling parameters (temperature, top_p) to prevent output length from running out of control.
    • Replace static batching with continuous batching; throughput typically differs by several times.

    4. Approach 2: Multi-GPU Tensor Parallelism plus Expert Parallelism

    Best fit: running a lightweight MoE variant and serving it to a team.

    Tensor parallelism splits each layer’s matrices across multiple GPUs. It is communication-heavy and should stay within the high-speed interconnect of a single machine. Expert parallelism distributes different experts across different cards, with a sparser communication pattern that suits cross-node scaling. The common engineering combination is “tensor parallelism inside the node, expert parallelism across nodes.”

    Illustrative startup logic (pseudocode, showing only how the parallelism dimensions combine):

    1. engine = InferenceEngine(
    2. model="local-moe-284b",
    3. tensor_parallel_size=4, # intra-node split
    4. expert_parallel_size=2, # cross-node split
    5. quant="w4a16",
    6. max_model_len=65536,
    7. gpu_memory_utilization=0.88,
    8. )

    Tuning priorities: make sure intra-node bandwidth is sufficient first; when the cross-node link is inadequate, prefer lowering the tensor parallelism degree and raising the expert parallelism degree. Also enable prefix caching so the system prompt and long documents are computed only once.

    5. Approach 3: CPU-GPU Hybrid Offloading

    Best fit: insufficient GPU memory but abundant system memory (512GB or more), for offline batch processing where higher latency is acceptable.

    The idea is to keep attention and the first several layers on the GPU while leaving cold layers and expert weights in system memory, swapping them in on demand. Its significance is trading time for space: it lets a 1.6T-class flagship model run in a data center with no thousand-GPU cluster. The cost is per-token latency that may rise to several seconds, making it better suited to overnight batch jobs, code auditing, and structured document extraction—throughput-first tasks that are not latency-sensitive.

    Optimization options include tuning the layer placement strategy (pinning frequently accessed layers to the GPU), using quantization formats sensitive to memory bandwidth, and adding request queuing with priority scheduling so long jobs do not block interactive requests.

    6. Approach 4: Domestic Accelerators and Self-Developed Compute Adaptation

    In environments with strict requirements around domestic technology stacks and data compliance, you need a domestic accelerator that has completed operator adaptation. The usual path is: confirm the operator support list for the target model and inference framework → validate numerical alignment using an official or community-provided adapted image → run performance stress tests. A common pitfall here is a missing custom operator causing a fallback to CPU execution and a sharp performance drop. Use per-layer latency profiling to locate it rather than looking only at end-to-end numbers.

    7. Serving and Observability

    Local deployment is not the finish line; reliably exposing the capability is. A recommended minimum production architecture includes an HTTP gateway with an OpenAI-style compatible API, request queuing and rate limiting, load balancing across multiple model instances, and logging plus metrics monitoring and alerting. Core metrics should cover time to first token (TTFT), time per output token (TPOT), throughput (tokens/s), cache hit rate, and GPU memory utilization. If elasticity is needed, separate the stateless gateway from the inference instances and use a container platform to scale replicas, with model weights pre-staged in object storage or a shared file system to speed up loading.

    8. Comparison and Selection Conclusion

    Approach Entry cost Supportable scale Latency Recommended use
    Single-GPU quantization Low Quantized variants below 300B Low Prototyping, internal Q&A
    Multi-GPU parallelism Medium-high Full 300B-class serving Low Team production
    Hybrid offloading Medium Trillion-scale MoE High Offline batch processing
    Domestic accelerator adaptation Medium-high Depends on adaptation level Medium Compliant internal networks

    Recommended selection order: start with single-GPU quantization to validate business value and prompt engineering, then move to multi-GPU parallelism to handle real traffic, keep hybrid offloading as a supplementary channel for very long documents, and finally introduce self-developed compute as compliance requirements dictate. Once the local unit cost (hardware depreciation plus power plus operations) falls below the external billing bill, and data compliance becomes a hard constraint, local deployment has completed the transition from technical experiment to infrastructure. To further reduce operational complexity, you can also evaluate a combination of general-purpose capabilities such as container platforms, object storage, and monitoring and alerting from Baidu AI Cloud, keeping your focus on model quality itself.