Abstract
Large Language Models (LLMs) are increasingly deployed on mobile devices for tasks involving long-form generation, such as document summarization and multi-turn reasoning. However, the Key-Value (KV) cache required for these tasks grows linearly with sequence length, quickly exceeding the limited DRAM available on smartphones. While offloading the KV cache to flash storage is a viable strategy, existing retrieval-based methods struggle with "distribution shift"—a phenomenon where the data distribution of the KV cache evolves during generation, rendering initial retrieval indexes inaccurate. We propose DynaKV, an adaptive management system that maintains high retrieval accuracy and efficiency through migration-free cluster adaptation and continuity-centric flash management. Our evaluation shows that DynaKV improves accuracy by 1.38× and end-to-end latency by 1.47× compared to state-of-the-art methods.
Introduction
The deployment of LLMs on edge devices like smartphones is hindered by a fundamental hardware constraint: memory capacity. Modern mobile devices typically possess less than 12GB of DRAM, while the KV cache for a long-sequence task can easily consume several gigabytes. When memory is exhausted, the system may crash or suffer from severe performance degradation due to swapping.
To mitigate this, researchers have turned to tiered memory systems, offloading the KV cache to the device's flash storage. Retrieval-based methods then fetch only the most relevant KV entries for each decoding step. However, these methods often rely on static indexing built during the "prefill" phase. As the model generates hundreds or thousands of new tokens, the underlying data distribution shifts, leading to "misaligned" indexes that either miss critical context (reducing accuracy) or fetch excessive data (increasing latency).
The Challenge: KVCache Distribution Shift
The core problem identified in this work is the KVCache Distribution Shift. During the prefill phase, the model processes the initial prompt, and the resulting KV entries are clustered to build a retrieval index. However, as the decoding phase progresses, the newly generated tokens often exhibit different semantic patterns.
As shown in Figure 4, static or local update strategies quickly deviate from the "optimal partition" as the sequence length increases from 0.5K to 1.5K tokens. This misalignment means that the centroids used for retrieval no longer accurately represent their clusters, causing the system to retrieve irrelevant data or skip essential context.
DynaKV System Design
DynaKV addresses these challenges through a three-pronged architectural approach designed specifically for the constraints of mobile hardware.
1. Migration-Free Cluster Adaptation
To handle distribution shift without incurring heavy I/O overhead, DynaKV monitors the variance (cohesion) of each cluster. When a cluster's variance exceeds a head-specific threshold, indicating it has become too "messy," the system triggers a split. Crucially, this splitting occurs only when the cluster is already loaded into DRAM for processing. By performing the update "in-flight," DynaKV avoids the expensive process of reading data from flash solely for the purpose of re-indexing.
2. Continuity-Centric Flash Management
Mobile flash storage is optimized for sequential access; random I/O operations (IOPS) are significantly slower. DynaKV exploits this by co-locating highly correlated clusters physically adjacent to each other on the storage medium. Furthermore, it implements a dual-head flash layout, allowing clusters to expand or split from both ends of a storage pool. This design ensures that updates can be written sequentially, maximizing the effective bandwidth of the flash memory and reducing latency.
3. Memory-Efficient Cache Design
DynaKV manages a "virtual cache" that spans both DRAM and flash. It employs a specialized replacement policy that prioritizes keeping small, recently updated clusters in DRAM. The authors observed that these "hot" clusters are the most likely to be accessed in subsequent decoding steps. By keeping them in fast memory, the system minimizes the frequency of flash retrievals.
Experimental Evaluation
The authors evaluated DynaKV using five popular on-device LLMs (Qwen2.5, Llama3.2, Mistral, etc.) across reasoning, story generation, and conversation tasks.
- Accuracy: DynaKV achieved 1.38× higher accuracy on average compared to existing methods like PQCache and ClusterKV. It maintained performance levels remarkably close to the theoretical maximum (the "No Cluster" baseline).
- Latency: The system provided a 1.47× speedup in end-to-end decoding latency. By optimizing flash access patterns, it improved effective bandwidth by 2.10×.
- Energy Efficiency: Due to the significant reduction in execution time and optimized I/O, DynaKV reduced overall energy consumption by 1.57×.
Conclusion
DynaKV demonstrates that adaptive, hardware-aware management of the KV cache is essential for long-sequence LLM inference on smartphones. By addressing the distribution shift problem and optimizing for the sequential-access nature of flash storage, DynaKV enables mobile devices to handle complex, long-form tasks with high accuracy and low latency. Future work includes integrating DynaKV with KV cache quantization techniques and extending the framework to heterogeneous mobile accelerators like GPUs and NPUs.
Summary updated