Open-Weight LLM Architecture Selection and Inference Cost Optimization: A Practical Guide

    Open-weight large language models have shifted from a "one size fits all" approach to a layered product family. Rather than a single isolated model, developers now work with a set of carefully positioned options defined by compute budget, deployment scenario, and quality requirements. This article walks through four key architectural designs—small models, shared KV cache, Mixture of Experts (MoE), and dense architectures—and explains how to choose the right one across edge devices, local workstations, and cloud services. It also covers deployment practices and offers selection guidance based on compute, memory, context length, and post-training needs.

    Introduction

    In recent years, open-weight large language models have evolved from “a single size for every task” into a layered product family. Developers no longer face one isolated model, but a set of coordinate points carefully divided by compute budget, deployment scenario, and quality requirements. Understanding the architectural trade-offs behind these layers is the prerequisite for making the right choice across edge devices, local workstations, and cloud services. Starting from three typical positioning categories, this article systematically reviews four key design dimensions—small models, shared KV cache, Mixture of Experts (MoE), and dense architectures—and offers practical guidance for engineering adoption.

    The Tiered Spectrum of Open-Weight Models

    A mature open-weight model series typically covers three targets:

    • Edge and embedded layer: Designed for mobile, IoT, and other devices with severely limited compute and memory, prioritizing small size, low power consumption, and quantizability.
    • Efficient local inference layer: Designed for single-GPU or consumer-grade hardware, balancing quality and resources, often using a sparse Mixture of Experts architecture.
    • High-quality layer: Designed for scenarios with higher generation-quality demands, using a dense architecture that balances output quality with post-training (fine-tuning) convenience.

    These three layers are not simply “large, medium, and small.” Instead, they develop along three different optimization mainlines: energy efficiency, throughput, and maintainability. When making a selection, the first step is to identify which mainline you sit on—this avoids mismatches such as “using a large model for a small task” or “forcing a small model to handle demanding requirements.”

    Small Models for Edge and IoT

    In embedded environments where memory is measured in megabytes and compute is limited, the core design constraint is not “whether a model can be trained” but “whether it can actually run.” The key techniques at this stage include:

    • Parameter compression and quantization: Using INT8/INT4 quantization to significantly reduce weight size and memory-access overhead.
    • Vocabulary and embedding optimization: Factorizing or sharing word embeddings to reduce parameter and memory footprint.
    • KV cache reuse: Controlling memory growth in long-context scenarios (see the next section).

    It is worth emphasizing that edge models do not chase extremes on a single metric. Instead, they seek a deliverable balance among latency, memory, and accuracy. If any one dimension gets out of control, the on-device experience becomes unusable.

    Shared KV Cache

    During autoregressive decoding, each layer must cache Key/Value states for historical tokens. This memory grows linearly with context length and is one of the main bottlenecks in long-context inference.

    The core idea of a “shared KV cache” is this: later layers reuse the Key/Value states already computed by earlier layers, rather than computing and storing a separate copy at every layer. It is not an invention of any single model, but an engineering implementation of cross-layer attention ideas that have long appeared in research and various implementations.

    A sketch (pseudocode) looks like this:

    1. # Originally, each layer maintains its own K/V cache
    2. # When shared_kv=True, reuse the K/V produced by upstream layers
    3. kv_cache = {}
    4. for layer_idx, layer in enumerate(layers):
    5. if layer.supports_shared_kv and layer_idx > 0:
    6. k, v = kv_cache[layer.source] # Directly reuse the source layer's K/V
    7. else:
    8. k, v = layer.compute_kv(hidden) # Compute and cache independently
    9. kv_cache[layer_idx] = (k, v)
    10. hidden = layer.attend(hidden, k, v)

    Benefits and costs should be considered together:

    • Benefits: Significantly reduces memory usage and memory-bandwidth pressure in long-context scenarios, allowing small models to carry longer contexts.
    • Costs: Cross-layer sharing sacrifices some independence of expression between layers, which may introduce subtle quality degradation—a trade-off to weigh during training or evaluation.

    Mixture of Experts (MoE): Trade-offs for Efficient Local Inference

    The MoE architecture replaces some feed-forward layers with multiple “experts,” and a router selects a small subset of experts to activate for each token. Its defining characteristic is sparse activation: the model has a large total parameter count, but each forward pass activates only a small fraction of them.

    The value of this design lies in “gaining large parameter capacity with relatively little compute,” which makes it well suited to efficient local inference. However, adoption requires attention to a few points:

    • Memory requirements depend on total parameters: Although only a few experts are activated, all expert weights must remain resident in memory, so the practical deployment memory threshold is often determined by the total parameter count.
    • Post-training is harder: The router must maintain load balancing; during fine-tuning, problems such as route collapse and uneven expert utilization can arise, making the process more sensitive to hyperparameter tuning and data distribution.
    • Inference implementation is complex: Batch size affects expert activation and memory-access efficiency, and the sparsity advantage is hard to fully exploit at small batch sizes.

    As a result, MoE is better understood as “trading engineering complexity for greater capacity at the same compute,” which places higher demands on operations and tuning capabilities.

    Dense Architecture: Quality First and Post-Training Friendly

    In contrast to MoE, every parameter in a dense architecture participates in computation on every forward pass. Its strengths precisely fill the gaps in MoE:

    • Predictable behavior: With no routing fluctuation, inference latency and memory behavior are more stable.
    • Smooth post-training: The workflows for fine-tuning, alignment, and domain adaptation are more direct, less prone to expert imbalance, and backed by more mature community tools and experience.
    • Controllable quality: In scenarios that pursue higher generation quality, dense structures are often easier to tune to the target.

    The cost is higher compute demand for the same quality—using all parameters in exchange for determinism is the essential trade-off of the dense architecture.

    Engineering and Deployment Practices

    Once you have selected a model layer, the real challenge lies in deployment and operations. Regardless of the architecture chosen, it is worth building a system around the following capabilities:

    • Inference servitization: Use a container platform to package models as elastic services with automatic scaling based on load.
    • Weight and artifact management: Use object storage to host model weights and versions, ensuring traceability and reproducibility.
    • Observability: Continuously track latency, throughput, memory usage, and error rates through logging and monitoring/alerting.
    • Peak shaving: Buffer requests with a message queue during traffic spikes to prevent inference nodes from being overloaded.

    For example, developers can combine these general-purpose capabilities from cloud providers such as Baidu AI Cloud: a container platform to run inference services, object storage to manage model assets, and logging plus monitoring/alerting to ensure stability. This lets teams focus their effort on model selection and quality tuning rather than repeatedly rebuilding underlying infrastructure.

    Selection Guidance and Conclusion

    • Edge/IoT scenarios: Prioritize “small parameters + quantization + shared KV cache,” pushing memory and power consumption within a range the device can accept.
    • Efficient local inference: Consider MoE when compute is adequate but you want “greater capacity,” while evaluating post-training and operational costs at the same time.
    • Quality-first scenarios: When pursuing stable quality and smooth fine-tuning, a dense architecture is the more reliable choice.

    There is no absolute winner among architectures—only the degree of fit with a given scenario. First clarify your requirements for compute, memory, context length, and post-training, then revisit the “energy–throughput–maintainability” mainlines to make trade-offs. Only then can you select a model form that genuinely suits your business, and use mature, general-purpose cloud capabilities in the deployment and operations stages to put stability into practice.