SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2412.03409 · NeurIPS · 2025

PrefixKV: Adaptive Prefix KV Cache is What Vision Instruction-Following Models Need for Efficient Generation

Jianchao Tan, Jungong Han, Guiguang Ding, Hui Chen, Jiaxin Li, Ao Wang, Zijia Lin, Xunliang Cai, Kefeng Zhang

arXiv · PDF · Open in the Atlas

Code that ran

2 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 1 failure of our instrument; 3 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2412.03409.json · badge: /api/ran/2412.03409.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
thu-mig/prefixkv canonical (classifier label)
classifier basis: classifier_2025
2 ran · 1 no recorded run
THU-MIG/PrefixKV marked official in Papers with Code
Papers with Code archive
0 ran · 2 no recorded run
FunctionStatusWhere it lives
slice1d Ran
ran, honoured the contract we drafted
thu-mig/prefixkv/prefixkv.py
code served (permissive licence) · get_code("727f447af4c6cf17")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 3, dtype family float, shape (2, 2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create a small 3D tensor with shape (batch=2, sequence=4, features=3)
x = torch.randn(2, 4, 3)

# Define start and end indices for slicing the sequence dimension
start = 1
end = 3

ARGS = {
    "x": x,
    "start": start,
    "end": end,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 2, 3) — shape (2, 2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
slice3d Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
thu-mig/prefixkv/prefixkv.py
code served (permissive licence) · get_code("349c21c206f3e211")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 5, dtype family float, shape (2, 4, 3, 3, 6) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create a small 5D tensor for slicing
# Shape: (batch=2, dim1=4, dim2=3, dim3=5, dim4=6)
x = torch.randn(2, 4, 3, 5, 6)

# Define start and end indices for the slice operation on dimension 3
start = 1
end = 4

ARGS = {
    "x": x,
    "start": start,
    "end": end,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 5, dtype family float, shape (2, 4, 3, 3, 6) — shape (2, 4, 3, 3, 6) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
PrefixKV Not yet run
unverified (harvested, no recorded run)
THU-MIG/PrefixKV/prefixkv.py
code served (permissive licence) · get_code("ef0f018176d5ec13")
How it ran

no invocation recorded.

obtain_cdf_num Not yet run
unverified (harvested, no recorded run)
THU-MIG/PrefixKV/prefixkv.py
code served (permissive licence) · get_code("bec4a2080b4fd55d")
How it ran

no invocation recorded.

slice2d Not yet run
unverified (harvested, no recorded run)
thu-mig/prefixkv/prefixkv.py
code served (permissive licence) · get_code("38bd668b3d930f03")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 3 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
slice1d
brick of this paper's assembly: helper
4 other papers
3 dated earlier, 1 later · 1 only as an assembly brick
2309.14717 (2023-09)
QA-LoRA: Quantization-Aware Low-Rank Adaptation of Large Language Models
2309.17453 (2023-09)
Efficient Streaming Language Models with Attention Sinks
2407.18121 (2024-07)
Efficient Inference of Vision Instruction-Following Models with Elastic Cache
and 1 more not named here
slice2d
brick of this paper's assembly: helper
4 other papers
3 dated earlier, 1 later · 1 only as an assembly brick
2309.14717 (2023-09)
QA-LoRA: Quantization-Aware Low-Rank Adaptation of Large Language Models
2309.17453 (2023-09)
Efficient Streaming Language Models with Attention Sinks
2407.18121 (2024-07)
Efficient Inference of Vision Instruction-Following Models with Elastic Cache
and 1 more not named here
slice3d
brick of this paper's assembly: helper
4 other papers
3 dated earlier, 1 later · 1 only as an assembly brick
2309.14717 (2023-09)
QA-LoRA: Quantization-Aware Low-Rank Adaptation of Large Language Models
2309.17453 (2023-09)
Efficient Streaming Language Models with Attention Sinks
2407.18121 (2024-07)
Efficient Inference of Vision Instruction-Following Models with Elastic Cache
and 1 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Recently, large vision-language models (LVLMs) have rapidly gained popularity for their strong generation and reasoning capabilities given diverse multimodal inputs. However, these models incur significant computational and memory overhead during inference, which greatly hinders the efficient deployment in practical scenarios. The extensive key-value (KV) cache, necessitated by the lengthy input and output sequences, notably contributes to the high inference cost. Based on this, recent works have investigated ways to reduce the KV cache size for higher efficiency. Although effective, they generally overlook the distinct importance distributions of KV vectors across layers and maintain the same cache size for each layer during the next token prediction. This results in the significant contextual information loss for certain layers, leading to notable performance decline. To address this, we present PrefixKV, where "Prefix" means the top-ranked KV based on importance rather than position in the original sequence. It reframes the challenge of determining KV cache sizes for all layers into the task of searching for the optimal global prefix configuration. With an adaptive layer-wise KV retention recipe based on binary search, the maximum contextual information can thus be preserved in each layer, facilitating the generation. Extensive experiments demonstrate that our method achieves the state-of-the-art performance compared with others. It exhibits superior inference efficiency and generation quality tradeoffs, showing promising potential for practical applications. Code is available at https://github.com/THU-MIG/PrefixKV.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2412.03409")
get_code_for_paper("2412.03409")
have("2412.03409")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2412.03409.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2412.03409.svg)](https://syntology.ai/paper/2412.03409)

Connect an agent — have() is free.