TL;DR
LeanStream introduces a "speculate-and-refine" streaming framework that allows large language models (LLMs) to run efficiently on memory-constrained mobile and embedded devices by offloading weights to storage. By progressively refining activation predictions and I/O priorities using partial GPU results, it breaks the traditional trade-off between prediction accuracy and compute-I/O overlap. This approach reduces memory usage by up to 7.5$\times$ and boosts token throughput by up to 2.1$\times$ compared to state-of-the-art systems.
What Problem Does This Paper Address?
Running LLMs directly on smartphones or edge devices is highly desirable for privacy and responsiveness, but these models are typically too large to fit into device DRAM. To bypass this bottleneck, recent systems store model weights on flash memory (SSDs) and load them on demand. They exploit activation sparsity—the phenomenon where only a small fraction (often ~20%) of neurons actually fire during a given inference step—to avoid loading the entire model.
However, this introduces a fundamental systems tension:
- To accurately predict which weights to load, the system needs the exact output (context) of the preceding layer. Waiting for this context serializes execution, leaving the GPU idle while waiting for storage I/O.
- To hide I/O latency, systems try to predict activation patterns early (speculative fetching). But without the latest context, these predictions are inaccurate, leading to redundant weight transfers, wasted computation, and massive memory cache overheads.
Methods
LeanStream resolves this tension through a streaming pipeline that continuously updates its predictions rather than making a single "one-shot" decision.
- Partial-Feature Refinement: LeanStream breaks down the feed-forward network (MLP) execution into multiple priority-ordered stages. As the GPU finishes computing an early stage, its partial intermediate results are immediately used to refine the activation predictions for the next layer.
- Fine-Grained, Non-Blocking Coordination: Traditional GPU-CPU synchronization primitives (like global barriers) introduce massive overhead when called frequently. LeanStream leverages the unified memory architecture of modern system-on-chips (SoCs) to implement thread-block-level flag checks. The GPU can start executing high-priority weight blocks as soon as they arrive in DRAM, completely decoupling the CPU's I/O loop from the GPU's compute loop.
- Stacked Learnable Hashing: Prior systems used standard multi-layer perceptrons (MLPs) to predict sparsity, which ironically consumed over 1 GB of memory. LeanStream replaces these with a lightweight, differentiable hashing mechanism. By relying on bitwise operations and in-register table lookups, it slashes prediction latency to under 100 $\mu$s and reduces the predictor's footprint to just ~23 MB.
- Permutation-Invariant Execution: Because weights arrive from storage out of order based on priority, LeanStream exploits the mathematical property of permutation invariance in SwiGLU layers. Arriving weights are simply appended to a contiguous dense matrix buffer and executed immediately, avoiding complex indexing or data reshuffling overheads.
Datasets
The authors evaluated LeanStream across three representative LLM generation tasks using standard benchmarks:
- Scrolls-Qasper: Long-document question answering.
- TruthfulQA: Open-ended factual text generation.
- CoQA: Conversational question answering.
These datasets were tested against popular open-source models including Mistral-7B, Llama2-7B, and Qwen2.5-7B.
Key Insights and Ideas
- Sparsity Prediction is a Spectrum, Not a Binary Choice: You don't have to choose between guessing early or waiting until the end. Partial computation yields highly informative features that rapidly converge on the true activation pattern.
- Hardware Co-design via Unified Memory: On mobile SoCs, the CPU and GPU share physical memory. Instead of treating them as isolated devices requiring heavy synchronization, LeanStream treats them as cooperative threads reading and writing shared flags in real time.
- Algorithmic Flexibility Beats Complex Indexing: By recognizing that the internal order of hidden neurons in an MLP layer doesn't affect the final summed output, the system completely sidesteps the need to reorganize out-of-order data arriving from the SSD.
Key Results
LeanStream was evaluated on hardware including the NVIDIA Jetson AGX Orin and the OnePlus 13 smartphone (Snapdragon 8 Elite).
- Memory Reduction: At equivalent throughput levels to baselines like PowerInfer-2, LeanStream reduced memory requirements by 4.8$\times$ to 7.5$\times$.
- Throughput Boost: When operating under tight memory constraints, LeanStream improved token generation speed by 1.6$\times$ to 2.1$\times$ over state-of-the-art baselines.
- Predictor Efficiency: The Stacked Learnable Hashing model achieved an inference latency of <100 $\mu$s while maintaining a competitive loading redundancy level (12%–14%).
- Accuracy Preservation: Across all models and datasets, LeanStream maintained accuracy nearly identical to the original uncompressed, dense models.
Limitations and Future Work
- Offline Profiling Cost: To optimize the streaming schedule dynamically, LeanStream uses a stochastic Model Predictive Control (MPC) policy. Generating the lookup table for this policy requires extensive offline profiling (~90 hours on a Jetson AGX Orin).
- Prefill Phase Bottleneck: The framework primarily optimizes the token decoding phase. The initial prefill (prompt processing) phase is highly compute-bound and does not exhibit the same level of activation sparsity, meaning it still suffers from initial dense weight loading overheads.
Summary updated