SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2609.03430 · September 2026

Random Attention: Rethinking KV Cache Eviction for Efficient Reasoning

Huan Wang, Silvio Savarese, Jiawei Han, Heng Wang, Liangwei Yang, Cheng Qian, Heng Ji, Shelby Heinecke, Wenting Zhao, Weizhi Zhang, Jielin Qiu

arXiv · PDF · Open in the Atlas

Code that ran

8 of 12 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 4 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/2609.03430.json · badge: /api/ran/2609.03430.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
SalesforceAIResearch/Random-Attention canonical (classifier label)
classifier basis: census
8 ran · 4 no recorded run
FunctionStatusWhere it lives
acc_ci Ran
ran, honoured the contract we drafted
SalesforceAIResearch/Random-Attention/kvcompress/synth/scoreboard.py
code served (permissive licence) · get_code("37e3428250b62925")
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, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np

# Create a small numpy array for accuracy values
acc_array = np.array([0.85, 0.87, 0.90, 0.88, 0.86, 0.89, 0.84, 0.91])

# Create the dict 'a' with 'acc' key containing the numpy array
a = {'acc': acc_array}

# Number of bootstrap samples
boot = 100

# Create a random number generator with a seed for reproducibility
rng = np.random.default_rng(seed=42)

ARGS = {
    'a': a,
    'boot': boot,
    'rng': rng
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
boot_ci Ran
ran, honoured the contract we drafted
SalesforceAIResearch/Random-Attention/kvcompress/analysis/bootstrap_ci.py
code served (permissive licence) · get_code("eabe13fdd2b77b60")
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, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 random

# Set random seed for reproducibility
random.seed(42)

# Construct per_prob: dict of problem_id -> list of binary outcomes
per_prob = {
    "problem_1": [1, 0, 1, 1, 0],
    "problem_2": [1, 1, 0, 1],
    "problem_3": [0, 1, 1, 0, 1, 1],
    "problem_4": [1, 0, 0, 1, 0],
}

ARGS = {
    "per_prob": per_prob,
    "n_boot": 10000,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
lens Ran
ran; our contract draft was wrong, not the code
SalesforceAIResearch/Random-Attention/figures/effective_throughput.py
code served (permissive licence) · get_code("e1ef7f39b6437aaa")
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, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 os
import tempfile
import json
import shutil

# Create temporary directory structure to mock the file system
tmpdir = tempfile.mkdtemp()

# Create mock directory structure
task = 'math'
method = 'dense'

# Create nested directories matching the pattern
base_path = os.path.join(tmpdir, 'gate2', 'Qwen3-4B', 'dense', 'math_001', 'run_001')
os.makedirs(base_path, exist_ok=True)

# Create a mock other_info.json file with generate_lens data
other_info_data = {
    'generate_lens': [10, 15, 20, 25, 30]
}

with open(os.path.join(base_path, 'other_info.json'), 'w') as f:
    json.dump(other_info_data, f)

# Mock the environment and DIRS
os.environ['RA_ENGINE'] = tmpdir

# Update DIRS to point to our temp directory
DIRS = {
    ('math', 'dense'): [f'{tmpdir}/gate2/Qwen3-4B/dense/math_*'],
    ('math', 'random_pp'): [f'{tmpdir}/gate2/Qwen3-4B/random_pp/math_*'],
    ('math', 'vase'): [f'{tmpdir}/gate2/Qwen3-4B/vase_faithful/math_*'],
    ('math', 'snapkv'): [f'{tmpdir}/gate2/Qwen3-4B/attn/math_*'],
    ('math', 'caote'): [f'{tmpdir}/gate2/Qwen3-4B/caote/math_*'],
    ('math', 'triattn'): [f'{tmpdir}/gate2/Qwen3-4B/math_K1024/triattn_ph']
}

ARGS = {
    'task': 'math',
    'method': 'dense'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
load_scoreboard Ran
ran; our contract draft was wrong, not the code
SalesforceAIResearch/Random-Attention/figures/plot_mechanism.py
code served (permissive licence) · get_code("c4d00d07ba83a46f")
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, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type 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 tempfile
import os

# Create a temporary scoreboard file with valid data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("cellA arm1 0.85 [0.80, 0.90] 0.92 [0.88, 0.96] 100\n")
temp_file.write("cellA arm2 -- 0.88 [0.85, 0.91] 50\n")
temp_file.write("cellB arm1 0.75 [0.70, 0.80] 0.80 [0.75, 0.85] 75\n")
temp_file.write("cellB arm3 0.95 [0.92, 0.98] 0.97 [0.94, 0.99] 200\n")
temp_file.close()
temp_path = temp_file.name

ARGS = {
    'path': temp_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
mean Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
SalesforceAIResearch/Random-Attention/kvcompress/analysis/analyze_union.py
code served (permissive licence) · get_code("2971e9e45e0853ea")
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, through the batch API) and returned float, ndim 0, dtype family float, shape () 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)

# The function 'mean' takes a single parameter 'xs' which should be an iterable
# It computes the sum and divides by length, so xs needs to support sum() and len()
# We'll test with a list of numbers (both int and float work)

xs = [1, 2, 3, 4, 5]

ARGS = {
    "xs": xs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
parse_grid Ran
ran, honoured the contract we drafted
SalesforceAIResearch/Random-Attention/figures/plot_overview.py
code served (permissive licence) · get_code("a373a8dca3e8e8bf")
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, through the batch API) and returned int, ndim 0, dtype family int, shape () 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 os
import re
import numpy as np
import tempfile

# Create a temporary LaTeX file with test data
temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.tex', delete=False)
temp_file.write("""% Test LaTeX table
\\documentclass{article}
\\begin{document}
\\begin{tabular}{cccccc}
\\dense{} & 0.850 & 0.860 & 0.870 & 0.880 & 0.890 \\\\
\\snapkv{} & 0.820 & 0.830 & 0.840 & 0.850 & 0.860 \\\\
\\rkv{} & 0.800 & 0.810 & 0.820 & 0.830 & 0.840 \\\\
\\vase{} & 0.770 & 0.780 & 0.790 & 0.800 & 0.810 \\\\
\\triattn{} & 0.750 & 0.760 & 0.770 & 0.780 & 0.790 \\\\
\\method{} (ours) & 0.900 & 0.910 & 0.920 & 0.930 & 0.940 \\\\
\\end{tabular}
\\end{document}
""")
temp_file.close()

# Define blocks list - this is used as keys in the acc dict
blocks = ['task1', 'task2', 'task3', 'task4', 'task5', 'task6']

# Define ARGS dict with all required parameters
ARGS = {
    'path': temp_file.name,
    'blocks': blocks
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () 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
read Ran
ran; our contract draft was wrong, not the code
SalesforceAIResearch/Random-Attention/figures/plot_throughput.py
code served (permissive licence) · get_code("94c268f7736d16d7")
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, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type 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 tempfile
import os
import csv

# Create a temporary TSV file with test data
temp_dir = tempfile.mkdtemp()
test_file = os.path.join(temp_dir, "test_metrics.tsv")

with open(test_file, 'w', newline='') as f:
    writer = csv.DictWriter(f, fieldnames=['model', 'layer', 'tok_s', 'peak_GB'], delimiter='\t')
    writer.writeheader()
    writer.writerow({'model': 'bert', 'layer': '1', 'tok_s': '100.5', 'peak_GB': '2.3'})
    writer.writerow({'model': 'gpt', 'layer': '2', 'tok_s': '150.2', 'peak_GB': '3.1'})
    writer.writerow({'model': 'bert', 'layer': '3', 'tok_s': '120.7', 'peak_GB': '2.8'})

ARGS = {
    'path': test_file,
    'keyfields': ['model', 'layer']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
yerr Ran
ran; our contract draft was wrong, not the code
SalesforceAIResearch/Random-Attention/figures/plot_mechanism.py
code served (permissive licence) · get_code("f252f988d00d9459")
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, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type 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 numpy as np

# Create sample data: list of dictionaries with lo_key, hi_key, and val_key
rows = [
    {'lower': 0.5, 'upper': 1.5, 'value': 1.0},
    {'lower': 1.2, 'upper': 2.8, 'value': 2.0},
]

lo_key = 'lower'
hi_key = 'upper'
val_key = 'value'

ARGS = {
    'rows': rows,
    'lo_key': lo_key,
    'hi_key': hi_key,
    'val_key': val_key,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
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
R_ci Not yet run
unverified (harvested, no recorded run)
SalesforceAIResearch/Random-Attention/kvcompress/synth/scoreboard.py
code served (permissive licence) · get_code("12845c22f83668e7")
How it ran

no invocation recorded.

load Not yet run
unverified (harvested, no recorded run)
SalesforceAIResearch/Random-Attention/kvcompress/synth/scoreboard.py
code served (permissive licence) · get_code("43cf494e4b88f000")
How it ran

no invocation recorded.

meta Not yet run
unverified (harvested, no recorded run)
SalesforceAIResearch/Random-Attention/figures/plot_mechanism.py
code served (permissive licence) · get_code("23bc5857a725e7d4")
How it ran

no invocation recorded.

table Not yet run
unverified (harvested, no recorded run)
SalesforceAIResearch/Random-Attention/kvcompress/analysis/carrier_mass.py
code served (permissive licence) · get_code("506d001c8f961eac")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 11 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
mean 1 other paper
1 dated earlier
2604.19457 (2026-04)
Four-Axis Decision Alignment for Long-Horizon Enterprise AI Agents

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

Large language models achieve superior performance on tasks that require extended reasoning, but long chains of thought make the KV cache a severe memory bottleneck. Existing KV cache compression methods share one paradigm: score each cached token by some estimate of how much it will matter later, and keep the top-scoring ones. We show that the selection signal contributes almost nothing. Random Attention keeps the prompt and evicts uniformly at random within each attention head, computing no score at all; across four models and six reasoning tasks it matches the strongest prior evictor while serving 32-43% higher throughput than it in vLLM deployment. Controlled experiments explain this by showing that 1) the prompt is the fragile part of the cache, and most of the gap between selectors is just whether their selection signal happened to keep it; 2) the reasoning trace protects itself against eviction with redundancy at two levels, in the text (the model restates what it still needs as it works) and across attention heads (each keeps its own copy of the trace), so once the prompt is safe, a random draw retains enough copies of what the model still needs, and no score is required to pick them. Our code is publicly available at https://github.com/SalesforceAIResearch/Random-Attention.

For agents

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

get_harvested_code_for_paper("2609.03430")
get_code_for_paper("2609.03430")
have("2609.03430")

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

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

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

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

Connect an agent — have() is free.