Abstract
Retrieval-Augmented Generation (RAG) is a critical technique for enabling Large Language Models (LLMs) to access private or real-time information. However, deploying RAG on edge devices is hindered by the "memory wall," where the energy and latency costs of moving massive embedding databases between off-chip memory and processors become prohibitive. This paper introduces DIRC-RAG, a hardware-software co-design that utilizes a novel Digital In-ReRAM Computation (DIRC) architecture. By coupling high-density multi-level ReRAM with robust SRAM cells, DIRC-RAG achieves an energy efficiency of 0.956µJ per query and a latency of 5.6µs, providing the high precision necessary for vector-based document retrieval on the edge.
Introduction
As Large Language Models (LLMs) migrate toward edge deployment, the need for efficient Retrieval-Augmented Generation (RAG) has become paramount. RAG allows models to ground their responses in specific, up-to-date contexts by searching through millions of high-dimensional "document embeddings." On resource-constrained devices like smartphones or IoT gateways, the primary bottleneck is the movement of these embeddings from DRAM to the processor.
While Computing-in-Memory (CIM) has emerged as a potential solution to this "memory wall," existing implementations face significant trade-offs. SRAM-based CIM offers high speed but suffers from low storage density, making it unsuitable for large embedding databases. Conversely, analog ReRAM-based CIM provides high density but is plagued by device noise and limited computational accuracy, which degrades the precision of vector similarity searches. DIRC-RAG addresses these challenges through a hybrid digital-analog approach.
The DIRC-RAG Architecture
Hybrid ReRAM-SRAM Cell
The core of the DIRC-RAG architecture is a hybrid ReRAM-SRAM coupled cell. Each cell integrates an 8x8 Multi-Level Cell (MLC) ReRAM subarray with a 1-bit SRAM cell. This design leverages the strengths of both technologies: the ReRAM provides high-density, non-volatile storage for document embeddings, while the SRAM enables robust, high-speed digital logic operations during the active computation phase.
Digital MAC Operations
Unlike traditional analog CIM architectures that rely on sensitive current summing—which is prone to environmental noise—DIRC-RAG performs Digital Multiply-Accumulate (MAC) operations. By utilizing NOR gates and carry-save adders, the system ensures bit-level precision. This deterministic accuracy is vital for the high-dimensional vector mathematics (such as Cosine Similarity or Maximum Inner Product Search) required for RAG tasks.
Query-Stationary (QS) Dataflow
To further minimize data movement, DIRC-RAG employs a Query-Stationary (QS) dataflow. In this model, the user's query is broadcast to all CIM cores simultaneously. The document embeddings remain stationary within the memory cells, allowing the computation to occur where the data resides, drastically reducing the energy overhead associated with data fetching.
Robustness and Optimization
ReRAM technology is inherently subject to device variability. To maintain high retrieval precision, DIRC-RAG incorporates two primary hardware-software strategies:
- Error-Aware Bitwise Mapping: The researchers observed that not all bits in a vector contribute equally to retrieval accuracy. By identifying the spatial error distribution of the ReRAM array, the system maps the most significant bits (MSBs) to the most reliable physical ReRAM locations. This strategy alone improved retrieval precision by 24.6%.
- Error Detection Circuit: A hardware-level checksum system monitors data integrity. If a readout error is detected, the system triggers a "re-sense" of the ReRAM data to ensure the accuracy of the digital computation.
Experimental Evaluation
Performance Metrics
The DIRC-RAG chip was simulated using a TSMC 40nm process. The results demonstrate significant improvements over traditional hardware:
- Storage Density: 5.18 Mb/mm² (on-chip non-volatile memory).
- Throughput: A peak performance of 131 TOPS.
- Efficiency: 0.956 µJ per query.
- Latency: 5.6 µs for a 4MB retrieval task.
When compared to a high-end discrete GPU (NVIDIA RTX 3090), DIRC-RAG is approximately 7,800x more energy-efficient and 8x faster for the same retrieval workload.
Retrieval Precision
The architecture was validated using the BEIR framework across five standard NLP benchmarks: SciFact, NFCorpus, TREC-COVID, ArguAna, and SciDocs. The study found that INT8 quantization maintained full-precision (FP32) accuracy levels. While INT4 quantization introduced a slight drop in precision, it remained within acceptable limits for edge applications.
Conclusion and Future Work
DIRC-RAG demonstrates that a hybrid, digital-focused CIM architecture can overcome the density and accuracy limitations of previous edge AI hardware. By prioritizing digital precision and strategic bit mapping, it enables high-performance RAG in power-constrained environments.
Future research will focus on scaling the architecture to handle gigabyte-scale databases through chiplet technology or advanced process nodes (e.g., 28nm). Additionally, the team aims to explore quantization-aware training to further minimize the precision loss observed at INT4 bit-widths and address the write-endurance limitations of ReRAM for more dynamic database environments.
Summary updated