Manuscript Offprint

arXiv:2610.22579

MemLLM: End-to-end In-Storage Acceleration of On-device Retrieval-Augmented Generation using Precomputed KV Caches

Seungkwan Kang, Hyungseok Ko, Heemin Kim, Myoungsoo Jung

Seungkwan Kang, Hyungseok Ko, Heemin Kim, Myoungsoo Jung

Computer Architecture and Memory Systems Laboratory, KAIST

Daejeon, Republic of Korea

Abstract—Retrieval-augmented generation (RAG) on edge devices enables personalized large language model (LLM) inference while preserving privacy. However, RAG's inherent length asymmetry makes the prefill phase the dominant bottleneck. While precomputing the KV caches offline alleviates the prefill cost on server systems, the multi-gigabyte caches over the narrow interconnect create a severe I/O wall for on-device systems. To mitigate this, we propose MEMLLM, an end-to-end in-storage processing (ISP) architecture that executes the complete attention pipeline based on precomputed KV caches within the SSD. MEMLLM utilizes per-channel accelerators to fully utilize the aggregated NAND channel bandwidth and accelerates all KV cache-related computations on the storage-side to minimize PCIe transfers. To efficiently handle the sparse updates required by RAG, MEMLLM introduces a fused recomputation-query kernel paired with a hardware-based filter logic to halve the NAND read volume and eliminate write-back penalties. Furthermore, MEMLLM's global SRAM-based stateful reduction engine enables a completely DRAM-less dataflow, thereby removing the internal memory bottlenecks and bounding the PCIe egress to an O(1)O(1) footprint. A full-stack software stack allows asynchronous, zero-copy transfers from the ISP to the host and provides transparent execution within modern ML frameworks. Evaluated across eight real-world RAG datasets and six on-device LLM models, MEMLLM achieves an average end-to-end speedup of 4.06×4.06\times over the GPU baseline.

Index Terms—In-storage processing, retrieval-augmented generation, large language model inference, KV cache, near-data processing, on-device machine learning

I. INTRODUCTION

Large language models (LLMs) are rapidly migrating from cloud servers to edge on-device systems, driven by the demand for privacy-preserving inference over sensitive data, such as personal medical records [1]-[5], financial documents [6]-[10], and corporate knowledge bases [11]-[13], without dependence on centralized servers [14]-[17]. Retrieval-augmented generation (RAG [18]) is central to this vision. By grounding LLM responses in an external knowledge base, RAG eliminates the need for costly fine-tuning and enables real-time, personalized answers on-device.

However, RAG workloads exhibit a fundamental length asymmetry; the retrieved contexts typically span thousands of tokens, while the generated answers remain extremely short, often by a factor of 100–1000×. This asymmetry shifts the inference bottleneck from the decode phase, which dominates standard LLM serving, to the prefill phase, where the LLM must process the massive retrieved context to build its KV cache. On resource-constrained edge devices, this prefill-dominated latency profile creates a severe performance barrier for practical on-device RAG deployment, especially for the long-context, short-answer regime.

A promising software-level mitigation is to precompute the KV caches for documents in the knowledge base offline and load them from storage at inference time, replacing the compute-intensive prefill with a storage read [19]–[22]. On server systems equipped with high-bandwidth storage arrays, this trade of computation for I/O yields substantial speedups. However, on edge devices, the massive data movement across the narrow PCIe interconnect severely throttles performance. To make matters worse, the limited memory capacity of edge SoCs cannot accommodate these multi-gigabyte precomputed KV caches alongside the model weights, forcing the KV caches to be completely offloaded to persistent storage [23]–[28]. Streaming these precomputed caches from the SSD to the GPU over the limited PCIe bus takes longer than the compute time it was meant to replace, creating an I/O wall that negates the benefits of precomputation entirely.

Existing in-storage processing (ISP) architectures offer a partial remedy. Prior works have offloaded decode-phase attention to storage devices to eliminate repeated KV cache transfers [23]–[25], or moved model-weight computation into flash to free GPU memory [29]. Yet, these approaches fail to address the defining challenge of precomputed-KV-based RAG: selective recomputation. Because independently precomputed KV caches break cross-attention between retrieved documents, a small but critical subset of tokens ( ∼\sim15%) must be recomputed using the full model weights to restore generation quality [20], [30]. This recomputation presents a highly heterogeneous workload consisting of compute-intensive, dense matrix multiplications (GEMMs), element-wise softmax operations and matrix-vector multiplications (GEMVs). This exceeds the capabilities of not only existing decode-only ISPs, but conventional accelerator paradigms overall. Rigid 2D systolic arrays suffer catastrophic underutilization (zero-padding bubbles) when faced with 1D decode vectors or irregular sparse masks, while standard Single Instruction Multiple Data (SIMD) architectures lack the inter-

This work was supported by Samsung Research Funding & Incubation Center for Future Technology under Project Number SRFC-IT2302-05.

PE data forwarding required for efficient GEMM execution. Unable to absorb the workload internally, current systems are forced into a disjoint execution flow: the entire KV cache must be first read from the storage and hauled to the GPU for recomputation, and read yet again for query attention; streaming multi-gigabyte data across the PCIe bus twice.

To mitigate the issue, we present MemLLM, an in-storage processing architecture that eliminates this I/O wall by performing the precomputed-KV attention pipeline entirely within the SSD, without ever transferring the full KV cache to the host. MEMLLM targets on-device RAG with precomputed document KV caches and selective recomputation under long-context, short-answer workloads; we delineate this scope and its boundaries in Section VII. MEMLLM's design is governed by three I/O minimization principles.

Reduce NAND I/O. MEMLLM fuses selective recomputation and query attention into a single NAND-read pass via a unified kernel that constructs a combined query matrix ( QfusedQ_{fused}) from the recomputation targets and the user query. A hardware-based stream filter logic compacts the valid tokens from the irregular recomputation mask into a dense stream, allowing the compute units to process only the necessary tokens without wasting cycles on masking and zero-padding. This fusion halves the NAND read volume and completely eliminates the write-back penalty, as recomputed KV entries are consumed in situ within the same streaming pass.

Utilize aggregated NAND bandwidth. Rather than funneling all NAND data through a centralized accelerator bottlenecked by the SSD's internal bus, MEMLLM distributes lightweight Elastic-SIMD accelerators to each NAND channel endpoint. Each Elastic-SIMD dynamically reconfigures its datapath between broadside mode (parallel GEMV for decode) and cascaded mode (systolic-like forwarding for GEMM during prefill), maintaining high PE utilization across the heterogeneous RAG workload. This per-channel architecture delivers the full aggregate NAND bandwidth directly to computation without any internal bus contention.

Eliminate internal DRAM I/O. A central coordinator logic merges per-channel partial attention outputs using a stateful online softmax reduction engine, hosted entirely in the controller's global SRAM. Rather than repeatedly reading and writing partial sums to the controller's DRAM, MEMLLM leverages RAG's length asymmetry to avoid the internal bandwidth bottleneck entirely. Because QfusedQ_{fused} and the final output OfinalO_{final} are small enough to reside completely on-chip, the SSD's DRAM is entirely removed from the attention critical path. To this end, the total PCIe traffic for the entire attention computation is bounded to a single O(1)O(1) transfer that is completely independent of context length.

We implemented MEMLLM's Elastic-SIMD architecture in RTL and prototyped it on a 16nm FPGA [31]. We evaluated the cycles required for each GPU kernel using the prototype and an NVIDIA Jetson Orin NX board [32] and integrated it with a cycle-accurate SSD simulator [33]. Evaluation across eight real-world datasets and six LLM models shows that MEMLLM achieves an average end-to-end speedup of 4.06×4.06\times.

The main contributions of this paper are as follows:

Figure

(a) Decoder-only transformer.

Figure

(b) Online softmax.

Fig. 1: LLM inference.

• Analysis of the on-device RAG I/O wall. We provide the first systematic characterization of how precomputed KV caches and their selective recomputation create a disjoint execution bottleneck that conventional accelerator paradigms cannot resolve, establishing the need for an end-to-end ISP for precomputed-KV RAG.

• Fused kernel with hybrid mask handling. We propose a single-pass fused kernel that eliminates redundant NAND reads and write-backs by co-processing selective recomputation and query attention against the same KV stream, with a hardware-based filter logic that compacts irregular sparse masks into dense compute.

• Per-channel Elastic-SIMD. We design a distributed, dynamically reconfigurable SIMD fabric that sustains high utilization across GEMV, thin-GEMM, and element-wise softmax workloads without the area overhead and underutilization of rigid 2D systolic arrays.

• NAND-stationary tiling and DRAM-less data flow. We co-design the hardware micro-architecture with a NAND-stationary tiling algorithm and a global SRAM-based stateful reduction engine that completely bypasses the SSD’s DRAM, ensuring that internal storage bandwidth is strictly dedicated to NAND reads rather than intermediate memory traffic.

References (63)