SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2601.20326 · 2026

Beyond Speedup - Utilizing KV Cache for Sampling and Reasoning

Sinno Pan, Hui-Ling Zhen, Mingxuan Yuan, Xing Li, Zeyu Xing

arXiv · PDF · Open in the Atlas

Code that ran

3 of 9 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; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 6 no recorded run), measured 2026-11-23; 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/2601.20326.json · badge: /api/ran/2601.20326.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
cmd2001/ICLR2026_KV-Embedding canonical (classifier label)
classifier basis: census
3 ran · 6 no recorded run
FunctionStatusWhere it lives
get_kv_cache Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cmd2001/ICLR2026_KV-Embedding/KVClassifier/eval_kv_classsfier_classification.py
code served (permissive licence) · get_code("00d32e9533569aeb")
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 DynamicCache. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 torch
import torch.nn as nn
from transformers import DynamicCache

torch.manual_seed(0)

# Mock tokenizer that implements the interface needed by get_kv_cache
class MockTokenizer:
    def __call__(self, prompts, return_tensors=None, truncation=None, padding=None, max_length=None):
        batch_size = len(prompts) if isinstance(prompts, list) else 1
        seq_len = max_length if max_length else 64
        result = {
            'input_ids': torch.randint(0, 1000, (batch_size, seq_len))
        }
        if return_tensors == 'pt':
            result = type('obj', (object,), {'input_ids': result['input_ids']})()
        return result

# Mock model that implements the interface needed by get_kv_cache
class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.hidden_size = 64
        self.num_hidden_layers = 2
        
    def generate(self, input_ids, past_key_values=None, use_cache=None, max_new_tokens=None):
        # Minimal implementation: just return some generated tokens
        # The function only cares that this executes without error
        batch_size = input_ids.shape[0]
        return torch.randint(0, 1000, (batch_size, 1))

# Create instances
prompts = ["Hello world", "How are you"]
model = MockModel()
tokenizer = MockTokenizer()

ARGS = {
    'prompts': prompts,
    'model': model,
    'tokenizer': tokenizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DynamicCache — a DynamicCache output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DynamicCache output the recorded ndim 1 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
load_generation_results Ran
ran; our contract draft was wrong, not the code
cmd2001/ICLR2026_KV-Embedding/KVClassifier/parse_kv_classfier_results_classification.py
code served (permissive licence) · get_code("e3f9d49158bd33bc")
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 json
import tempfile
import os

# Create a temporary file with sample generation results
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.jsonl')
temp_path = temp_file.name

# Write sample data in the first format
sample_data_1 = {
    'output_fast_think': 'fast thinking output 1',
    'output_slow_think': 'slow thinking output 1',
    'output_fast_think_tokens': [1, 2, 3, 4],
    'output_slow_think_tokens': [5, 6, 7, 8]
}

# Write sample data in the second format
sample_data_2 = {
    'fast_think_output': 'fast thinking output 2',
    'slow_think_output': 'slow thinking output 2',
    'fast_think_output_tokens': [9, 10, 11],
    'slow_think_output_tokens': [12, 13, 14]
}

temp_file.write(json.dumps(sample_data_1) + '\n')
temp_file.write(json.dumps(sample_data_2) + '\n')
temp_file.close()

ARGS = {
    'generation_result_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
parse_prompts Ran
ran; our contract draft was wrong, not the code
cmd2001/ICLR2026_KV-Embedding/KVClassifier/train_kv_classifier.py
code served (permissive licence) · get_code("c7e9a39b3eb34571")
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 list, 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 torch

torch.manual_seed(0)

def parse_prompts(prompts):
    ret = []
    for prompt in prompts:
        prompt_think = '<|im_start|>user\nYou are a math problem solver. For the following question, solve it using your thinking ability.\nHere is the question:\n{}\n<|im_end|>\n<|im_start|>assistant\n'.format(prompt)
        if 'DeepSeek' in model_name:
            prompt_think = '|User|>\nYou are a math problem solver. For the following question, solve it using your thinking ability.\nHere is the question:\n{}\n|Assistant|\n'.format(prompt)
        ret.append(prompt_think)
    return ret

model_name = 'Qwen/Qwen3-32B'

prompts_input = [
    "What is 2 + 2?",
    "Solve for x: 3x + 5 = 14"
]

ARGS = {
    'prompts': prompts_input
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
prep_kv_cache Not yet run
unverified (harvested, no recorded run)
cmd2001/ICLR2026_KV-Embedding/KVClassifier/eval_kv_classsfier_classification.py
code served (permissive licence) · get_code("f83e3b3a36ac05b0")
How it ran

no invocation recorded.

prep_kv_cache Not yet run
unverified (harvested, no recorded run)
cmd2001/ICLR2026_KV-Embedding/KVClassifier/train_kv_classifier.py
code served (permissive licence) · get_code("d5bfc57658f9cc08")
How it ran

no invocation recorded.

run_prompt Not yet run
unverified (harvested, no recorded run)
cmd2001/ICLR2026_KV-Embedding/KVClassifier/eval_kv_classifier_generative.py
code served (permissive licence) · get_code("f38ac32ce1f38813")
How it ran

no invocation recorded.

run_prompt Not yet run
unverified (harvested, no recorded run)
cmd2001/ICLR2026_KV-Embedding/KVClassifier/prep_fast_slow_thinking_results.py
code served (permissive licence) · get_code("06e6484deafdc09c")
How it ran

no invocation recorded.

select_kv_cache Not yet run
unverified (harvested, no recorded run)
cmd2001/ICLR2026_KV-Embedding/KVClassifier/eval_kv_classifier_generative.py
code served (permissive licence) · get_code("5935de2fbe5c8164")
How it ran

no invocation recorded.

select_kv_cache_multi_pos Not yet run
unverified (harvested, no recorded run)
cmd2001/ICLR2026_KV-Embedding/KVClassifier/eval_kv_classifier_generative.py
code served (permissive licence) · get_code("43aa3af0e1419907")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 9 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.

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-23.

Repositories linked to this paper

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

Abstract

KV caches, typically used only to speed up autoregressive decoding, encode contextual information that can be reused for downstream tasks at no extra cost. We propose treating the KV cache as a lightweight representation, eliminating the need to recompute or store full hidden states. Despite being weaker than dedicated embeddings, KV-derived representations are shown to be sufficient for two key applications: (i) Chain-of-Embedding, where they achieve competitive or superior performance on Llama-3.1-8B-Instruct and Qwen2-7B-Instruct; and (ii) Fast/Slow Thinking Switching, where they enable adaptive reasoning on Qwen3-8B and DeepSeek-R1-Distil-Qwen-14B, reducing token generation by up to 5.7× with minimal accuracy loss. Our findings establish KV caches as a free, effective substrate for sampling and reasoning, opening new directions for representation reuse in LLM inference. Our code is available at https://github.com/cmd2001/ICLR2026_KV-Embedding.

For agents

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

get_harvested_code_for_paper("2601.20326")
get_code_for_paper("2601.20326")
have("2601.20326")

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

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

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

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

Connect an agent — have() is free.