On-Device Deployment of Open-Source Large Models: Architecture Choices and Multimodal Practices
Deploying large language models on edge devices is becoming a practical alternative to cloud-only inference, driven by low latency, offline operation, data privacy, and lower long-term cost. This article examines how a new generation of open-source, on-device-optimized model families address these needs across the full compute spectrum, from embedded devices to professional workstations. It covers model tiering and the trade-offs between dense and Mixture-of-Experts (MoE) architectures, native multimodal input (text, image, video, and audio), long-context handling through a hybrid of standard and proportional RoPE position encoding, and Per-Layer Embeddings (PLE) for on-demand information injection. It closes with practical engineering guidance on quantization, inference runtime adaptation, resource and latency profiling, and cloud-edge collaboration.
1. Background: Why Open-Source Small Models Are Gaining Ground
Over the past few years, the center of gravity for large-model deployment has been the cloud data center. But a clear trend is now emerging: inference is progressively moving down to the edge. The reasons are straightforward. On-device inference naturally offers low latency, the ability to run offline, data that stays local (friendly to privacy and compliance), and lower long-term cost per call. For scenarios such as phone assistants, smart home devices, wearables, and embedded platforms like the Raspberry Pi, relying on cloud round trips introduces not only network latency but also privacy and reliability risks.
The emergence of open-source models has significantly lowered the barrier to this trend. When weights, architecture, and inference code are public, developers can perform quantization, pruning, fine-tuning, and deployment on their own hardware without being constrained by a single closed API. A recent wave of open-source model families optimized for on-device use follows a common design philosophy: use a set of models spanning different parameter sizes and architectural approaches to cover the entire compute spectrum, from embedded devices to professional workstations. This article takes the public technical characteristics of such models as a backdrop and abstracts the general engineering methods behind them.
2. Model Tiers and Architecture: Choosing Between Dense and MoE
A mature on-device open-source model family typically offers more than a single size. It divides models into multiple tiers by parameter count and compute characteristics, roughly corresponding to three classes of hardware:
- Ultra-small efficient tier (around 2B–4B parameters): Targets compute- and memory-constrained devices such as phones, wearables, and the Raspberry Pi, emphasizing local execution on a single GPU or SoC.
- Mid-size dense tier (multi-billion parameters, dense structure): Targets laptops or professional workstations with meaningful compute, balancing per-request quality with inference throughput.
- Mixture-of-Experts tier (multi-billion parameters, MoE structure): Has larger total parameters but, through sparse activation, keeps the actual compute per forward pass close to that of a smaller dense model.
The key to understanding these tiers lies in distinguishing the fundamental difference between dense models and Mixture-of-Experts (MoE) models:
- Dense models: Every token activates all parameters, so compute is strongly correlated with parameter count. The advantages are stable behavior, simple deployment, and predictable memory usage. The drawback is that as parameter scale grows, the cost of a single inference step rises linearly.
- MoE models: Split the feed-forward layers into multiple “experts” and introduce a router that selects and activates only a few experts for each token. This way, total parameter capacity can be made large (carrying more knowledge) while per-token compute is held down by sparse activation. The cost is higher routing-related load balancing, greater memory usage, and increased engineering complexity.
So the central question in model selection is not “which model has more parameters and is therefore better,” but rather “what are the compute budget, memory ceiling, and latency requirements of the target device?” On demanding scenarios like phones, an ultra-small dense model is often easier to deploy than an equivalently sized MoE model. On a workstation with ample memory, however, an MoE model can deliver stronger expressive power at a compute cost close to that of a small model. In addition, different tiers often share the same tokenizer and parts of the weight structure, making it easier to layer capabilities and upgrade smoothly within the same product line.
# Example: selecting model tiers for different devicesdeployment_targets:- device: "phone / wearable"tier: "efficient-small" # ~2B-4B, dense and efficientconstraint: "low latency, low memory"- device: "laptop / workstation"tier: "dense-mid" # multi-billion denseconstraint: "quality first, offline capable"- device: "local server / workstation"tier: "moe" # sparse activation, larger total parametersconstraint: "high expressiveness, ample compute"
3. Native Multimodal Input: One Model for Text, Image, Video, and Audio
A key capability boundary for an on-device agent is whether it can “see” and “hear” the real world. A defining trait of this new generation of on-device models is native support for text, image (at variable resolution), and video input, with some efficient tiers going further to add native audio input.
The most engineering-relevant aspect here is the native support for audio input. Traditional on-device voice solutions often follow a “two-stage” pipeline: first use an external speech recognition (ASR) model to convert speech into text, then feed that text to the language model. This chain has clear problems — it requires maintaining an additional ASR model, consumes more memory, accumulates cascading errors, and struggles to preserve paralinguistic information such as tone, pauses, and pitch in speech.
When a model natively supports audio input (for example, handling audio clips on the order of tens of seconds), this chain can be significantly simplified: speech enters a unified multimodal understanding flow directly, with no need for an external recognition module. This directly reduces the number of components, memory usage, and end-to-end latency of the on-device system, and makes the “voice trigger → intent understanding → task execution” on-device agent more compact.
The significance of multimodal input for on-device applications shows up in several ways:
- A unified semantic space: Text, image, audio, and video are mapped into the same representation space, letting the model perform cross-modal reasoning (for example, “does this image contain the thing I just mentioned?”).
- Reduced system complexity: Fewer independent models to deploy and tune within the cascading pipeline.
- Better on-device agent usability: Cameras, microphones, and screens become natural input sources, supporting interactions closer to real-world usage.
It is worth noting that multimodality is not a “free lunch.” Image resolution, video frame count, and audio duration all directly affect preprocessing overhead and memory usage. On-device deployment usually requires balancing quality and resources through quantization combined with input cropping.
4. The Key to Long Context: Dual RoPE Hybrid Position Encoding
On-device models increasingly need to handle longer inputs — multi-turn conversations, long documents, code context, video temporal information, and so on. A built-in bottleneck of the attention mechanism is that compute and memory overhead rise sharply as the sequence grows. A common industry compromise is sliding window attention, where each token attends only to neighbors within a local window, reducing complexity from global quadratic levels.
But this introduces a problem: a pure sliding window lacks global visibility, and long-range dependencies get cut off. One approach used by the new generation of on-device models is a dual position-encoding configuration, combining “local” and “global” attention layers:
- Sliding window layers use standard RoPE (rotary position encoding): They efficiently model local relationships and control compute cost.
- Global attention layers use proportional RoPE (p-RoPE, a position encoding that scales frequencies proportionally): They maintain long-range, global context associations.
The core idea of RoPE is to encode relative positions by rotating vectors, and its performance on long-context extrapolation is highly sensitive to the “frequency scaling strategy.” The idea behind proportional RoPE is to scale position frequencies in the global layers (similar to position interpolation), so the model can extrapolate relatively stably to longer contexts beyond its training length, rather than letting the position encoding “go out of bounds” and fail.
# Example: local + global hybrid position encodingposition_encoding:sliding_window_layers:type: rope # standard RoPE: models local relationships, controls computewindow_size: 1024global_attention_layers:type: p_rope # proportional RoPE: supports long-range and long-context extrapolationfrequency_scale: ... # scales position frequencies to extend effective context length
Through this division of labor — “local layers handle efficiency, global layers handle visibility” — the model can balance long-context capability and inference efficiency under limited compute. This is precisely what enables on-device handling of long documents, long conversations, and video temporal information.
5. Per-Layer Embeddings (PLE): An On-Demand Path for Conditioning Information
A standard Transformer carries an implicit assumption: each token receives only a single embedding vector at input. That embedding must “pack in,” at the entry point, all the information that every subsequent layer might need — the token’s identity information and context-relevant information alike are crammed into this one vector. As the layers deepen, if information needed by the deeper layers is not fully preserved, an expressiveness bottleneck appears.
Per-Layer Embeddings (PLE) is an improvement idea aimed at exactly this problem, and some efficient on-device tiers inherit and refine a similar mechanism. Its core construction is:
- In addition to the original token embedding, add a parallel, low-dimensional conditioning path;
- This path generates a dedicated small vector for each decoding layer;
- As a result, each token’s representation combines both a token identity signal and a context-aware signal;
- The outcome is that each layer can receive token-specific information on demand when needed, without having to pack everything into the initial embedding at the entry point.
The value of this mechanism lies in “information decoupling” and “on-demand supply.” In the traditional approach, the initial embedding must serve both as an identity marker and as a store for context needed by deeper layers, coupling the information tightly and easily causing congestion. PLE separates these two types of signals: identity information is carried stably by the backbone embedding, while context-related, layer-specific fine-grained information is supplied layer by layer through the low-dimensional conditioning path. Because the conditioning vectors are low-dimensional, the extra overhead stays relatively manageable, yet the mechanism can markedly improve the model’s expressiveness in deep layers and its stability under long context.
# Example: on-demand injection logic for Per-Layer Embeddings (PLE)import torchimport torch.nn as nnclass PerLayerEmbedding(nn.Module):def __init__(self, hidden_dim, ple_dim, num_layers):super().__init__()# Parallel low-dimensional condition path: generates a dedicated small vector per decode layerself.proj = nn.ModuleList([nn.Linear(ple_dim, hidden_dim) for _ in range(num_layers)])def forward(self, token_embeds, context_signal):# token_embeds: backbone token identity embeddings# context_signal: low-dimensional condition signal carrying context-aware informationper_layer_inputs = []for layer_idx, proj in enumerate(self.proj):cond = proj(context_signal) # project low-dim condition to this layer's dimensionper_layer_inputs.append(token_embeds + cond) # this layer receives token-specific info on demandreturn per_layer_inputs
6. Engineering Practices for On-Device Deployment and Cloud-Edge Collaboration
Turning the capabilities above into something that actually runs on a device requires a series of engineering steps. These steps are vendor-independent and represent general best practices:
- Quantization and compression: On-device compute and memory are limited, so weights typically need INT8/INT4 quantization, often combined with KV cache quantization to control memory growth under long context. After quantization, quality loss must be re-evaluated, especially on multimodal and long-context tasks.
- Inference runtime adaptation: Compute backends (NPU, GPU, CPU) vary widely across devices. Choosing the right on-device inference runtime and performing operator-level tuning are necessary to make full use of the hardware.
- Resource and latency profiling: Establish baseline profiles for latency, peak memory, and power consumption on the target device, and use them to decide the model tier, context length, and maximum input resolution.
- Cloud-edge collaboration: A purely on-device approach cannot cover every scenario. A common pattern is to handle high-frequency, privacy-sensitive, low-latency tasks on the device and offload complex tasks to the cloud on demand. Asynchronous task scheduling via message queues, model and data versioning via object storage, cloud inference services hosted on a container platform, and end-to-end observability through logging and monitoring/alerting services together make up this architecture. Building on such general-purpose capabilities offered by cloud platforms like Baidu AI Cloud, it is fairly straightforward to assemble a layered “on-device real-time response + cloud fallback and enhancement” architecture.
7. Summary
The technical highlights of on-device open-source large models can be distilled into four main threads: on the architecture front, the division of labor between dense and MoE models matches the full compute spectrum from embedded devices to workstations; on the capability front, native multimodality (text/image/video/audio) simplifies the on-device agent pipeline and eliminates the burden of an external ASR module; on the long-context front, a local–global hybrid configuration of standard RoPE and proportional RoPE balances efficiency and visibility; and on the representation front, Per-Layer Embeddings (PLE) decouple token identity from context-aware signals and inject them layer by layer on demand. For developers, the real key to successful deployment is not blindly chasing larger parameters, but rather doing architecture selection, quantization and compression, and cloud-edge collaboration around the target device’s constraints of compute, memory, latency, and privacy — that is the right way to build efficient intelligent applications on the edge.
