Optimizing Foundation Model Inference on a Many-tiny-core Open-source RISC-V Platform

Viviane Potocnik, Luca Colagrande, Tim Fischer, Luca Bertaccini, Daniele Jahier Pagliari, Alessio Burrello, Luca Benini · DOI

Introduction

The deployment of Foundation Models (FMs), such as Vision Transformers (ViTs) and Large Language Models (LLMs), has historically been the domain of high-end proprietary GPUs and specialized accelerators. However, the rise of open-source hardware offers a potential path toward more transparent and customizable AI infrastructure. Researchers from ETH Zürich, the University of Bologna, and Politecnico di Torino have recently demonstrated a significant breakthrough: the first end-to-end inference of transformer-based FMs on an open-source, many-tiny-core RISC-V platform. By integrating custom Instruction Set Architecture (ISA) extensions with sophisticated memory management, the team achieved performance levels that challenge commercial state-of-the-art solutions.

The Computational Challenge

Foundation models present two primary hurdles for general-purpose architectures like RISC-V. First is the computational overhead associated with the attention mechanism, which exhibits quadratic complexity, and the intensive transcendental mathematics required for Softmax operations. Second is the memory wall—the energy and latency costs incurred by moving massive weight matrices and intermediate tensors between main memory (HBM) and the compute cores. Traditional RISC-V cores often spend more cycles managing data movement and loop overhead than performing actual floating-point arithmetic.

The Snitch Architecture: Hardware Innovations

The researchers utilized a scalable platform based on the Snitch cluster. Each cluster is composed of eight 32-bit integer RISC-V cores, a dedicated DMA core, and a shared 64-bit SIMD Floating Point Unit (FPU). To overcome the limitations of standard RISC-V, three key hardware innovations were employed:

  1. Stream Semantic Registers (Xssr): This extension allows the FPU to stream data directly from memory into registers. By bypassing explicit load/store instructions, the system effectively hides memory latency and reduces instruction pressure.
  2. Instruction Repetition (Xfrep): To minimize the overhead of branch instructions and instruction cache fetches, a hardware buffer repeats sequences of instructions (e.g., dot product loops) automatically without the usual architectural overhead.
  3. Hierarchical Interconnect: A multi-level crossbar system facilitates direct cluster-to-cluster communication. This allows for data sharing without the need to traverse the relatively slow and power-hungry High Bandwidth Memory (HBM).

Software and Algorithmic Optimizations

Hardware alone is insufficient for FM performance; the researchers implemented several software-level optimizations to maximize throughput:

  • Layer Fusion and FlashAttention-2: Operations such as GELU activations were fused with preceding linear layers to reduce memory round-trips. The implementation also integrated FlashAttention-2 principles to optimize the attention bottleneck.
  • Logarithmic Reduction: To manage attention heads distributed across multiple clusters, the team used a tree-based reduction method. This leverages the hierarchical interconnect for cluster-to-cluster transfers, reducing HBM reads by up to 1.6× for models like GPT-J.
  • Mixed Precision Support: The library supports a range of precisions from FP64 down to FP8. By utilizing SIMD instructions, the system can double or quadruple throughput as precision decreases, though Softmax operations are maintained in FP32 to ensure numerical stability.

Experimental Results and Performance Analysis

The platform was tested against five major model configurations, including ViT-Base/Large/Huge and GPT-3XL (1.3B) and GPT-J (6B). The evaluation covered both Non-Autoregressive (NAR) mode—typical for prompt encoding—and Autoregressive (AR) mode for token generation.

Key Results:

  • Throughput Gains: Compared to a baseline RISC-V implementation, the optimized platform achieved a 12.8× speedup for ViTs, a 16.1× speedup for GPT in NAR mode, and a 35.6× speedup for GPT in AR mode.
  • Hardware Utilization: In NAR mode, the system reached 70.6% FPU utilization for FP16. This significantly outperforms commercial accelerators; for comparison, the NVIDIA A100 and Habana Gaudi2 show approximately 14.4% and 34.6% utilization, respectively, on similar workloads.
  • Energy Efficiency: The platform demonstrated an efficiency of 294 GFLOPS/W using FP8 precision in NAR mode.
  • Scalability: Performance scaled almost linearly with the number of clusters (up to 16 clusters/128 cores tested), validating the efficiency of the hierarchical interconnect.

Discussion and Future Work

While the results are promising, the study identifies several areas for improvement. Autoregressive (AR) inference remains a challenge; despite the high speedup relative to the baseline, absolute FPU utilization in AR mode remains below 10% because it processes only one token at a time, making it heavily memory-bound by the KV cache. Additionally, the "Softmax tax"—the need to upcast to FP32 for activations—remains a bottleneck in low-precision workflows.

Future research will focus on lower-precision approximations for exponential functions and exploring multi-chiplet scalability to accommodate models that exceed the memory capacity of a single silicon interposer. This work proves that "tiny" open-source cores, when augmented with specialized data-streaming hardware, can provide a viable and efficient alternative to proprietary AI hardware.

Summary updated

BibTeX
@article{potocnik2024optimizing,
  author = {Viviane Potocnik and Luca Colagrande and Tim Fischer and Luca Bertaccini and Daniele Jahier Pagliari and Alessio Burrello and Luca Benini},
  title = {{Optimizing Foundation Model Inference on a Many-tiny-core Open-source RISC-V Platform}},
  journal = {IEEE Trans. Circuits Syst. Artif. Intell.},
  year = {2024},
  doi = {10.1109/tcasai.2024.3459412},
}
Figure