On-Device Multi-Size Small Model Architecture: Deployment Selection Guide
Small models for edge devices face limited memory, tight power budgets, and offline or data-locality requirements, so their architecture and evaluation need dedicated design. This article explains how a multi-size model family can share one architecture across hardware tiers through homogeneous scaling, then discusses the engineering implications of native multimodal processing and hybrid attention for long context. It also covers practical methods for estimating weight memory, measuring latency and throughput, and choosing a model size based on device and workload constraints.
1. Why On-Device Small Models Need Dedicated Design
Cloud large models rely on abundant VRAM, continuous network connectivity, and stable power. Edge devices such as laptops, mobile terminals, industrial gateways, and automotive systems often have only a few GB to tens of GB of available memory, power budgets measured in watts, and many scenarios that require offline operation or keep data on the device. These constraints mean the design goal for on-device models is not merely “fewer parameters.” The model must simultaneously satisfy time to first token, throughput, peak memory, and task accuracy under fixed resources.
The value of a multi-size model family is that one architecture can cover different hardware tiers. Developers can maintain a single technical pipeline and switch between small and large models according to device conditions, without re-adapting inference code, prompt templates, and evaluation systems for each size.
2. Homogeneous Scaling: Depth and Width Within One Architecture
Homogeneous scaling means models of different sizes use the same module types and adjust only hyperparameters such as layer count and hidden dimension. This makes the relationship between capability and scale easier to predict and simplifies engineering code reuse.
The specifications below illustrate this scaling approach. The table labels the sizes from smallest to largest as Spec A through Spec D:
| Configuration | Spec A | Spec B | Spec C | Spec D |
|---|---|---|---|---|
| Nominal parameters | 0.8B | 2B | 4B | 9B |
| Language layers | 24 | 24 | 32 | 32 |
| Hidden dimension | 1024 | 2048 | 2560 | 4096 |
| Vision layers | 12 | 24 | 24 | 27 |
| Vision hidden dimension | 768 | 1024 | 1024 | 1152 |
| Vocabulary size | 248,320 | 248,320 | 248,320 | 248,320 |
Two scaling paths are visible in the table. Spec A to Spec B mainly expands width: the hidden dimension doubles while the layer count stays the same. Spec B to Spec D increases depth, raising the layer count from 24 to 32 while continuing to widen the hidden dimension. Increasing width usually improves the feature capacity of a single layer, while increasing depth lets information pass through more nonlinear transformations. The two choices affect memory and latency differently.
For on-device selection, one empirical rule is important: with similar parameter counts, deeper models often have more serial inference steps and higher time to first token; wider models have larger matrix multiplications and place higher demands on compute and memory bandwidth. The balance depends on the characteristics of the target chip.
3. Engineering Implications of Native Multimodal Capabilities
Native multimodal means images and text are processed together in the same model, rather than using a separate recognition module to extract text or labels and then passing the result to a language model. A typical structure has three parts: a vision encoder splits the image into patches and encodes them into features; a projection module maps visual features into the language model’s representation space; and the language model processes image features and text tokens together.
The native approach brings two direct benefits for on-device applications. First, the pipeline is shorter. Tasks such as visual question answering, screenshot understanding, and form recognition require only one model call, reducing data movement and error propagation between modules. Second, image and text information are fused in the same representation space, allowing the model to focus on relevant regions of an image based on the question.
It is important to note that a small parameter count limits the perception of visual detail. Small text, dense tables, and complex charts are prone to missed detection or misreading. Before launch, teams should run targeted evaluations on real images from the business workload rather than relying only on generic benchmarks.
Image resolution is a major cost variable on edge devices. The number of visual tokens usually grows with resolution, which in turn increases prefill computation and memory usage. A common engineering practice is to set a maximum side length based on business requirements, then resize images proportionally.
def fit_image_to_budget(width: int, height: int, max_side: int = 1024) -> tuple[int, int]:"""Resize the image proportionally by the maximum side limit to control the number of visual tokens."""longest = max(width, height)if longest <= max_side:return width, heightscale = max_side / longestreturn max(1, round(width * scale)), max(1, round(height * scale))
4. Hybrid Attention and Very Long Context
4.1 Cost Sources of Full Attention
For a sequence of length n, standard self-attention has computation proportional to n². During inference, the model caches keys and values for each layer (the KV cache) to avoid repeated computation, and the cache size grows linearly with sequence length. Consider an illustrative configuration: assume the model has 32 layers, 8 KV heads per layer, a head dimension of 128, and FP16 storage. The KV cache per token is approximately 2 × 32 × 8 × 128 × 2 bytes, or 131 KB. At a context length of 256K tokens, the KV cache alone exceeds 30 GB, far beyond the available memory of most edge devices.
4.2 The Linear Attention Approach
Linear attention replaces the explicit softmax matrix with kernel functions or a recursive state, fixing the inference state size and making computation approximately linear with sequence length. The trade-off is that long-distance exact retrieval is usually weaker than with full attention.
Using the delta update rule as an example, a common recursive state form is shown below, where S is the state matrix, k and v are the key and value at the current step, and β is the write strength:
St = S{t-1} + βt (v_t − S{t-1} k_t) k_t^T
This equation means that at each step, the current key first reads the existing value from the old state, and then the state is corrected by the difference between the true value and the read value. This avoids information overwrite caused by unbounded accumulation and makes a fixed-size state more stable.
4.3 Design Trade-offs of Hybrid Structures
Hybrid attention uses both linear attention layers and full attention layers in the same model. Linear layers efficiently compress and propagate context information, while full attention layers perform precise cross-position retrieval. A common approach is to insert one full attention layer every few layers. The code below illustrates this inter-layer arrangement; the interval is an example value, not a parameter from a specific model:
def build_layer_schedule(num_layers: int, full_attn_every: int = 4) -> list[str]:"""Return the attention type used by each layer. The example places one full-attention layer every 4 layers."""schedule = []for idx in range(num_layers):if (idx + 1) % full_attn_every == 0:schedule.append("full_attention")else:schedule.append("linear_attention")return scheduleprint(build_layer_schedule(8))# ['linear_attention', 'linear_attention', 'linear_attention', 'full_attention',# 'linear_attention', 'linear_attention', 'linear_attention', 'full_attention']
The hybrid structure provides benefits in two areas. Linear layers do not produce a KV cache that grows with length, so the overall cache size is determined by the number of full attention layers, greatly reducing memory pressure for long contexts. Full attention layers retain precise retrieval capability, so the model remains reliable when it needs to locate specific information.
It should be emphasized that “supporting very long context” refers to the sequence length the model architecture can process; it does not guarantee that retrieval and reasoning quality remain unchanged at that length. For long-document scenarios, teams should verify recall of key information through testing and use segmentation, retrieval, or summarization strategies when necessary.
5. Resource Estimation for On-Device Deployment
5.1 Weight Memory Estimation
The memory occupied by model weights can be roughly estimated as the product of parameter count and bytes per parameter:
Weight memory ≈ parameter count × bytes per parameter
FP16 uses 2 bytes per parameter, INT8 uses 1 byte, and INT4 uses 0.5 bytes. The table below uses nominal parameter counts and includes only weights, not activations, KV cache, or runtime overhead:
| Nominal parameters | FP16 | INT8 | INT4 |
|---|---|---|---|
| 0.8B | approx. 1.6 GB | approx. 0.8 GB | approx. 0.4 GB |
| 2B | approx. 4.0 GB | approx. 2.0 GB | approx. 1.0 GB |
| 4B | approx. 8.0 GB | approx. 4.0 GB | approx. 2.0 GB |
| 9B | approx. 18.0 GB | approx. 9.0 GB | approx. 4.5 GB |
Actual deployment also requires KV cache, activations, image preprocessing buffers, and reserved system memory. As a rule of thumb, multiply the weight estimate by a safety factor before comparing it with available device memory, and use measured peak values as the final reference.
5.2 Key Performance Metrics
On-device evaluation usually focuses on the following metrics:
- Time to First Token (TTFT): the time from submitting input to producing the first output token, mainly affected by input length and prefill computation.
- Generation throughput (tokens/s): the number of output tokens per second during decoding, mainly limited by memory bandwidth.
- Peak memory: the maximum memory usage during inference, which determines whether the model can run stably on the target device.
- Power and temperature: energy consumption and throttling during sustained inference, which affect the experience on mobile devices.
- Task accuracy: accuracy, recall, or human ratings on real business data.
Measurements should be taken on the target device with fixed input length, output length, temperature, and background load, and the median of multiple runs should be used. Below is a general timing framework, where run_inference represents any inference interface:
import timeimport statisticsdef benchmark(run_inference, prompts, repeats: int = 5):"""Run the same set of inputs multiple times and return the median time to first token."""first_token_latencies = []for _ in range(repeats):for prompt in prompts:start = time.perf_counter()# Assume run_inference returns a generator when the first token is producedstream = run_inference(prompt)next(stream)first_token_latencies.append(time.perf_counter() - start)return statistics.median(first_token_latencies)
6. Scenario Selection Recommendations
Selection should start from business constraints rather than simply pursuing the largest parameter count. A recommended decision process begins with determining the hardware budget: available memory and power limits.
