On-Device Open-Source LLMs: Model Size Selection and Architecture Guide

    On-device open-source LLMs are moving from raw benchmark competition toward usable experiences under hard constraints. This guide explains how to choose among dense, mixture-of-experts (MoE), and lightweight small models; whether native multimodality and native audio input can shorten the on-device pipeline; how dual RoPE and layer-wise conditional embeddings address long-context extrapolation and small-model expressiveness; and how to replace benchmark scores with real measurements such as time-to-first-token, throughput, peak memory, power draw, and quantization accuracy loss. It closes with an engineering checklist covering device selection, memory estimation, testing methodology, and licensing compliance.

    Introduction: How big a model should a phone or edge box run?

    On-device open-source LLMs are shifting from a “capability race” to “usable experience under constraints.” The question developers face is rarely “which model tops the leaderboard.” It is more often: How many parameters fit a phone or an edge box? How do dense and mixture-of-experts (MoE) designs trade off? Can native audio input remove an external module? What do you do when quantization costs accuracy?

    This article covers spec selection, architectural innovation, and deployment for on-device open-source LLMs. Specifically, it addresses how to choose among multiple model sizes, whether MoE is a good fit for the edge, how to extrapolate long context stably, how small models can gain expressive power, and how to replace leaderboard scores with measurements that reflect real usage.

    1. The multi-size lineup: dense, MoE, or a lightweight small model?

    Mature open-source model families usually ship several sizes, covering compute budgets from phones to workstations. Before choosing, understand how the three categories differ.

    1.1 Dense models: predictable deployment

    In a dense model, every forward pass runs all parameters, so parameter count and compute cost scale roughly linearly. The advantage is a fixed inference path with predictable memory and compute requirements, which makes operator fusion, quantization, and on-device compiler optimizations straightforward.

    For on-device use, dense models in the range of roughly 1B to 10B parameters are a common reference point, but whether a given size actually ships depends on memory bandwidth, operator support, the quantization scheme, context length, and device thermals. Phones generally suit smaller sizes or higher compression ratios; professional workstations can carry much larger parameter counts.

    1.2 MoE models: trading sparse activation for capacity

    Mixture-of-experts models split the network into several expert subnetworks, and a gating network selects a few experts per token. The defining trait is “large total parameters, few activated per token,” which can yield stronger expressiveness at a comparable inference compute budget.

    MoE is not automatically a win on-device, however. Memory still has to hold all expert weights, and routing introduces load imbalance, implementation complexity, and potential power fluctuation.

    The following sketch shows MoE routing logic. The key idea is to gather tokens per expert, then scatter the gating weights back to the original token positions correctly:

    1. import torch
    2. import torch.nn.functional as F
    3. # Illustrative only: router logits, top-k gating, and expert outputs must line up
    4. def moe_layer(x, router, experts, top_k=2):
    5. # x: [B*L, d_model]
    6. logits = router(x) # [B*L, num_experts]
    7. topk_val, topk_idx = logits.topk(top_k, dim=-1) # [B*L, top_k]
    8. # Compute gating weights only over the selected top_k experts
    9. gates_topk = F.softmax(topk_val, dim=-1) # [B*L, top_k]
    10. out = torch.zeros_like(x) # accumulates all expert outputs
    11. for expert_id, expert in enumerate(experts):
    12. # Locate the token positions routed to this expert and their gate slots
    13. token_pos, slot_pos = torch.where(topk_idx == expert_id)
    14. if token_pos.numel() == 0:
    15. continue
    16. x_tokens = x[token_pos] # [n_tokens, d_model]
    17. w_tokens = gates_topk[token_pos, slot_pos] # [n_tokens]
    18. y = expert(x_tokens) # [n_tokens, d_model]
    19. # Scatter expert outputs back to the original tokens, weighted by the gate
    20. out.index_add_(0, token_pos, y * w_tokens.unsqueeze(-1))
    21. return x + out

    This avoids the shape mismatch you get from applying gating weights to a boolean mask directly, and it ensures that a token’s multiple expert outputs are accumulated correctly.

    1.3 Lightweight small models: for extremely constrained hardware

    For the scenarios most sensitive to power draw and heat, vendors typically offer a smaller, more efficient variant. The goal of these models is not peak capability but remaining usable under very tight memory, low compute, and low power. They often include dedicated design work on embedding efficiency, activation sparsity, conditional embeddings, and quantization friendliness.

    1.4 Comparing the three categories

    Type Parameters vs. compute Memory / VRAM profile Typical use Main drawback
    Dense All parameters participate in every pass Relatively predictable Phones, edge boxes, workstations Capability ceiling limited by parameter count
    MoE Large total, few activated Must still hold all expert weights Memory-rich devices that want more capacity Complex routing, heavy memory pressure
    Lightweight small Few parameters, low activation Friendly to memory and power Low-power devices, lightweight offline tasks Limited complex reasoning ability

    2. Native multimodality: can it shorten the on-device pipeline?

    When an application runs on-device, a shorter pipeline is easier to keep under control in terms of latency, power, and footprint. Early designs bolted separate speech recognition, vision encoding, and text understanding modules onto the model and stitched them together with glue code. The result was complicated deployment, higher latency, and larger resource consumption.

    Newer open-source models tend to unify text, image, video, and audio inputs inside a single model. Native audio input is particularly valuable on-device. If the model can understand a short audio clip on its own — for example, a voice command a few tens of seconds long — the on-device application can depend less on an external ASR component, or drop it entirely, and close the loop from “voice in → understanding → action.”

    That matters for phone voice assistants, in-car interaction, and offline smart speakers: shorter pipelines, lower latency, and a smaller deployment footprint.

    3. Long context and dual RoPE: balancing local precision with global extrapolation

    A Transformer’s positional encoding determines how the model perceives distance and order between tokens. Rotary position embedding (RoPE) injects positional information through rotation and is widely used for long-context extrapolation.

    A single RoPE configuration often struggles to satisfy two goals at once: positional relationships must be precise within a local window, while long-range spans must extrapolate stably. Some models therefore adopt a dual RoPE strategy:

    • Sliding-window layers use standard RoPE, focusing on the local window so that nearby token relationships stay stable;
    • Global attention layers use scaled RoPE or p-RoPE, rescaling positions so attention remains reliable over longer spans.

    This “precise locally, stable globally” combination helps with long documents and long conversation histories.

    One caution: it is not accurate to claim simply that “overall complexity drops from quadratic in sequence length to linear.” A more precise statement is that when most layers use sliding windows and only a few are global, overall complexity approximates linear behavior; the actual benefit still depends on window size, the ratio of global layers, operator implementation, and KV cache strategy.

    If the model has N layers, of which g are global attention layers, with window size W, the approximate cost is:

    1. total attention cost ≈ g * O(L^2) + (N - g) * O(L * W)

    When g is small and W is fixed, total cost grows closer to linearly as sequence length L increases. But the more global layers there are, and the larger the window, the more long-context cost still rises.

    4. Layer-wise conditional embeddings: how do small models get token information on demand?

    In a standard Transformer, each token enters the model with a single initial embedding vector. That means the initial embedding has to “pre-package” information that every later layer might need. It is information-dense, but reuse efficiency is limited.

    Layer-wise conditional embeddings take a different approach: beyond the main embedding, each token gets a set of low-dimensional conditional vectors that are injected at different decoding layers on demand. Token identity signals and context-aware signals can then be partially decoupled, and each layer can obtain extra information when it needs it.

    Conditional vectors can come from a small conditional encoder — for example, derived from the token embedding, a lightweight convolution, a low-rank projection, or a separate conditioning network. Their dimension is usually far smaller than the main model dimension: d_cond might be 32, 64, or 128, while the main model dimension could be 1024 or higher.

    There are several ways to organize conditional vectors:

    • One low-dimensional conditional vector per token, up-projected separately by each layer;
    • One set of conditional vectors per decoding layer, shaped conceptually as cond_vectors with length equal to the number of layers;
    • When fusing conditional vectors with the main embedding, use addition, gating, scaling, or a normalized residual injection.

    The sketch below shows one forward path:

    1. # Illustrative only: cond_vectors should map one-to-one onto layers
    2. def forward(tokens, cond_vectors, layers, token_embedding, output_head, mask_builder):
    3. # tokens: [B, L]
    4. h = token_embedding(tokens) # main embedding: [B, L, d_model]
    5. # cond_vectors: list[Tensor], length equal to layers
    6. # each item shaped: [B, L, d_cond]
    7. for i, layer in enumerate(layers):
    8. cond = layer.cond_up(cond_vectors[i]) # [B, L, d_cond] -> [B, L, d_model]
    9. # Fusion can be swapped for gating, scaling, normalization, or residual
    10. cond = layer.cond_gate(cond)
    11. h = layer.norm(h + cond)
    12. h = layer(h, attn_mask=mask_builder(i))
    13. return output_head(h)

    For a lightweight small model with a tight parameter budget, this cheap conditioning path can improve expressiveness without adding many parameters.

    5. Beyond benchmark scores: how do you measure the real experience?

    Public benchmarks capture part of a model’s capability, but the on-device experience also depends on latency, memory, power, stability, and task completion rate. Developers should not read only rankings; they should measure on the target device.

    At minimum, track these metrics:

    • Time to first token: the metric users feel most directly;
    • Output throughput: tokens generated per second;
    • Peak memory: maximum memory usage during inference;
    • Quantization accuracy loss: difference on business data before and after quantization;
    • Power and temperature rise: whether sustained runs trigger throttling;
    • Stability: whether long conversations, back-to-back requests, or malformed input cause crashes.

    A reasonable test procedure:

    1. Fix input length, output length, and generation parameters;
    2. Warm up the device before measuring, to avoid cold-start effects;
    3. Run multiple requests and take the median or P90 rather than a single sample;
    4. Build the evaluation set from real business data, not public benchmarks alone;
    5. Record results separately for pre-quantization, post-quantization, long context, and high concurrency.

    6. FAQ: how do you choose an on-device open-source LLM?

    How do you choose an on-device open-source LLM?

    Use a three-step process:

    1. Check memory and compute first: confirm the device can hold weights, KV cache, activations, and system overhead;
    2. Then check scenario requirements: do you need image, audio, video, long context, or tool calling;
    3. Finally measure on the target device: time to first token, throughput, peak memory, and quantization accuracy.

    Is MoE a good fit for phones?

    Not necessarily. MoE’s advantage is large total capacity with few parameters activated per token, but only if the device can hold all expert weights. On a phone with limited memory and lower bandwidth, or with an inference framework whose MoE routing support is immature, MoE may be less stable than a dense small model in the same parameter range.

    Phones are generally a better fit when:

    • Memory can hold all weights;
    • The inference framework supports sparse routing and expert parallelism;
    • The scenario demands more capability headroom than absolute minimal power;
    • The team can handle routing variance and accuracy fluctuation.

    What are the pitfalls of native audio input?

    Native audio input can shorten the pipeline, but watch for:

    • Whether sample rate and channel count match what the model expects;
    • Whether short audio gets truncated or ignored;
    • Whether noise, far-field capture, and echo affect understanding;
    • Whether you still need a wake word, VAD, or denoising pre-processing;
    • Whether uploading audio raises privacy concerns, and whether fully offline operation is possible;
    • How well the model covers multiple languages, accents, and speaking rates.

    What do you do when quantization costs accuracy?

    Work through this order:

    • Use a representative calibration set, not random text;
    • Keep sensitive layers at higher precision, such as embeddings, normalization layers, and the output layer;
    • Compare bit widths, such as INT8, INT4, and mixed precision;
    • Check whether long context and multi-turn dialogue degrade;
    • If needed, apply light distillation or instruction fine-tuning;
    • Judge by the business evaluation set in the end, not a single metric.

    7. An engineering checklist for on-device deployment: from memory to security

    When deploying a model to real hardware, follow this checklist.

    7.1 Target device selection

    • Identify CPU, GPU, NPU, memory bandwidth, and storage capacity;
    • Confirm inference framework and operator support;
    • Evaluate thermals, power limits, and stability under sustained load;
    • Establish separate benchmark environments for phones, edge boxes, and workstations.

    7.2 Memory estimation before and after quantization

    A rough estimate:

    1. weight memory ≈ parameter count × bytes per parameter
    2. actual runtime memory ≈ weight memory + KV cache + activations + runtime overhead

    For example, at INT8 each parameter takes roughly 1 byte, and at INT4 roughly 0.5 bytes, but real deployment also adds scale factors, alignment overhead, KV cache, and runtime buffers.

    7.3 Time-to-first-token testing

    • Fix the prompt length;
    • Warm up for several rounds;
    • Record P50 and P90 time to first token;
    • Test both short and long inputs separately;
    • Check whether results are affected by model loading, tokenization, or memory paging.

    7.4 Throughput and peak memory testing

    • Measure tokens/s with output length fixed;
    • Use system tools or the inference framework to monitor peak memory;
    • Test long context separately, since KV cache grows;
    • For multi-turn dialogue, watch cache hits and memory release.

    7.5 Power and temperature testing

    • Record power in three phases: idle, loading, and inference;
    • Watch for thermal throttling during long continuous inference runs;
    • For in-car, wearable, and speaker scenarios, power often matters more than peak performance.

    7.6 Model licensing and compliance

    • Verify the open-source license, including commercial use, redistribution, and modification terms;
    • Check whether the training data sources permit your intended use;
    • If user speech, images, or text are involved, apply privacy de-identification;
    • Even for offline deployment, consider log security, model integrity verification, and permission isolation.

    7.7 Device-cloud collaboration

    If the on-device hardware needs cloud assistance, general-purpose cloud services can handle request distribution, model weight distribution, monitoring and alerting, and log analysis. For example, a container platform can host inference services with elastic scaling, object storage can manage model files, and monitoring and alerting can track latency, memory, and error rates.

    Conclusion: real measurement and the right match decide on-device success

    Competition among on-device open-source LLMs is fundamentally an engineering contest: approaching a usable experience under memory, compute, power, and latency constraints. The multi-size lineup defines the selection space, native multimodality and native audio compress the on-device pipeline, and architectural innovations such as dual RoPE and layer-wise conditional embeddings seek balance between efficiency and capability.

    For developers, the priority is not chasing parameter counts or benchmark scores. Establish the resource boundaries on the target device first, then use real business data to evaluate time to first token, throughput, peak memory, and quantization accuracy. Only when that loop — from understanding specs to measured verification — is closed can an on-device LLM actually run on the device.