SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2506.08373 · ICLR · 2025

Draft-based Approximate Inference for LLMs

Kangwook Lee, Minjae Lee, Kevin Galim, Wonjun Kang, Ethan Ewer, Hyung Koo, Furiosaai

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 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 3 have no contract verdict; 5 failures of our instrument; 3 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2506.08373.json · badge: /api/ran/2506.08373.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
furiosa-ai/draft-based-approx-llm canonical (classifier label)
classifier basis not recorded on the link
3 ran · 3 no recorded run
copy not recorded community
not in the paper's declared repositories
5 ran · 0 no recorded run
FunctionStatusWhere it lives
repeat_kv Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
this paper's copy was not recorded; identical code first harvested from Time-MoE/Time-MoE
pointer only · get_code("3c76e52815c5401d")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

build_chat Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from zefan-cai/kvcache-factory
pointer only · get_code("3ddd62fbad41e698")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

build_chat_llama3 Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from zefan-cai/kvcache-factory
pointer only · get_code("a06d17c88eb31b3d")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

compress_kv Ran
ran on a synthesized input
furiosa-ai/draft-based-approx-llm/draft_approx_llm/speckv/util.py
code served (permissive licence) · get_code("d40a43c3d846d891")
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 torch
import math

torch.manual_seed(0)

# Parameters for compress_kv function
batch_size = 2
num_key_value_heads = 2
num_query_heads = 4
seq_len = 16
head_dim = 4
window_size = 4
max_capacity_prompt = 12
prefill_vertical_size = 6
reduction_type = 'mean'
pool_type = 'mean'
kernel_size = 3

# Create tensors
# query_states: (batch, num_query_heads, seq_len, head_dim)
query_states = torch.randn(batch_size, num_query_heads, seq_len, head_dim)

# key_states: (batch, num_key_value_heads, seq_len, head_dim)
key_states = torch.randn(batch_size, num_key_value_heads, seq_len, head_dim)

# value_states: (batch, num_key_value_heads, seq_len, head_dim)
value_states = torch.randn(batch_size, num_key_value_heads, seq_len, head_dim)

ARGS = {
    'key_states': key_states,
    'query_states': query_states,
    'value_states': value_states,
    'window_size': window_size,
    'max_capacity_prompt': max_capacity_prompt,
    'prefill_vertical_size': prefill_vertical_size,
    'reduction_type': reduction_type,
    'pool_type': pool_type,
    'kernel_size': kernel_size,
}
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 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
key_pruner_query_driven Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
this paper's copy was not recorded; identical code first harvested from zefan-cai/kvcache-factory
pointer only · get_code("3597e5670a759378")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

maybe_repeat_kv_before_cache Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
this paper's copy was not recorded; identical code first harvested from zefan-cai/kvcache-factory
pointer only · get_code("6211e835b472f7ad")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

patch_model Ran
ran on a synthesized input
furiosa-ai/draft-based-approx-llm/draft_approx_llm/draft_approx_llm.py
code served (permissive licence) · get_code("edb10589c3297b21")
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 MinimalModel. 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 torch
import torch.nn as nn

torch.manual_seed(0)

# Create minimal model classes
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(x)

class MinimalDraftModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(x)

# Create minimal config class
class MinimalConfig:
    def __init__(self, sparse_type):
        self.sparse_type = sparse_type

# Mock patch functions to avoid import errors
def mock_speckv_patch_model(model, draft_model, config):
    return model

def mock_specpc_patch_model(model, draft_model, config):
    return model

def mock_speckvpc_patch_model(model, draft_model, config):
    return model

# Monkey-patch the imports
import sys
from types import ModuleType

specpc_module = ModuleType('specpc')
specpc_module.specpc_patch_model = mock_specpc_patch_model
sys.modules['draft_approx_llm.specpc.specpc'] = specpc_module

speckv_module = ModuleType('speckv')
speckv_module.speckv_patch_model = mock_speckv_patch_model
sys.modules['draft_approx_llm.speckv.speckv'] = speckv_module

speckvpc_module = ModuleType('speckvpc')
speckvpc_module.speckvpc_patch_model = mock_speckvpc_patch_model
sys.modules['draft_approx_llm.speckvpc.speckvpc'] = speckvpc_module

parent_module = ModuleType('draft_approx_llm')
sys.modules['draft_approx_llm'] = parent_module

specpc_parent = ModuleType('draft_approx_llm.specpc')
sys.modules['draft_approx_llm.specpc'] = specpc_parent

speckv_parent = ModuleType('draft_approx_llm.speckv')
sys.modules['draft_approx_llm.speckv'] = speckv_parent

speckvpc_parent = ModuleType('draft_approx_llm.speckvpc')
sys.modules['draft_approx_llm.speckvpc'] = speckvpc_parent

# Create instances
model = MinimalModel()
draft_model = MinimalDraftModel()
config = MinimalConfig(sparse_type='speckv')

ARGS = {
    'model': model,
    'draft_model': draft_model,
    'config': config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
draft_approx_llm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MinimalModel — a MinimalModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MinimalModel 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
update_llama_model_for_speckv Ran
ran on a synthesized input
furiosa-ai/draft-based-approx-llm/draft_approx_llm/speckv/llama_util.py
code served (permissive licence) · get_code("b547ebd6d3a3089d")
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 MockModel. 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 torch
import torch.nn as nn
from transformers.cache_utils import Cache

torch.manual_seed(0)

class MockConfig:
    def __init__(self):
        self.max_capacity_prompt = None
        self.window_size = 64
        self.prefill_vertical_size = 32
        self.reduction_type = "mean"
        self.pool_type = "mean"
        self.kernel_size = 4
        self.prefill_window_size = 16
        self._attn_implementation = "eager"

class MockAttention(nn.Module):
    def __init__(self):
        super().__init__()
        self.hidden_size = 64
        self.num_heads = 4
        self.head_dim = 16
        self.q_proj = nn.Linear(64, 64)
        self.k_proj = nn.Linear(64, 64)
        self.v_proj = nn.Linear(64, 64)
        self.o_proj = nn.Linear(64, 64)
        self.attention_dropout = 0.1
        self.scaling = self.head_dim ** -0.5
        self.config = MockConfig()
        self.layer_idx = 0
        self.training = False
    
    def forward(self, hidden_states, position_embeddings, attention_mask, past_key_value=None, cache_position=None, **kwargs):
        batch_size, seq_len, hidden_dim = hidden_states.shape
        output = torch.zeros_like(hidden_states)
        return (output, None)

class MockLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.self_attn = MockAttention()

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.model = nn.Module()
        self.model.layers = nn.ModuleList([MockLayer() for _ in range(2)])

model = MockModel()

ARGS = {
    "model": model,
}
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 MockModel — a MockModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockModel 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
generate_aggregated_attention Not yet run
unverified (harvested, no recorded run)
furiosa-ai/draft-based-approx-llm/draft_approx_llm/specpc/specpc_utils.py
code served (permissive licence) · get_code("2b96d4ca67c65e40")
How it ran

no invocation recorded.

reset_llama_model Not yet run
unverified (harvested, no recorded run)
furiosa-ai/draft-based-approx-llm/draft_approx_llm/speckv/llama_util.py
code served (permissive licence) · get_code("864ba42e7bb2bd2e")
How it ran

no invocation recorded.

vertical_slash_sparse_attention_forward Not yet run
unverified (harvested, no recorded run)
furiosa-ai/draft-based-approx-llm/draft_approx_llm/speckv/util.py
code served (permissive licence) · get_code("3dfaf65cb0227004")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 1 the same month, 1 later) and 6 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
repeat_kv 243 other papers
192 dated earlier, 5 the same month, 40 later, 4 same year, order not determinable, 2 undated · 22 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2305.17888 (2023-05)
LLM-QAT: Data-Free Quantization Aware Training for Large Language Models
and 240 more not named here
build_chat 3 other papers
2 dated earlier, 1 same year, order not determinable
2410.19258 (2024-10)
Not All Heads Matter: A Head-Level KV Cache Compression Method with Integrated Retrieval and Reasoning
2025.findings-emnlp.429 (2025 (year only))
More Tokens, Lower Precision: Towards the Optimal Token-Precision Trade-off in KV Cache Compression
2505.23416 (2025-05)
KVzip: Query-Agnostic KV Cache Compression with Context Reconstruction
key_pruner_query_driven 2 other papers
2 dated earlier
2406.02069 (2024-06)
PyramidKV: Dynamic KV Cache Compression based on Pyramidal Information Funneling
2505.23416 (2025-05)
KVzip: Query-Agnostic KV Cache Compression with Context Reconstruction
maybe_repeat_kv_before_cache 2 other papers
2 dated earlier
2406.02069 (2024-06)
PyramidKV: Dynamic KV Cache Compression based on Pyramidal Information Funneling
2505.23416 (2025-05)
KVzip: Query-Agnostic KV Cache Compression with Context Reconstruction
build_chat_llama3 1 other paper
1 dated earlier
2505.23416 (2025-05)
KVzip: Query-Agnostic KV Cache Compression with Context Reconstruction

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

Optimizing inference for long-context large language models (LLMs) is increasingly important due to the quadratic compute and linear memory cost of Transformers. Existing approximate inference methods, including key-value (KV) cache dropping, sparse attention, and prompt compression, typically rely on coarse predictions of token or KV pair importance. We unify and extend recent work by introducing a framework for approximate LLM inference that leverages small draft models to more accurately predict token and KV pair importance. We provide novel theoretical and empirical analyses justifying lookahead-based importance estimation techniques. Within this framework, we present: (i) SpecKV, the first method to use lookahead with a small draft model to enable precise KV cache dropping; (ii) SpecPC, which leverages draft model attention activations to identify and discard less important prompt tokens; and (iii) SpecKV-PC, a cascaded compression strategy combining both techniques. Extensive experiments on long-context benchmarks demonstrate that our methods consistently achieve higher accuracy than existing baselines while retaining the same efficiency gains in memory usage, latency, and throughput.

For agents

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

get_harvested_code_for_paper("2506.08373")
get_code_for_paper("2506.08373")
have("2506.08373")

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

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

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

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

Connect an agent — have() is free.