KV Cache Token Eviction via Segmentation and Group Importance

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Large language models (LLMs) face challenges in efficiently managing key-value caches (KV caches) due to the high memory requirements and dynamic growth, leading to inefficiencies in text generation tasks.

Innovation Solution

The proposed solution involves dividing the KV cache into three parts: start tokens, evicting tokens, and recent tokens, and applying different eviction strategies to each part, while also grouping tokens into pages to optimize memory usage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If the KV cache is used to store all tokens during text generation, then the accuracy of language model inference is maintained, but the memory requirements increase significantly

Engineering Contradiction:
Improveinference accuracyVSAvoidmemory requirements
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The KV cache is segmented into three distinct parts: start tokens (first N tokens), evicting tokens (middle portion), and recent tokens (last M tokens). This segmentation allows differential treatment of token importance, preserving critical tokens while enabling eviction of less important middle tokens, thus reducing memory usage while maintaining inference accuracy for essential tokens

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Different eviction strategies are applied to different segments of the KV cache. The start tokens portion uses a freeze strategy (no eviction), the evicting tokens portion uses importance-based eviction, and the recent tokens portion uses a recency-based strategy. This local quality approach ensures that tokens with different importance characteristics are managed appropriately, balancing memory efficiency with accuracy preservation

Inventive Principle:
Principle #3Local quality

2Loss of information

If the KV cache grows dynamically to accommodate all generated tokens, then the completeness of context information is maintained, but the efficiency of inference workloads decreases due to memory management overhead

Engineering Contradiction:
Improvecontext information completenessVSAvoidinference efficiency
Core Design Contradiction:
Loss of informationVSProductivity

Solution Approach 1:

The KV cache management is made dynamic through adaptive eviction strategies. The system continuously evaluates token importance and adjusts which tokens to evict based on current cache size and usage patterns. This dynamic approach allows the cache to adapt to varying workload requirements, maintaining context completeness when needed while improving efficiency by evicting unnecessary tokens

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The system changes parameters such as the size of the start tokens portion (N) and recent tokens portion (M), as well as the eviction threshold, to optimize the balance between context retention and memory efficiency. By adjusting these parameters based on workload characteristics, the system can maintain inference efficiency while preserving necessary context information

Inventive Principle:
Principle #35Parameter changes

3Device complexity

If the KV cache is managed with a single eviction strategy, then the device complexity is reduced, but the accuracy of language model inference deteriorates due to uniform treatment of all tokens

Engineering Contradiction:
Improvecache management complexityVSAvoidinference accuracy
Core Design Contradiction:
Device complexityVSReliability

Solution Approach 1:

The KV cache is divided into distinct segments (start tokens, evicting tokens, recent tokens) that are managed with different eviction strategies. This segmentation resolves the contradiction by allowing sophisticated differential management without requiring a single complex unified strategy, thereby maintaining inference accuracy through appropriate treatment of different token types

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The token eviction circuitry is designed to perform multiple functions: it can freeze tokens, evict tokens based on importance, and prioritize recent tokens. This multi-functionality allows a single cache management system to handle diverse token requirements, maintaining accuracy while avoiding the need for separate management systems for different token types

Inventive Principle:
Principle #6Universality (Multi-functionality)

4Quantity of substance

If more memory is allocated to the KV cache, then the capacity to store context tokens increases, but the deployment feasibility on memory-constrained accelerators decreases

Engineering Contradiction:
Improvecache storage capacityVSAvoiddeployment feasibility
Core Design Contradiction:
Quantity of substanceVSAdaptability or versatility

Solution Approach 1:

The system extracts and evicts less important tokens from the middle portion of the KV cache, removing them from memory storage. This extraction approach reduces the memory capacity required for the KV cache while maintaining the ability to store essential context tokens, thereby enabling deployment on memory-constrained accelerators without sacrificing critical context information

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The system adjusts parameters such as the eviction threshold and cache segment sizes to optimize memory usage for deployment on resource-constrained devices. By changing these parameters, the KV cache can operate effectively with reduced memory capacity, making deployment feasible on various accelerator types with different memory constraints

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS20250036876A1Methods and apparatus to evict tokens from a key value cache
Publication Date: 2025.01.30 INTEL CORP
  • US20250036876A1 patent drawing
  • US20250036876A1 patent drawing
  • US20250036876A1 patent drawing

AI summary

Systems, apparatus, articles of manufacture, and methods are disclosed to evict tokens from a key value cache. An example apparatus includes interface circuitry, machine readable instructions, and programmable circuitry to at least one of instantiate or execute the machine readable instructions to: determine score history values for tokens based on attention scores associated with the tokens, wherein a token is a numerical representation of text, after a number of tokens present in the key value cache exceeds a threshold number of tokens, compute group importance scores for groups of tokens based on score history values of the tokens in the groups of tokens, identify low-ranked groups of tokens having lowest group importance scores, the low-ranked groups of tokens associated with an eviction range in the key value cache, and remove an identified low-ranked group of tokens from the eviction range of the key value cache.