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

MCUBERT: Memory-Efficient BERT Inference on Commodity Microcontrollers

Zebin Yang, Renze Chen, Taiqiang Wu, Ngai Wong, Yun Liang, Runsheng Wang, Ru Huang, Meng Li

Abstract

Deploying Transformer-based models like BERT on commodity microcontrollers (MCUs) is traditionally hindered by severe memory constraints. This paper introduces MCUBERT, a co-optimization framework that enables BERT inference on devices with as little as 256KB of SRAM. By employing a two-stage Neural Architecture Search (NAS) for embedding compression and a fine-grained computation scheduling strategy, MCUBERT reduces BERT-tiny’s parameter size by 5.7× and peak memory by 3.5×. These optimizations allow commodity MCUs to process sequences of up to 512 tokens, a significant milestone for edge-based natural language processing.

1. Introduction

The deployment of Large Language Models (LLMs) on the "edge of the edge"—specifically microcontrollers—faces a formidable "memory wall." Standard MCUs, such as the ARM Cortex-M7, typically provide approximately 1MB of Flash storage for model weights and 320KB of SRAM for runtime activations. Even the smallest variants of BERT exceed these limits, primarily due to the massive size of embedding tables and the quadratic memory requirements of the Multi-Head Attention (MHA) mechanism. MCUBERT addresses these bottlenecks through a three-layered co-optimization strategy spanning the network, scheduling, and kernel levels.

2. Challenges in MCU-Based Inference

The authors identify two primary bottlenecks that prevent standard BERT deployment on MCUs:

  1. Storage (Flash): In compact BERT models, the embedding table often accounts for over 90% of the total parameters, making it the dominant consumer of non-volatile storage.
  2. Runtime Memory (SRAM): The MHA mechanism generates a "score matrix" that grows quadratically with sequence length. For a 512-token sequence, this matrix alone can exceed the entire SRAM capacity of a typical MCU.

Existing solutions designed for mobile GPUs or high-end mobile processors often rely on sparse computation or sub-8-bit quantization, features that are rarely supported by commodity MCU hardware.

3. The MCUBERT Framework

3.1 Network Level: Two-Stage MCU-Aware NAS

To address the storage bottleneck, MCUBERT utilizes clustered low-rank approximation for embedding table compression. Rather than applying uniform compression, the framework groups tokens into clusters and assigns varying low-rank factorization ratios to each. To ensure search stability, the authors proposed a two-stage NAS process guided by Knowledge Distillation (KD):

  • Stage 1: Fixes the ranks and searches for optimal token clustering.
  • Stage 2: Fixes the clusters and searches for the optimal approximation ratios. This decomposition allows the model to capture token importance effectively while maintaining a manageable search space.

3.2 Scheduling Level: Fine-Grained Tiling

To overcome the SRAM bottleneck, MCUBERT re-engineers the execution of the Transformer block:

  • MLP Scheduling: Input is tiled along the token dimension, and residual additions are performed in-place, reducing memory consumption by approximately 6×.
  • MHA Scheduling: Inspired by FlashAttention but tailored for MCUs, the framework tiles computation along both head and token dimensions. This transforms the quadratic memory requirement of the score matrix into a linear one, enabling the processing of long input sequences.

3.3 Kernel Level: Custom Operator Design

To maximize throughput, the authors developed custom kernels that move beyond generic libraries like CMSIS-NN. These kernels exploit Instruction Level Parallelism (ILP) and Register Level Locality through loop unrolling and SIMD instructions (e.g., SMLAD), optimizing the hardware pipeline of the MCU.

4. Evaluation and Results

4.1 Experimental Setup

The framework was evaluated using the GLUE (General Language Understanding Evaluation) benchmark, with a focus on MNLI, MRPC, SST2, and QQP tasks. Hardware testing was conducted on commodity MCUs, including the NUCLEO-F746.

4.2 Key Findings

  • Compression: MCUBERT reduced the parameter size of BERT-tiny by 5.7× and BERT-mini by 3.0×.
  • Memory Efficiency: Peak execution memory was reduced by 3.5× for BERT-tiny and 4.3× for BERT-mini.
  • Latency: Custom kernels provided a 1.5× speedup compared to the industry-standard CMSIS-NN library.
  • Sequence Length: The framework successfully enabled BERT-tiny inference with a sequence length of 512 tokens on a device with only 256KB of SRAM.

5. Conclusion and Future Work

MCUBERT demonstrates that the memory constraints of microcontrollers are not an absolute barrier to Transformer inference. By co-optimizing model architecture and execution scheduling, it is possible to run sophisticated NLP models on low-power hardware. Future research will focus on extending these techniques to decoder-only models (like GPT), which present unique challenges regarding KV cache management, and exploring mixed-precision quantization for further efficiency gains.

Summary updated

BibTeX
@inproceedings{yang2024mcubert,
  author = {Zebin Yang and Renze Chen and Taiqiang Wu and Ngai Wong and Yun Liang and Runsheng Wang and Ru Huang and Meng Li},
  title = {{MCUBERT: Memory-Efficient BERT Inference on Commodity Microcontrollers}},
  booktitle = {ICCAD},
  year = {2024},
}
Figure