LLM Inference in a Flash!

Sebastian Zhao, Minseo Kim, Coleman Hooper, Luca Manolache, Michael W. Mahoney, Yakun Sophia Shao, Kurt Keutzer, Amir GholamiarXiv 2026

TL;DR

This paper introduces an innovative co-design framework that enables large language model (LLM) inference to run directly on Flash-based Compute-in-Memory (CIM) hardware. By combining an end-to-end integer-only quantization pipeline with a static dictionary-based KV cache compression scheme, the authors bypass the traditional memory wall and Flash write-endurance bottlenecks. The resulting system delivers up to 4.4$\times$ faster decoding and 6.8$\times$ energy savings for long-context workloads with negligible loss in accuracy.

What Problem Does This Paper Address?

As LLMs handle increasingly longer sequences for applications like retrieval-augmented generation (RAG) and long-context agents, serving them efficiently has become incredibly difficult. LLM decoding is fundamentally bottlenecked by the "memory wall"—the reality that memory capacity and bandwidth are not scaling as fast as compute hardware.

Compute-in-Flash (storing weights and performing matrix multiplications directly inside flash memory/SSDs) is a promising alternative to expensive DRAM or HBM because it offers massive capacity and high internal read bandwidth. However, deploying LLMs on Flash CIM faces two major roadblocks:

  1. Limited Write Endurance: Flash cells degrade quickly under frequent write operations, making them poorly suited for the constantly updating Key-Value (KV) cache.
  2. Lack of Floating-Point Support: Flash controllers are highly optimized for simple integer operations and struggle with the high-precision floating-point (FP32) math required by nonlinear LLM layers like Softmax and RMSNorm.
Figure 1: Motivation and overview of LLM inference on flash compute-in-memory (CIM). (a) Comparison between traditional computing and CIM, illustrating the memory-wall bottleneck. (b) Key challenges for LLM decoding on flash CIM: frequent KV-cache writes (endurance) and costly FP32/nonlinear operations. (c) Proposed methods: end- to-end integer-only inference and dictionary-based KV caching.

Methods

The authors address these hardware constraints through a tailored algorithmic overhaul:

  • End-to-End Integer-Only Quantization: To avoid costly offloading to a host CPU/GPU for floating-point operations, the entire inference pipeline is kept in the integer domain. Linear layers run in INT8 (W8A8). Nonlinear operators (Softmax, RMSNorm, SwiGLU) are replaced with second-order polynomial approximations. To prevent numerical overflow during these integer approximations, they introduce a token-wise INT16 requantization step right before reduction operations.
  • Dictionary-Based KV Cache Compression: To solve the write-endurance problem, the authors transform the KV cache into a "read-mostly" structure. They train a static, overcomplete dictionary that resides permanently in Flash. Any new dynamic KV vector is represented as a sparse linear combination of these static dictionary atoms.
  • Projection-Based Greedy Pursuit: Instead of using standard Orthogonal Matching Pursuit (OMP)—which requires computationally heavy least-squares refitting that is ill-suited for CIM—they design a hardware-friendly greedy pursuit that relies strictly on linear matrix-vector projections and residual updates.
  • Query-Aware Hierarchical Sparsity: To further reduce internal read I/O, they implement a two-stage attention mechanism. The system first computes a coarse attention score using a very small dictionary budget ($K_{low}=3$) and then selectively refines only the top-N% most relevant tokens with a higher budget ($K_{high}=16$).

Datasets

The framework was calibrated and evaluated using several standard datasets:

  • The Pile (Validation Set): Used to calibrate quantization scales, smoothing parameters, and to extract key/value activations for training the overcomplete dictionaries.
  • WikiText-2: Used to evaluate language modeling perplexity during the quantization ablation studies.
  • LongBench: A comprehensive benchmark suite for long-context tasks (including multi-document QA, summarization, few-shot learning, and code completion) used to measure end-to-end downstream accuracy.

Key Insights and Ideas

  • Shifting from Dynamic Writes to Static Reads: The core conceptual leap is treating the KV cache as a sparse coding problem over a static dictionary. By turning a heavy write workload into a heavy read workload, they perfectly align the software with Flash's massive read capacity while protecting it from write wear.
  • Hardware-Algorithm Alignment: Algorithms that excel on GPUs (like OMP or full dequantization) fail on Flash CIM due to data transfer overheads. Simplifying the math to pure matrix-vector projections allows the system to exploit the massive internal parallel bandwidth of Flash arrays.
  • Coarse-to-Fine Filtering Saves I/O: Not all tokens in a long context are equally important. Spending a tiny fraction of compute to roughly filter token relevance allows the hardware to skip reading the vast majority of dictionary entries, dramatically lowering latency.

Key Results

The authors evaluated their approach on Llama-3.1-8B and Qwen-2.5-7B:

  • Accuracy Preservation: The combined integer-only and compressed KV cache pipeline retains 99% of the baseline FP16 accuracy across LongBench tasks.
  • Traffic Reduction: The hierarchical sparse coding scheme reduces dynamic KV cache traffic by 15$\times$.
  • System-Level Gains (S2 Configuration):
    • For short contexts (1K tokens), the system achieves a 3.1$\times$ latency speedup and 2.7$\times$ energy savings compared to a standard NPU+DRAM baseline.
  • For long contexts (256K tokens), the benefits scale up to a 4.4$\times$ latency speedup and 6.8$\times$ energy savings.

Limitations and Future Work

  • Prefill Phase Excluded: This work focuses entirely on the autoregressive generation (decode) phase. The prefill phase is highly compute-bound rather than memory-bound, making it much harder to map efficiently to CIM architectures which typically have lower peak compute performance than traditional GPUs.
  • Storage Redundancy: To optimize both the pursuit phase (which requires a transposed dictionary matrix) and the attention calculation (non-transposed), the system currently stores two copies of the Value dictionary in Flash, increasing the static storage footprint.

Summary updated

BibTeX
@misc{zhao2026llm,
  author = {Sebastian Zhao and Minseo Kim and Coleman Hooper and Luca Manolache and Michael W. Mahoney and Yakun Sophia Shao and Kurt Keutzer and Amir Gholami},
  title = {{LLM Inference in a Flash!}},
  year = {2026},
  eprint = {2609.16161},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.16161},
}
Figure