Abstract
On-device Large Language Models (LLMs) are revolutionizing mobile AI, enabling applications such as UI automation while addressing privacy concerns. Currently, the standard approach involves deploying a single, robust LLM as a universal solution for various applications, often referred to as LLM-as-a-Service (LLMaaS). However, this approach faces a significant system challenge: existing LLMs lack the flexibility to accommodate the diverse Service-Level Objectives (SLOs) regarding inference latency across different applications. To address this issue, we introduce ELMS, an on-device LLM service designed to provide elasticity in both the model and prompt dimensions of an LLMaaS. This system includes: A one-time neuron reordering technique, which utilizes the inherent permutation consistency within transformer models to create high-quality, elastic sub-models with minimal runtime switching costs. A dual-head compact language model, which efficiently refines prompts and coordinates the elastic adaptation between the model and the prompt. We have implemented this elastic on-device LLM service on several off-the-shelf (COTS) smartphones and evaluate ELMS using both standalone NLP/mobile-agent datasets and synthesized end-to-end traces. Across a range of SLOs, ELMS surpasses four strong baselines by up to 16.83% and 11.04% in absolute accuracy on average, with less than 1% Time-To-First-Token (TTFT) switching overhead, comparable memory usage, and fewer than 100 offline GPU hours.
Introduction
The deployment of Large Language Models (LLMs) on mobile devices offers significant advantages for user privacy and offline functionality. However, a major hurdle remains: the inherent rigidity of current LLM architectures. Mobile applications have diverse Service-Level Objectives (SLOs). For instance, a real-time chatbot requires a low Time-Per-Output-Token (TPOT) to maintain conversational flow, whereas a UI-automation agent might prioritize a fast Time-To-First-Token (TTFT) to trigger actions promptly.
Current deployment strategies—either a single "one-size-fits-all" model or multiple specialized models—fail to balance performance and memory efficiency. ELMS (Elasticized Large Language Models) addresses this by introducing dynamic elasticity, allowing the model to scale its complexity and input length in real-time to meet specific latency targets.
Methodology
ELMS achieves elasticity through two primary dimensions: the model dimension (number of active parameters) and the prompt dimension (input length).
Two-Dimensional Latency Orchestration
A key insight of this work is the differing impact of model and prompt size on latency metrics. TTFT is sensitive to both prompt length and model size, while TPOT is primarily driven by model size. ELMS leverages these relationships to optimize the "mix" of model and prompt compression for any given SLO.
One-shot Neuron-Reordering
To enable near-instantaneous model scaling, ELMS utilizes "permutation consistency" in Transformers. By profiling the importance of attention heads and MLP neurons offline, ELMS reorders them so that the most critical components are stored contiguously in memory. This allows sub-models to be accessed as simple memory "slices," reducing switching overhead to less than 1% of average TTFT—a significant improvement over traditional pruning methods that require costly runtime memory re-layout.
Dual-head Tiny Language Model (TLM)
ELMS employs a modified MobileBert as a controller. A Score-head ranks token importance for prompt pruning, while a Decision-head determines the optimal configuration (model size vs. prompt length) to maximize accuracy under the requested SLO. To further preserve quality, ELMS uses Low-Rank Adapters (LoRA) for sub-models and identifies "Anchor Layers" that remain unpruned.
Results
ELMS was evaluated on off-the-shelf smartphones (e.g., Redmi K60) across general NLP benchmarks and mobile-specific agent tasks like Octopus and LlamaTouch.
- Accuracy: ELMS outperformed seven strong baselines by an average of 10.45% in absolute accuracy across various SLOs.
- Efficiency: The system achieved up to a 5x speedup in TTFT and a 2x speedup in TPOT with minimal accuracy loss (<2%).
- Switching Overhead: Model switching was reduced to 0.31 seconds, compared to 6-8 seconds for standard pruning-based baselines.
- Development Cost: The offline "elastification" process for a LLaMA-7B model requires fewer than 100 GPU hours.
Conclusion
ELMS demonstrates that elasticity is a viable and efficient solution for on-device LLM services. By combining neuron reordering with intelligent prompt management, ELMS provides the flexibility needed to support diverse mobile applications without the memory overhead of multiple models or the latency penalties of traditional pruning. Future work will focus on optimizing hardware-level support for dynamic model shapes on mobile NPUs.
Summary updated