NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sparse Learning for State Space Models on Mobile

Xuan Shen, Hangyu Zheng, Yifan Gong, Zhenglun Kong, Changdi Yang, Zheng Zhan, Yushu Wu, Xue Lin, Yanzhi Wang, Pu Zhao, Wei Niu

TL;DR

This paper introduces a sparse learning framework designed to bring high-performance State Space Models (SSMs), such as Mamba, to mobile devices. By combining a novel $C_4^n$ kernel sparsity pattern with architecture-aware compiler optimizations and weight compensation techniques, the authors achieve up to a 7× speedup over the standard llama.cpp framework while maintaining significantly higher accuracy than existing pruning methods.

What Problem Does This Paper Address?

While Transformer models dominate the AI landscape, State Space Models (SSMs)—specifically the Mamba architecture—have emerged as highly efficient alternatives for long-sequence modeling. Mamba offers sub-quadratic scaling, making it theoretically ideal for processing long contexts without the massive memory overhead of traditional attention mechanisms.

Throughput comparison of Mamba versus other models across different parameter sizes.

However, this "theoretical efficiency" often hits a wall on mobile hardware. Mamba’s selective mechanism requires high memory bandwidth and complex dynamic parameter adjustments that are difficult to execute on resource-constrained mobile CPUs and GPUs. Existing optimization libraries, which are typically tailored for data center GPUs, do not translate well to mobile System-on-Chips (SoCs). Furthermore, standard pruning techniques often either destroy the model's accuracy or create "irregular" sparsity that mobile hardware cannot actually accelerate, leaving a gap between algorithmic compression and real-world speedups.

Methods

The authors propose an end-to-end solution that bridges the gap between algorithmic sparsity and hardware execution:

  1. $C_4^n$ Kernel Sparsity: Instead of random pruning, the authors split weights into groups of four. They prune $n$ elements out of every four ($n \in \{0, 1, 2, 3, 4\}$). This "semi-structured" approach is specifically designed to align with SIMD (Single Instruction, Multiple Data) units on mobile processors, which typically process four-element vectors in parallel.
Illustration of the C_4^n sparsity pattern and compiler-level weight reordering.
  1. Sparse Learning Framework: Rather than using a simple heuristic to decide which weights to cut, they use a differentiable learning process. They define an "effectiveness loss" (predicting accuracy drop), a "sparsity loss," and a "latency loss." The framework learns an optimal pruning mask that minimizes accuracy loss while hitting specific latency targets.
  2. Weight Compensation: After pruning, the remaining weights are "rectified" using a method based on the classic Optimal Brain Surgeon (OBS) algorithm. This recalibrates the surviving weights to compensate for the removed ones, using only a small calibration set (e.g., 128 samples).
  3. Compiler-Level Optimizations:
    • Weight Reordering: They reorder weights offline to eliminate branch divergence and load imbalances during execution.
  4. Layout Transformation Elimination: They optimize the computational graph to remove unnecessary "Transpose" or "Reshape" operations, which are notoriously "bandwidth-hungry" on mobile devices.

Datasets

The models (ranging from Mamba-130M to Mamba-2.8B) were evaluated on several standard common-sense reasoning and language modeling benchmarks:

  • LAMBADA: For word prediction and perplexity.
  • HellaSwag, PIQA, WinoGrade: For common-sense reasoning.
  • Arc-easy and Arc-challenge: For science-question answering.

Key Insights and Ideas

  • Hardware-Software Co-design is King: The $C_4^n$ pattern is the core breakthrough. By acknowledging that mobile CPUs operate optimally in chunks of four, the authors created a sparsity pattern that the hardware can actually "see" and accelerate, rather than just reducing the theoretical FLOP count.
  • Differentiable Search vs. Heuristics: Traditional pruning (like Wanda or SparseGPT) often uses static metrics to prune. By making the pruning mask learnable and hardware-aware (incorporating actual latency measurements into the loss function), the model finds a vastly superior trade-off between speed and intelligence.
  • Moving Data is More Expensive than Computing: The "Layout Transformation Elimination" highlights a critical mobile bottleneck. On a phone, the energy and time cost of moving data in memory often exceeds the cost of the math itself. Eliminating these moves provides a "free" performance boost.

Key Results

  • Massive Speedups: The framework achieves up to 7× speedup compared to the llama.cpp implementation of Mamba on a OnePlus 11 (Snapdragon 8 Gen 2). Even compared to their own optimized dense baseline, they see 1.1× to 1.7× acceleration depending on the sparsity level.
  • Superior Accuracy: At 50% sparsity, their method significantly outperformed baselines. For Mamba-130M, they reduced perplexity from 212.9 (Wanda) to 28.97 (Ours).
  • Efficiency: The Mamba-2.8B model, which previously took 2.5 seconds to generate a single token on high-end mobile devices, becomes significantly more viable for real-time use.

Limitations and Future Work

  • Mamba-Specific: While the compiler optimizations are general, the effectiveness loss and specific kernel designs are heavily tailored to the Mamba/SSM architecture. It is unclear how easily this transfers back to modern "Hybrid" architectures (Transformer-SSM mixes).
  • GPU Support in Baselines: The authors note that llama.cpp does not yet support Mamba on mobile GPUs, so their primary speedup comparisons are against CPU-based implementations.
  • Search Overhead: While the pruning is "one-shot" and relatively fast (about 50 minutes for a 2.8B model), it still requires a GPU-based search phase before deployment.

The authors suggest that future work could involve exploring even more fine-grained mixed-kernel strategies or extending these optimizations to the very latest "Mamba-2" architectures.

Summary updated

BibTeX
@inproceedings{shen2025sparse,
  author = {Xuan Shen and Hangyu Zheng and Yifan Gong and Zhenglun Kong and Changdi Yang and Zheng Zhan and Yushu Wu and Xue Lin and Yanzhi Wang and Pu Zhao and Wei Niu},
  title = {{Sparse Learning for State Space Models on Mobile}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=t8KLjiFNwn},
}
Figure