Dense vs MoE for On-Device LLMs: An Open-Source Model Selection and Deployment Guide

    One of the most common questions in on-device AI is whether to choose a dense or a Mixture-of-Experts (MoE) architecture for open-source LLMs. This guide explains why leaderboard rankings alone are a poor basis for on-device selection, then walks through the factors that actually matter: total versus active parameters, the memory footprint of weights and KV Cache, native multimodal and audio input, long-context stability via position encoding, Per-Layer Embeddings, and a five-point checklist for choosing a fine-tuning base. It closes with practical deployment details—quantization formats (GGUF, AWQ, GPTQ, FP8), inference frameworks, and the metrics worth measuring (resident memory, TTFT, tokens/s, KV Cache growth)—plus a quick FAQ and three decision paths.

    1. Why On-Device Selection Shouldn’t Rely on Leaderboard Rankings Alone

    For the past few years, the center of gravity for open-source LLM capabilities has been in the cloud: bigger parameters and higher leaderboard scores were treated as a proxy for “stronger.” After 2025, the trend shifted. More and more releases emphasize parameter efficiency and on-device runnability, with the goal of letting billion-parameter-scale models do on phones, single-board computers, and home workstations what previously required an internet connection.

    The engineering motivation is straightforward. Cloud inference incurs network latency, bandwidth costs, and privacy tradeoffs, and it bills you continuously per call. On-device inference keeps data local and eliminates per-call fees.

    But one thing needs to be stated clearly: “faster” is not a universal fact. On-device latency depends heavily on model size, quantization bit-width, hardware (NPU/GPU/CPU), and the inference engine’s compilation and operator optimization. What is certain is this: when the specialized inference stack is well supported and the model size matches memory bandwidth (for example, 1B–4B scale, INT4 quantization, running on an NPU or GPU backend), on-device inference can significantly reduce response latency, bringing first-token latency for a single interaction down to the hundreds-of-milliseconds range, which feels close to “instant.” This is not a guaranteed figure—variance across devices is large, so your own benchmark data must be the deciding factor.

    2. Dense or MoE? Look at the Memory Bill First, Then Active Parameters

    • Dense models: Every token passes through all parameters. The structure is regular, the weight footprint is predictable, and the inference implementation is simple. They have an edge when you’re chasing the capability ceiling or need a high-quality base for fine-tuning.
    • Mixture-of-Experts (MoE): Composed of multiple expert submodules, with each token routed to only a subset of them. Total parameters can be very large, but active parameters per token are few—what’s saved here is compute, bandwidth, and latency.

    One common misconception needs correcting: MoE saves on “per-token computation,” not on “resident weight memory.” All expert weights must be loaded into memory or VRAM; only a small portion is read at each step. So MoE fits scenarios where “memory is sufficient but compute is tight,” not scenarios where you “choose MoE because memory is insufficient.”

    Another observation that often gets over-generalized: in some releases, the Dense version actually has more total parameters than the MoE version of the same series. The Qwen3 series is a case in point—it offers both Dense (including 32B) and MoE (30B-A3B, roughly 3B active) variants. The Dense 32B has more total parameters but activates all of them per token; the MoE version has slightly fewer total parameters with only about 3B active (refer to the official model cards for exact numbers). This is a tradeoff under a specific design goal, not a rule that “MoE total parameters are usually smaller.” MoE targets inference cost-efficiency; Dense targets the capability ceiling and ease of fine-tuning. When selecting, write down both numbers—“total parameters” and “active parameters”—because they answer two different questions.

    1. def mem_estimate(total_params_b, bits, layers, kv_heads, head_dim, ctx, kv_bytes=2):
    2. """Roughly estimate resident weight memory and KV Cache (GiB) for on-device memory budgeting.
    3. bits: weight bit-width, FP16=16 / INT8=8 / INT4≈4 (including scaling factors, usually slightly higher in practice)
    4. kv_bytes: bytes per KV element, FP16=2 / INT8=1
    5. """
    6. w_gib = total_params_b * 1e9 * bits / 8 / 1024**3
    7. kv_gib = 2 * layers * kv_heads * head_dim * ctx * kv_bytes / 1024**3
    8. return w_gib, kv_gib
    9. # Example: MoE with 30B total params, INT4, 48 layers, GQA with 4 KV groups, head_dim 128, 32K context
    10. w, kv = mem_estimate(30, bits=4, layers=48, kv_heads=4, head_dim=128, ctx=32768)
    11. print(f"Resident weights ≈{w:.1f} GiB KV Cache ≈{kv:.2f} GiB Total ≈{w + kv:.1f} GiB")
    12. def pick(ram_budget_gib, moe_total_gib, moe_active_b, dense_total_gib, want_deep_finetune):
    13. if want_deep_finetune:
    14. return "Dense: regular structure, full activation; training and fine-tuning are more direct"
    15. if moe_total_gib <= ram_budget_gib:
    16. return f"MoE: weights fit, only {moe_active_b}B active, inference is more compute-efficient"
    17. if dense_total_gib <= ram_budget_gib:
    18. return "Dense: smaller scale, predictable footprint"
    19. return "Insufficient budget: quantize to INT4 first, or switch to a smaller base"

    3. On-Device Agents: Do You Need Natively Multimodal and Audio-Input Models?

    Truly valuable on-device scenarios are often not pure text Q&A, but ones that need to “see” and “hear”:

    • Unified multimodal input: An ideal on-device model can simultaneously accept text, images (supporting variable resolution to adapt to different clarity levels), and even video frames, performing visual understanding and language reasoning within a single model rather than chaining several independent models together.
    • Native audio input: Some lightweight models now support audio inputs up to tens of seconds long. The engineering payoff: if a model can understand audio directly, there’s no need to bolt on a separate ASR pipeline, which saves extra model size, memory footprint, and chaining latency, and significantly simplifies on-device Agent deployment.

    Take an on-device multimodal assistant as an example. With the offline speech and local NPU inference pipeline in place, and camera and microphone data not leaving the device, it can genuinely complete the “read the scene—understand the instruction—respond locally” loop without going online. But add a caveat: once complex reasoning is required and it falls back to a cloud large model, the real form becomes device-cloud collaboration, not a purely offline solution. When selecting, write “whether offline operation is mandatory” into your requirements as a hard constraint, so you don’t have to overturn the architecture later.

    4. Is Long Context Stable? First Check How Position Encoding Is Configured

    The mainstream approach is Rotary Position Encoding (RoPE): it rotates the query and key vectors to inject relative position information and has some extrapolation potential. The problem is that when a model contains both sliding-window attention layers (local, low-cost) and global attention layers (covering the full sequence), a single RoPE configuration struggles to satisfy both ends. Local layers need fine-grained short-range resolution, while global layers need to reliably distinguish positions even at extreme distances.

    A more refined approach is a dual RoPE configuration: sliding-window layers use standard RoPE to guarantee short-range resolution, while global attention layers use scaled RoPE (p-RoPE), which adjusts the position scaling factor so that position encoding can still reliably distinguish distant tokens under ultra-long contexts.

    A note on lineage, for verifiability: RoPE’s native extrapolation ability is limited, and the industry has developed a family of methods that “adjust position/scaling factors proportionally” along the line of Position Interpolation (PI) → NTK-aware scaling → YaRN. p-RoPE belongs to the same line of thinking, applied in a layered way within hybrid attention structures (refer to the corresponding technical reports for specific implementations and naming). The engineering implication is concrete: when choosing a model, confirm whether a long-context version or configuration is available, and estimate the growth of the KV Cache under long sequences—it scales linearly with layers, KV heads, head_dim, and context length, and is often the real cause of on-device OOM.

    5. What Problem Do Per-Layer Embeddings Solve?

    First, correct an inaccurate premise in the original claim: in a standard Transformer, the input token embedding is indeed static and shared across layers, but context information is not “stuffed into the initial embedding all at once.” It is mainly passed and updated layer by layer through attention and the residual stream. So the argument that “information placed into the initial vector will necessarily be diluted in deep layers” doesn’t hold.

    The real value of Per-Layer Embeddings is something else: beyond the shared initial embedding, it adds a parallel low-dimensional conditioning pathway that generates a small set of vectors for each token, which each decoder layer can draw on as needed. It decouples “token identity” from “current context state,” making information routing more flexible, while the extra parameters and compute overhead of the low-dimensional pathway are small—especially friendly to memory- and bandwidth-sensitive on-device settings. In terms of lineage, this approach shares roots with adaptive LayerNorm and FiLM-style conditioning injection, all of which use per-layer learnable conditioning signals to modulate representations (refer to the corresponding papers or technical reports for the specific mechanisms).

    1. Standard approach: token -> shared embedding E -> attention + residual stream pass and update context layer by layer
    2. Per-Layer Embeddings: token -> E + per-layer small vectors {e1, e2, ..., eL}
    3. Each layer fuses the token-identity signal with the context-state signal as needed (low-dimensional, low-overhead)

    6. How to Choose a Base Model for Fine-Tuning? Check These Five Items

    1. Scale and compute matching: For on-device use, prioritize architectures with few active parameters and weights that fit; only consider a larger Dense base if you have headroom for private deployment.
    2. Modality coverage: If your work involves images, video, or audio, choose native support to avoid the complexity and latency of bolting on multiple pipelines.
    3. Context length: For long-document or long-video scenarios, test stability at the target length and confirm whether the position encoding has been optimized for long contexts.
    4. Ecosystem and toolchain: Fine-tuning requires supporting training frameworks, quantization tools, and evaluation systems. A mature ecosystem significantly lowers the cost of getting to production.
    5. Licensing and compliance: Confirm that the open-source license permits commercial use and redistribution, to avoid legal risk down the road.

    7. How to Deploy On-Device? Quantization Formats, Inference Frameworks, and Metrics to Test

    Quantization formats: GGUF (llama.cpp / Ollama ecosystem, the first choice for CPU and hybrid inference, with common tiers like q4_k_m), AWQ (activation-aware weight quantization, GPU-inference friendly), GPTQ (post-training quantization, common for GPU deployment); you can also consider FP8 where hardware supports it.

    Inference frameworks: llama.cpp and Ollama (fast validation and prototyping), MLC-LLM (mobile and browser), ONNX Runtime GenAI and QNN (Qualcomm NPU), MediaPipe LLM Inference (Android), TensorRT-LLM (NVIDIA GPU), vLLM / SGLang (server-side and high-concurrency private deployment).

    Metrics to test and how to verify them: resident and peak memory (RSS / GPU VRAM), first-token latency (TTFT), decoding speed in tokens/s (mainly constrained by memory bandwidth), KV Cache growth under long context, P95 latency across continuous multi-turn sessions, and power draw plus thermal throttling during sustained operation. For the test method, use a fixed prompt and output length, warm up first, then take P50/P95, and run for 30 minutes or more to observe whether throttling kicks in.

    A recommended rhythm: first do a small-scale validation on the target hardware (pass on three things—peak memory, TTFT, and throughput), then decide whether the quantization tier needs trimming, and only then move on to fine-tuning and integration. This avoids sinking training cost into the wrong base.

    8. Quick Answers to Common Questions

    Q: How large a model is suitable for on-device use?
    A: Start from your memory budget minus what the OS and apps consume. Account for resident weights + KV Cache + peak activation, and staying within roughly 60%–70% of available memory is generally safe.

    Q: Dense or MoE?
    A: If you need deep fine-tuning and a regular structure, choose Dense. If memory is sufficient but compute/power is tight and you want interaction cost-efficiency, choose MoE.

    Q: Does on-device deployment always require multimodality?
    A: No. If the task is pure text or structured input, multimodality only adds weight size and memory pressure. It’s worth it only when you genuinely need visual or audio input.

    Q: What are the most common beginner mistakes?
    A: Looking only at total parameters and ignoring active parameters; treating MoE as a memory-saving scheme; jumping straight to FP16 and overlooking the gains from quantization; measuring throughput but not TTFT; assuming quantization is lossless (you need a small evaluation set for regression); and ignoring license restrictions on commercial use.

    Q: What else is needed for private deployment?
    A: Such models typically need to work alongside object storage, message queues, container platforms, logging services, and monitoring/alerting. Bring the quantized versions, model fingerprints, latency, and failure rates into your observability system, so you can support a stable, end-to-end AI capability from device to cloud.

    9. Conclusion: Three Decision Paths

    • Need on-device real-time response, low latency, and offline capability: Prioritize lightweight models with few active parameters, native multimodal and audio support, and position encoding optimized for long contexts.
    • Need the capability ceiling or a deep fine-tuning base: Prioritize Dense models with a regular structure and a direct training path.
    • Need something that fits in memory but has tight compute: Choose MoE, and account for both constraints at once—“total parameters fit” plus “active parameters save compute.”

    What ultimately determines real-world results is how well the model architecture, modality capabilities, and deployment environment match each other—not the leaderboard ranking. Put three metrics on your selection checklist first: memory budget, TTFT, and throughput. Only then discuss architecture preferences.