Deploying Very Large Open-Source LLMs: A Practical Guide to Architecture, Data, and Infrastructure

    Open-source large language models now rival top proprietary models on general QA, coding, and math tasks, but getting a model to run is very different from serving it reliably and cost-effectively in production. This guide covers five key decision areas—dense vs. sparse (MoE) architectures, long-context implementation, training data and alignment, model comparison, and GPU memory estimation—with concrete evaluation criteria and steps for each.

    Open-source large language models now approach top proprietary models on general question answering, coding, and math tasks. But there is a big gap between “the model runs” and “the model serves your business reliably and cost-effectively.” This article walks through the key decision points in five sections, each with evaluation criteria and actionable steps.

    1. Model Architecture: Dense vs. Sparse

    The conclusion first: dense models have mature architectures and simple inference paths, making them a good fit when stability is the priority. Sparse models compute fewer parameters per token, lowering per-unit inference cost, but they are more complex to schedule and operate.

    A dense model engages all of its parameters in every forward pass; Llama 3.1 405B falls into this category. A sparse model activates only a fraction of its parameters per token—DeepSeek-V3 has roughly 671B total parameters but activates only about 37B per token. Both are hundred-billion-scale models, yet their compute and memory profiles at inference time are completely different.

    Sparse activation is not synonymous with Mixture-of-Experts (MoE). MoE is simply the most common implementation; other structures (such as block-sparse attention or conditional computation) can also introduce sparsity. When selecting a model, use “how many parameters are activated per token” as the deciding criterion—architecture names are just labels.

    1.1 MoE Routing and Load Balancing

    MoE replaces the feed-forward layer with multiple parallel expert networks. A router selects the top-scoring experts for each token, and only the selected experts participate in computation.

    A common problem is expert collapse: a small number of experts handle most of the traffic while the rest sit nearly idle. Training typically adds a load-balancing auxiliary loss, or uses auxiliary-loss-free dynamic bias adjustment. Some implementations set a capacity factor that limits how many tokens a single expert can process at once; excess tokens are dropped or rerouted to other experts. Default values and drop policies differ across frameworks, so before deployment you should stress-test under your target traffic and check whether output quality is affected.

    1.2 How Long Context Is Implemented

    Recent open-source models commonly support inputs on the order of 128K tokens. Two families of techniques make long context possible.

    The first is positional encoding improvements. Rotary Position Embedding (RoPE) extends the positional range by adjusting the frequency base and similar methods. These adjustments usually require continued training or fine-tuning—they are not free extrapolation. Beyond the trained length, retrieval and reasoning quality typically degrade and must be validated with long-text evaluation sets.

    The second is attention optimization. Sliding window attention only attends to the most recent w tokens, so the KV cache size is tied to the window rather than growing linearly with context length. Streaming attention retains a small number of initial tokens (attention sinks) plus a recent window, achieving similar cache control. The trade-off is that information outside the window cannot be accessed directly and must be supplemented with external retrieval or summarization. For tasks that require precise cross-document localization, recall with these methods is often lower than with full attention.

    Selection note: if your business needs to locate a specific clause in a hundred-page document, run a “needle in a haystack” style test on the candidate model before trusting the advertised context length.

    2. Training Data and Alignment

    Data determines the ceiling of a model’s capability; alignment determines whether the model is usable in your business. Both require well-defined processes and records.

    Data processing typically includes the following steps:

    1. Source review: record the licensing status of every data batch and exclude unlicensed or restricted content.
    2. Cleaning and deduplication: filter low-quality text, then perform exact and approximate deduplication (e.g., MinHash).
    3. Decontamination: check overlap against evaluation sets to prevent inflated benchmark scores.
    4. Privacy handling: identify and redact sensitive information such as ID numbers, phone numbers, and credentials.
    5. Mixture and sampling: set proportions by domain and observe the impact on validation sets.

    Alignment generally proceeds in two stages. Supervised fine-tuning (SFT) trains the model with instructions and reference answers to follow formats and task requirements. Preference optimization (e.g., DPO) uses pairs of preferred and rejected responses to adjust the model’s output tendencies. When fine-tuning in-house, keep versions and provenance of your fine-tuning data to support auditing and rollback.

    3. Model Comparison

    The table below compares two representative models. Parameter figures are taken from each model’s public technical materials. Memory figures are lower bounds computed from BF16 weights and exclude KV cache and runtime overhead.

    Dimension Llama 3.1 405B (Dense) DeepSeek-V3 (Sparse MoE)
    Total parameters ~405B ~671B
    Activated parameters per token ~405B ~37B
    BF16 weight memory (lower bound) ~810 GB ~1.34 TB
    Long context 128K Per official configuration
    License Llama Community License, with additional conditions for large-scale users Per the model license at release
    Best fit Predictable behavior, mature tuning paths Cost-sensitive per-unit inference, tolerance for scheduling complexity

    When selecting a model, you should also compare throughput, time to first token, and per-unit cost. These metrics must be measured on identical hardware, with identical batch sizes and prompt lengths—otherwise the numbers are not comparable.

    4. GPU Memory Estimation

    GPU memory consists of three parts: weights, KV cache, and activations plus runtime overhead.

    Weight memory = parameter count × bytes per parameter. BF16 is 2 bytes, INT8 is 1 byte, and INT4 is roughly 0.5 bytes.

    KV cache (standard multi-head or grouped-query attention) = 2 × number of layers × number of KV heads × head_dim × sequence length × concurrency × bytes per element