# US 2025/0061316 A1 · Dynamic quantization and memory management of key-value cache for serving large language models

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0061316 A1
- Document ID: US20250061316A1
- Status: Published application
- Kind: A1
- Application number: 18/934,700
- Filed: 2024-11-01
- Published: 2025-02-20
- Earliest claimed: 2024-11-01
- Assignees: Intel Corporation
- Applicants: Intel Corporation
- Inventors: Sameh Gobriel; Nilesh Jain; Vui Seng Chua; Juan Pablo Munoz; Gopi Krishna Jha
- Web page: https://patentgrep.com/patent/US20250061316A1

## CPC

- G06N 3/0495: Quantised networks; Sparse networks; Compressed networks
- G06F 12/0875: with dedicated cache, e.g. instruction or stack
- G06N 3/0455: Auto-encoder networks; Encoder-decoder networks
- G06N 3/063: using electronic means
- G06N 3/082: modifying the architecture, e.g. adding, deleting or silencing nodes or connections
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Key-value (KV) cache paging schemes can improve memory management for KV caches by storing a KV cache page having key tensors and value tensors for a fixed number of tokens in a fixed-sized block in the KV cache of a worker. To further improve memory management, the schemes can be modified to implement dynamic variable quantization. Quantization level of a KV cache page can be set based on a runtime importance score of the KV cache page. In addition, the quantization level of the KV cache page can be set based on the system load. The end result is a scheme that can achieve a high compression ratio of KV cache pages in the KV cache. Fitting more KV cache pages in the KV cache can lead to higher inference throughput, higher system-level user capacity, and higher end-to-end service availability.

## Claims

### Claim 1

An apparatus, comprising:
one or more processors to execute one or more instructions; and
a memory to store data and the one or more instructions, wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to:
determining an importance score of a key-value cache page based on one or more attention scores of one or more tokens, the key-value cache page having one or more key tensors and one or more value tensors calculated for one or more tokens by an attention head of a neural network;
determining a quantization level based on the importance score;
retrieving the key-value cache page at the determined quantization level from the memory; and
storing the key-value cache page quantized at the quantization level in a key-value cache block of a key-value cache.

### Claim 2 (depends on 1)

The apparatus of claim 1, wherein the one or more instructions further cause the one or more processors to:
updating a memory pointer to reference the key-value cache page quantized at the quantization level.

### Claim 3 (depends on 1)

The apparatus of claim 1, wherein the one or more instructions further cause the one or more processors to:
quantizing the key-value cache page at different quantization levels; and
storing the key-value cache page quantized at the different quantization levels in the memory.

### Claim 4 (depends on 1)

The apparatus of claim 1, wherein determining the importance score is performed in response to a swap-out event of the key-value cache page.

### Claim 5 (depends on 1)

The apparatus of claim 1, wherein determining the importance score is performed in response to one or more new tokens being added to the key-value cache page.

### Claim 6 (depends on 1)

The apparatus of claim 1, wherein determining the quantization level is performed in response to a change in a number of outstanding requests to be executed by the neural network.

### Claim 7 (depends on 1)

The apparatus of claim 1, wherein determining the importance score comprises:
determining whether at least one of the one or more attention scores is greater than a threshold.

### Claim 8 (depends on 1)

The apparatus of claim 1, wherein determining the importance score comprises:
determining a ratio of a count of pivotal tokens whose attention scores is greater than a threshold and a sum of counts of pivotal tokens of the key-value cache page and one or more further key-value cache pages.

### Claim 9 (depends on 1)

The apparatus of claim 1, wherein determining the quantization level based on the importance score comprises:
determining the quantization level according to a set of quantization levels, the set of quantization levels corresponding to different ranges of importance scores.

### Claim 10 (depends on 9)

The apparatus of claim 9, wherein the set of quantization levels is determined based on one or more of: a maximum error tolerance, a total available memory of the key-value cache, a maximum concurrent load target, and a number of outstanding requests to be executed by the neural network.

### Claim 11

One or more non-transitory computer-readable media storing instructions executable by a computing processor to perform operations for memory management, the operations comprising:
determining an importance score of a key-value cache page based on one or more attention scores of one or more tokens, the key-value cache page having one or more key tensors and one or more value tensors calculated for one or more tokens by an attention head of a neural network;
determining a quantization level based on the importance score;
retrieving the key-value cache page at the determined quantization level from a memory; and
storing the key-value cache page quantized at the quantization level in a key-value cache block of a key-value cache.

### Claim 12 (depends on 11)

The one or more non-transitory computer-readable media of claim 11, wherein the operations further comprise:
updating a memory pointer to reference the key-value cache page quantized at the quantization level.

### Claim 13 (depends on 11)

The one or more non-transitory computer-readable media of claim 11, wherein the operations further comprise:
quantizing the key-value cache page at different quantization levels; and
storing the key-value cache page quantized at the different quantization levels in the memory.

### Claim 14 (depends on 11)

The one or more non-transitory computer-readable media of claim 11, wherein determining the importance score is performed in response to a swap-out event of the key-value cache page.

### Claim 15 (depends on 11)

The one or more non-transitory computer-readable media of claim 11, wherein determining the importance score is performed in response to one or more new tokens being added to the key-value cache page.

### Claim 16 (depends on 11)

The one or more non-transitory computer-readable media of claim 11, wherein determining the quantization level is performed in response to a change in a number of outstanding requests to be executed by the neural network.

### Claim 17

A method for memory management, comprising:
determining an importance score of a key-value cache page based on one or more attention scores of one or more tokens, the key-value cache page having one or more key tensors and one or more value tensors calculated for one or more tokens by an attention head of a neural network;
determining a quantization level based on the importance score; and
storing the key-value cache page quantized at the quantization level in a key-value cache block of a key-value cache.

### Claim 18 (depends on 17)

The method of claim 17, wherein determining the importance score is performed in response to a swap-out event of the key-value cache page.

### Claim 19 (depends on 17)

The method of claim 17, further comprising:
quantizing the key-value cache page at different quantization levels;
storing the key-value cache page quantized at the different quantization levels in a memory; and
retrieving the key-value cache page quantized at the quantization level from the memory.

### Claim 20 (depends on 17)

The method of claim 17, wherein determining the quantization level based on the importance score comprises:
determining the quantization level according to a set of quantization levels, the set of quantization levels corresponding to different ranges of importance scores, wherein the set of quantization levels is determined based on one or more of: a maximum error tolerance, a total available memory of the key-value cache, a maximum concurrent load target, and a number of outstanding requests to be executed by the neural network.
