Deeploy: Enabling Energy-Efficient Deployment of Small Language Models on Heterogeneous Microcontrollers

Moritz Scherer, Luka Macan, Victor J. B. Jung, Philip Wiese, Luca Bompani, Alessio Burrello, Francesco Conti, Luca Benini

Introduction

The rapid advancement of Large Language Models (LLMs) has revolutionized natural language processing, yet their deployment remains largely confined to high-power data centers. A parallel movement in the "tinyML" community seeks to bring these capabilities to the "extreme edge"—battery-powered devices such as wearables, smart sensors, and autonomous micro-robots. However, microcontrollers (MCUs) face severe resource limitations, typically possessing only a few megabytes of on-chip RAM and lacking the Memory Management Units (MMUs) found in server-grade hardware.

Furthermore, modern AI-centric MCUs are increasingly heterogeneous, integrating general-purpose RISC-V cores with specialized Neural Processing Units (NPUs). Existing compiler toolchains often struggle to coordinate these diverse execution engines while managing the complex data lifetimes inherent in Transformer architectures, particularly the Key-Value (KV) cache. This paper introduces Deeploy, a novel Deep Neural Network (DNN) compiler designed to enable end-to-end deployment of Small Language Models (SLMs) on heterogeneous MCUs without requiring external memory.

The Deeploy Compiler Architecture

Deeploy departs from traditional "top-down" compilation strategies that attempt to map high-level abstractions onto hardware. Instead, it adopts a bottom-up approach centered on three core pillars:

1. Kernel-First Design

The compiler constructs networks by composing hand-optimized C kernels. These kernels are pre-tuned for specific hardware targets (e.g., PULP-NN), ensuring that the generated code leverages the maximum available performance of the underlying architecture.

2. Co-optimized Tiling and Allocation

The "Midend" of Deeploy utilizes a constraint programming approach, specifically Google’s OR-Tools CP-SAT solver, to address the challenges of memory management. Unlike traditional compilers that treat tiling (breaking data into chunks) and memory allocation as sequential steps, Deeploy solves them simultaneously as a 2D bin-packing problem. This co-optimization is critical for managing "long-lived" tensors like the KV cache alongside "short-lived" intermediate activations. By fitting the KV cache entirely within on-chip L2 memory, Deeploy avoids the massive latency penalties of recomputation.

3. Automated Heterogeneous Offloading

Deeploy employs a "closure" system to manage execution across heterogeneous cores. It automatically wraps code segments and offloads them to the most appropriate engine—typically assigning heavy linear layers (matrix multiplications) to the NPU while delegating non-linear operations (e.g., Softmax, RMSNorm) to the multi-core RISC-V cluster.

Hardware Target: Siracusa SoC

The primary evaluation platform is Siracusa, a 16nm RISC-V System-on-Chip (SoC). Siracusa features an octa-core cluster for general-purpose parallel processing and the N-Eureka NPU, a bit-serial accelerator designed for high-efficiency AI inference. This combination allows the system to balance the flexibility required for complex Transformer logic with the raw throughput needed for neural computation.

Experimental Methodology

The researchers evaluated Deeploy using two primary benchmarks:

  • TinyStories: A dataset designed for training SLMs (ranging from tens to hundreds of millions of parameters) capable of coherent English generation. A Llama2-style model was deployed to test the compiler's ability to handle autoregressive inference.
  • MLPerf Tiny: A standard benchmark for edge AI, including models like DS-CNN and ResNet. This allowed for a direct comparison between Deeploy and state-of-the-art specialized compilers like Dory.

Key Results and Insights

The deployment of SLMs on the Siracusa MCU yielded record-breaking performance metrics:

  • Energy Efficiency: The system achieved an energy consumption of 490 µJ/Token. When normalized for the number of operations, this represents an estimated 130x improvement in energy efficiency over mobile-grade hardware like the Apple A15 Bionic.
  • Throughput: Autoregressive inference reached 340 Tokens/s. The decision to maintain the KV cache on-chip resulted in a 26x increase in throughput compared to systems that recompute the cache for every token.
  • Minimal Overhead: Despite the complexity of data marshaling between the NPU and the RISC-V cluster, the communication overhead was restricted to just 9% for large workloads.
  • Compiler Versatility: On standard CNN benchmarks (MLPerf Tiny), Deeploy matched the performance of specialized compilers. This demonstrates that its general-purpose constraint-solving approach does not sacrifice the efficiency typically associated with hand-tuned, model-specific tools.

Discussion and Future Work

Deeploy demonstrates that sophisticated language modeling is possible at the extreme edge through rigorous memory co-optimization. However, several challenges remain. The current implementation focuses on decoder-only and encoder-only architectures; expanding this to a broader range of models is a priority. Additionally, as SLMs scale toward the 100M+ parameter range, they will eventually exceed the physical limits of on-chip L2 memory, likely requiring the integration of ultra-low-power external memory solutions like HyperRAM.

Future iterations of Deeploy aim to support emerging hardware innovations, such as Compute-In-Memory (CIM) macros. By performing calculations directly within memory arrays, CIM could further reduce the energy costs associated with data movement, pushing the boundaries of what is possible for battery-powered AI.

Summary updated

BibTeX
@article{scherer2024deeploy,
  author = {Moritz Scherer and Luka Macan and Victor J. B. Jung and Philip Wiese and Luca Bompani and Alessio Burrello and Francesco Conti and Luca Benini},
  title = {{Deeploy: Enabling Energy-Efficient Deployment of Small Language Models on Heterogeneous Microcontrollers}},
  journal = {IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.},
  year = {2024},
  doi = {10.1109/tcad.2024.3443718},
}
Figure