[Explanation] ReFreeKV Technology to Eliminate Large Memory Consumption by LLMs

IT

A new KV cache compression technology, “ReFreeKV,” has been announced. This technology overcomes the challenge of setting thresholds for data dependence that traditional methods face, enabling adaptive memory consumption according to input content while maintaining inference accuracy equivalent to full cache.

The “KV Cache” Barrier Hindering LLM Inference

When large language models (LLMs) generate text sequentially, a memory area called the “KV cache” is essential to utilize past token information without recalculating it. However, the size of this KV cache increases linearly in proportion to the length of the input context (context length). For example, models like the Llama3-70B, released in 2024, require an enormous memory capacity of up to about 50GB to process just 20,000 tokens. Currently, generative AI is trending toward handling ultra-long texts ranging from tens of thousands to millions of tokens, but the expansion of KV caches is the biggest bottleneck, squeezing GPU memory capacity and bandwidth, significantly reducing system execution efficiency. The figure below shows how memory consumption surges as model size and context length increase.

The Birth of “ReFreeKV,” Breaking the Limits of Existing Methods

Previously, memory reduction methods such as “pruning,” which removes less important tokens from the cache, have been proposed. Representative algorithms include H2O and SnapKV, but these faced one major challenge in practical application. This means that to achieve optimal performance, you must pre-determine the threshold (budget) for each input data or domain—such as how much memory to reserve. According to the study, a contradiction arose: while 20% cache is sufficient for one dataset, accuracy drops significantly for another mathematical reasoning task unless 80% is retained. Announced in February 2025, “ReFreeKV” was designed to overcome the practical limitation of “input dependency threshold setting” through proprietary adaptive algorithms.

The groundbreaking concept of “threshold-free”

ReFreeKV’s goal of “Threshold-Free” is to automatically allocate resources for any input, maintaining performance equivalent to full cache without human intervention. In real-world use cases, user questions span diverse domains and difficulty levels, with no clear boundaries. Traditional methods of “fixed percentage” memory depletion risked losing information on complex reasoning questions and fatally degrading answer quality. ReFreeKV provides a robust inference experience by internalizing conditions under which the model detects missing information and stops pruning. This enabled truly “smart” memory management, applying high compression rates for simple questions and allocating sufficient memory for complex tasks.

ReFreeKV’s Innovative Mechanism and “Uni-Metric”

A precise pruning process composed of two stages

ReFreeKV consists of two-stage logic that enables efficient parallel computation. In the first stage, the “initial ranking,” the importance of each token is assessed based on its position. Here, inductive bias is used, such as the highly important position called “attention sync” at the beginning of sentences, or the most recent context that prioritizes it. In the following second phase, tokens sorted in order of lowest importance are gradually removed, and deletion stops at the moment information loss is close to exceeding the acceptable range. This process is highly parallelized using operators such as PyTorch’s cumulative-sum, and is designed to run with extremely low latency, comparable to traditional fixed-budget methods. The following flowchart visualizes the operation process of ReFreeKV.

Determining Stop Conditions Using the Attention Matrix Norm

At the core of ReFreeKV is a metric called “Uni-Metric” that determines the conditions for stopping. The research team discovered that changes in the attention matrix’s “Frobenius norm (L2 norm)” strongly correlate with changes in model performance when the cache is removed. Specifically, it compares the original full attention matrix norm with the “reduced matrix” norm after removing specific tokens. Experiments have demonstrated that if the difference in this norm is below the universal threshold of “1%,” the model’s output accuracy can be maintained near-lossless. This 1% value works stably regardless of input length or task type, so operators do not need to adjust parameters individually.

Protection strategies for the ‘initial layer’ that help understand the model

While pushing memory reduction to the extreme, ReFreeKV carefully protects the foundational part of the model’s “understanding of meaning.” Case studies in research showed that the initial few layers of LLMs focused uniform attention on forming dependencies between tokens within context. If you forcibly scrape the cache on the first layer, you may lose access to important information on later layers, resulting in illogical answers and incomprehensible loops. For this reason, the implementation of ReFreeKV adopted a strategy of fully protecting the first two layers of the model as if they were excluded from pruning. This balanced design is the key to achieving both high compression rates and high precision.

Overwhelming strength and future prospects demonstrated by research data

Versatility and stability proven by 13 datasets

The effectiveness of ReFreeKV is backed by extensive experiments using 13 diverse datasets covering mathematical reasoning, science, common sense, coding, and document summarization. In evaluations using the Llama3-8B, the average performance for all tasks was slightly above the full cache state (an improvement of about 0.12%), while automatic appropriate memory reduction was achieved. Notably, while competing existing methods caused serious accuracy declines with fixed budget settings like 20% or 50% (especially for challenging tasks like GSM8K), ReFreeKV consistently maintained scores equal to or better than full cache. This suggests that the technology is not specialized for specific benchmarks but is extremely robust against unpredictable real-world open inputs.

Optimal resource allocation according to tasks, from math to summarization

One of ReFreeKV’s standout features is that the difficulty of tasks is naturally reflected as “budget consumption.” Experimental data shows that for tasks in the “mathematics and science” field, which require precise calculations and step-by-step reasoning, the model automatically allocates over 90% of the budget and handles information carefully. On the other hand, for tasks like “text summarization” or “Q&A,” which require removing vast amounts of information, the system determines that even a cache of about 15% can achieve sufficient accuracy, and automatically performs significant memory reduction. This dynamic resource management holds the potential not only for saving memory but also as a new metric for analyzing the complexity of input data.

Dramatic improvement in inference speed and throughput

Reducing memory consumption directly contributes to improving the processing power (throughput) of inference systems. Efficiency analysis when applying ReFreeKV confirmed a 10% to 20% increase in throughput compared to standard generation processes. This is because pruning the cache reduces the amount of data the GPU must process and increases the number of tokens it can process per second. It has also been found that ReFreeKV maintains its performance advantages even when increasing batch size (number of simultaneous requests). This is expected to enable the provision of more affordable and faster AI services on personal PCs and mobile devices with limited resources, or on large-scale cloud servers handling thousands of requests simultaneously.

The Future of AI Operations and Future Highlights

The significance of expanding from edge devices to large-scale servers

Memory efficiency technologies like ReFreeKV represent a major step toward accelerating the “democratization” of AI. Traditionally, running high-performance models like Llama 3 in long context required servers equipped with multiple expensive high-end GPUs. However, if memory consumption can be adaptively suppressed, advanced inference can be performed without compromising context, even on cheaper consumer hardware or edge devices like smartphones. Furthermore, according to Gartner’s forecast, by 2030, the inference cost of LLMs will be reduced by 90%, and innovations at the model design level, such as ReFreeKV, will be one of the key technical factors in realizing this forecast.

Expectations for further improvements in compression ratios and theoretical guarantees

Future research challenges include bridging the gap between the compression rate currently achieved by ReFreeKV and the theoretical “true minimum budget.” For example, there are cases where a certain task currently holds 84% of memory, but in reality, an “excessive safety margin” remains, where accuracy does not drop even after cutting down to 50%. There is growing hope for the development of methods to cut this more aggressively and safely. Also, while current methods boast high stability based on empirical experimental data, there is no established “mathematical or theoretical guarantee” that performance degradation will never occur. As theoretical support in this field advances, it is expected that the adoption of AI agents directly linked to mission-critical tasks and safety will accelerate.

[#ReFreeKV #LLM #KVキャッシュ #メモリ削減 #AI推論 #推論コスト削減 #生成AI]

コメント

Copied title and URL