Open-Source LLMs On-Device: Memory, Architecture, and Multimodal Tradeoffs
Open-source large language models are moving off the cloud and onto phones, dev boards, vehicles, and edge workstations. Shipping a model to a device is not a matter of dropping weight files onto hardware — you are simultaneously constrained by memory, compute, power, modality support, and licensing. This guide lays out a practical decision path: choose the memory spec first (weights, KV Cache, and framework overhead), let the task define the required modality, and let the deployment scenario decide between Dense and MoE architectures. It compares Dense and MoE on total versus activated parameters, explains why native multimodal support determines whether an on-device workflow can actually close the loop, and details how long-context support depends on positional encoding, attention windowing, KV Cache management, and Per-Layer Embedding. It also covers inference framework selection, quantization, fine-tuning, compliance, and a short FAQ on what fits on an 8GB phone.
Open-source large models are moving from the cloud to phones, development boards, vehicles, and edge workstations. On-device deployment is not simply a matter of copying weight files onto hardware; it means meeting constraints on memory, compute, power, modality, and licensing all at once. The conclusions up front:
- Size the memory first. Start from the weight footprint, the KV Cache, and inference framework overhead, then decide whether the model can run stably.
- Let the task choose the modality. Voice interaction favors native audio; image and text understanding favors visual capability; long-document work favors long context and cache efficiency.
- Let the scenario choose Dense or MoE. When memory is tight, look at total parameters; when compute is the bottleneck, look at activated parameters and memory bandwidth.
1. Dense or MoE? Start With the Memory Budget, Then Look at Compute
In some recently released model families, the dense models actually have more parameters than their MoE counterparts. This is not a contradiction — each family was designed around its own optimization target. When you compare MoE against Dense, always state whether you are comparing within the same family and generation or across families. Otherwise you end up conflating different training objectives, different sparsity strategies, and different memory budgets.
Total parameters and per-token activated parameters are two separate dimensions. In a dense model, every token’s forward pass flows through all parameters, so activation equals the total parameter count. A mixture-of-experts model uses a gating network to select only a few experts per token, so activated parameters per token are typically much lower.
That does not automatically make MoE a good fit for devices. MoE only works where memory can hold all the experts. Low-bit MoE weights still approach the total parameter count in terms of actual memory traffic after dequantization, because the expert weights still have to stay resident or be paged in and out frequently. Low-batch on-device decoding is memory-bandwidth bound, and routing, expert switching, and dequantization all add memory access pressure.
The on-device selection rule should therefore be stated as: first look at the memory budget implied by total parameters, then look at the compute implied by activated parameters.
| Dimension | Dense | MoE |
|---|---|---|
| Total parameters | Matches the weight footprint | Possibly larger, but fewer parameters activated per token |
| Activated parameters | Equal to total parameters | Only a few experts activated per token |
| Weight memory | Determined by total parameters and quantization bit width | Determined by the total parameters across all experts |
| Compute per token | Grows with model size | Lower, but affected by routing and memory access |
| Typical device profile | Edge devices with ample memory that prioritize stable quality | Devices with enough memory to hold all experts |
| Fine-tuning cost | Smaller models are easier to fine-tune | All experts can raise fine-tuning and evaluation cost |
2. Does the Task Need Image, Audio, or Video? How Native Multimodality Affects the Loop
Whether an on-device model can close the loop depends on the input modality. Text is the baseline capability, but on-device applications are rarely chat-only.
For images, variable resolution improves detail fidelity, but visual tokens scale with it. As resolution increases or the number of tiles grows, context length, attention computation, and cache size all rise. You should therefore set caps on resolution, frame count, and a visual token budget.
Video understanding requires splitting video into frame sequences and accounting for the frame sampling rate, temporal alignment, and cache overhead. The more frames, the more visible the pressure on on-device memory and latency becomes. “Supports video” alone is not evidence that a model is deployable.
For audio, traditional on-device voice assistants typically use a two-stage pipeline: a speech recognition model plus a language model. That increases memory usage and introduces cascading errors. If a model accepts audio natively, the device can drop cascading components and their memory cost, handling listening, understanding, and responding in a single model. Native audio can still underperform dedicated ASR in noisy, far-field, or strong-accent conditions, so don’t judge by capability claims alone — measure accuracy and latency on real recording sets.
3. Why On-Device Long Context Eats Memory: RoPE, KV Cache, and Windowing
Long-context capability is not a single positional encoding trick. It is the combined result of positional encoding, attention windowing, KV Cache, and memory management. Rotary position embeddings (RoPE) and their variants are the common approach. One configuration alternates local sliding-window layers with global attention layers: local layers use standard RoPE and model within a limited window, lowering computational complexity; global layers use scaled RoPE (called p-RoPE in some models, belonging to the NTK/YaRN family of frequency scaling) to extend effective context by adjusting the wavelength across different dimensions.
On devices, however, the main long-context bottleneck is that the KV Cache grows linearly with context length. The longer the context, the larger the cache, because historical keys and values must be retained even if the model is generating only one token. Common mitigations include grouped-query attention (GQA) to reduce KV heads, KV quantization to lower cache bit width, and sliding windows to limit far-distance caching. Sliding windows can degrade long-range recall, and both GQA and KV quantization need accuracy evaluation.
Verifiable references: the sliding-window attention design in Mistral 7B, which bounds computation for long sequences; the YaRN paper (Peng et al., 2023) on frequency-scaled RoPE extension; and GQA in the Llama 3 family to reduce KV Cache overhead at inference time.
4. Not Enough Capacity to Be Smart? Per-Layer Embedding
In a standard Transformer, each token typically receives a single static embedding at the input, which all subsequent layers reuse. Per-Layer Embedding (PLE) offers an improvement on that idea: alongside the token embedding, a parallel low-dimensional conditional pathway generates a low-dimensional vector for each token at each decoding layer.
Illustrative code:
def layer_forward(x, per_layer_cond):h = attn(x) + x # Main representation pathwaycond = cond_proj(per_layer_cond) # Per-layer conditioning vectorh = h + cond # Inject the conditioning signal for this layerreturn ffn(h) + h
In the illustration, x is typically shaped [batch, seq, hidden], and per_layer_cond can be [batch, seq, layers, cond_dim] or sliced per layer into [batch, seq, cond_dim]. cond_proj maps the low-dimensional conditioning signal up to hidden. In practice the conditional branch usually needs normalization or scaling to keep its magnitude from conflicting with the main branch; initialization can use zero initialization or small-weight residual initialization. Real frameworks also give each layer its own projection and handle masking, caching, and batch dimensions.
The design value is in fusing token identity signals with context-aware signals, letting parameter-efficient small models schedule information more finely between shallow and deep layers. For low-latency, low-memory on-device scenarios, this kind of structural change is often more controllable than simply stacking more parameters.
5. How to Deploy: Inference Frameworks, Quantization, Fine-Tuning, and Compliance
Candidate inference frameworks include llama.cpp, MLC-LLM, LiteRT-LM, ExecuTorch, and ONNX Runtime GenAI. Don’t choose by name alone — verify operator support, data types, quantization schemes, memory management, and debugging tooling against your target chip’s NPU, GPU, and CPU, item by item.
On quantization, low-bit quantization reduces weight memory but brings accuracy loss and operator restrictions. Different layers, different attention operators, the vision encoder, or audio pre-processing may support different bit widths, and some operators may fall back to the CPU or require extra calibration.
A simplified formula works for memory budgeting: weight memory ≈ parameters × quantization bit width / 8. A 7B model at 4-bit comes to roughly 3.5GB, but that is only an approximation of the weights; the real total also needs KV Cache, visual token cache, framework overhead, and the operating system’s own usage. On an 8GB phone, usable memory is typically below the nominal figure, so leave headroom. MoE models with 32B or more total parameters generally do not suit phone-class memory, because the full expert set may not stay resident and paging or dequantization noticeably hurts the experience.
On fine-tuning, dense models in the billions-of-parameters range are usually a reasonable starting point, but what fits on a single card depends on available memory and your LoRA/QLoRA configuration. Larger models may require multiple cards, distributed training, or lower-bit quantization. Low-rank adaptation reduces the number of trainable parameters, but data quality, evaluation sets, and catastrophic forgetting still need assessment.
On compliance, verify commercial-use restrictions in the open-source license in advance, including redistribution, model naming, derivative works, and commercial use terms. On-device safety alignment and content moderation cannot be skipped either: configure input filtering, output policies, sensitive-data handling, and log redaction in the local deployment.
6. FAQ: How Big a Model Can Run on an 8GB Phone? Is MoE Good for Phones?
Q1: How large a model can run on an 8GB phone?
A: Don’t look at parameter count alone — look at available memory. At 4-bit quantization, a 7B model’s weights are around 3.5GB, and with KV Cache and framework overhead the total can approach the real usable ceiling of an 8GB device. Smaller 2B to 4B models are typically more stable.
Q2: Is MoE suitable for phones?
A: Not necessarily. MoE only works where memory can hold all experts. If total parameters are high, even low per-token activated parameters can still lead to memory or memory-access bottlenecks from resident weights, routing, and dequantization.
Q3: What are common on-device selection mistakes?
A: Looking only at benchmark scores; looking only at activated parameters while ignoring total parameters; ignoring KV Cache growth with context length; not evaluating native audio under noise and far-field conditions; not checking open-source license restrictions on commercial use.
Q4: Why does on-device long context eat memory?
A: Because the KV Cache grows linearly with context length and historical keys and values must be retained. GQA, KV quantization, and sliding windows can mitigate this, but each carries accuracy or recall costs.
7. Conclusion
Selecting an open-source on-device model is not about finding the one with the most parameters or the highest leaderboard score; it is about matching hardware constraints, task requirements, and architectural characteristics. Dense and MoE have different cost curves, native multimodality determines whether the workflow can close the loop, and dual positional encoding, KV Cache management, and parameter-efficient structures determine whether long context and small models are usable. Only by evaluating these engineering constraints in a single table can you make stable, low-power, deployable decisions on phones, edge boxes, and workstations.
