SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.08252 · 2023

REST: Retrieval-Based Speculative Decoding

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 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, 1 violated it and 0 have no contract verdict; 5 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2311.08252.json · badge: /api/ran/2311.08252.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
fasterdecoding/rest canonical (classifier label)
classifier basis: census
6 ran · 1 no recorded run
FunctionStatusWhere it lives
initialize_logits Ran
ran; our contract draft was wrong, not the code
fasterdecoding/rest/rest/model/utils.py
code served (permissive licence) · get_code("9fd8f39b4dc4957b")
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 Tensor, ndim 3, dtype family float, shape (2, 3, 8) 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 torch.nn as nn

torch.manual_seed(0)

class MockLLM(nn.Module):
    """Mock language model that returns outputs and logits."""
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 8)
    
    def forward(self, input_ids, past_key_values=None, output_orig=False):
        """
        Args:
            input_ids: tensor of shape (batch_size, seq_len)
            past_key_values: list of past tensors
            output_orig: whether to return outputs
        
        Returns:
            outputs: dummy tensor
            logits: tensor of logits
        """
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        
        # Create dummy outputs
        outputs = torch.randn(batch_size, seq_len, 4)
        
        # Create logits by passing through linear layer
        logits = self.linear(outputs)
        
        return outputs, logits

# Create mock model
model = MockLLM()

# Create input_ids tensor: (batch_size=2, seq_len=3)
input_ids = torch.randint(0, 100, (2, 3))

# Create past_key_values as a list of tensors
# Typical structure: list of tuples/tensors representing past hidden states
past_key_values = [
    torch.randn(2, 4, 3, 5),  # past key
    torch.randn(2, 4, 3, 5),  # past value
]

ARGS = {
    "input_ids": input_ids,
    "model": model,
    "past_key_values": past_key_values,
}
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 Tensor, ndim 3, dtype family float, shape (2, 3, 8) — shape (2, 3, 8) 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
initialize_past_key_values Ran
ran; our contract draft was wrong, not the code
fasterdecoding/rest/rest/model/kv_cache.py
code served (permissive licence) · get_code("3965aca677b30513")
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 torch.nn as nn

torch.manual_seed(0)

class MockConfig:
    def __init__(self):
        self.num_hidden_layers = 2
        self.num_attention_heads = 3
        self.max_position_embeddings = 4
        self.hidden_size = 12

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MockConfig()
        self.device = 'cpu'
        self.dtype = torch.float32

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 — 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
pad_path Ran
ran, violated the contract we drafted
fasterdecoding/rest/rest/model/utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from hkr04/RACER, is pointer only (licence: NONE) · get_code("a0751eee3897a746")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from hkr04/RACER, and GitHub detected no licence in that repository when it was checked. 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.

repeat_kv Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
fasterdecoding/rest/rest/model/modeling_llama_kv.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from SAI-Lab-NYU/DREAM-S, is pointer only (licence: NONE) · get_code("f6e0c0fc3868b787")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from SAI-Lab-NYU/DREAM-S, and GitHub detected no licence in that repository when it was checked. 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.

reset_past_key_values Ran
ran; our contract draft was wrong, not the code
fasterdecoding/rest/rest/model/utils.py
code served (permissive licence) · get_code("14f39e471f7c9e90")
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 2, 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
import torch.nn as nn

torch.manual_seed(0)

class MockKeyValueTensor:
    """Mock tensor with a current_length attribute that can be filled."""
    def __init__(self, shape):
        self.data = torch.randn(shape)
        self.current_length = torch.tensor([5])  # Initialize with non-zero value
    
    def fill_(self, value):
        """Fill current_length with a value."""
        self.current_length.fill_(value)
        return self

# Construct passed_key_values: list of layers, each containing [key_tensor, value_tensor]
passed_key_values = []

# Create 3 layers, each with 2 tensors (key and value)
for layer_idx in range(3):
    layer_kv = []
    for kv_idx in range(2):
        # Create mock tensors with current_length attribute
        mock_tensor = MockKeyValueTensor(shape=(2, 4, 8))  # batch=2, heads=4, seq_len=8
        layer_kv.append(mock_tensor)
    passed_key_values.append(layer_kv)

ARGS = {
    "passed_key_values": passed_key_values
}
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 2, 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
rotate_half Ran
ran; our contract draft was wrong, not the code
fasterdecoding/rest/rest/model/modeling_llama_kv.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from SAI-Lab-NYU/DREAM-S, is pointer only (licence: NONE) · get_code("b71b0ed70aa2939c")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from SAI-Lab-NYU/DREAM-S, and GitHub detected no licence in that repository when it was checked. 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.

apply_rotary_pos_emb Not yet run
unverified (harvested, no recorded run)
fasterdecoding/rest/rest/model/modeling_llama_kv.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from SAI-Lab-NYU/DREAM-S, is pointer only (licence: NONE) · get_code("bad260f6d71db00c")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from SAI-Lab-NYU/DREAM-S, and GitHub detected no licence in that repository when it was checked. 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. No invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 7 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 3 the same month, 7 later) and 0 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
rotate_half 360 other papers
39 dated earlier, 7 the same month, 311 later, 3 undated · 30 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
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 357 more not named here
repeat_kv 243 other papers
15 dated earlier, 3 the same month, 223 later, 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
apply_rotary_pos_emb 83 other papers
9 dated earlier, 3 the same month, 71 later · 6 only as an assembly brick
2306.15595 (2023-06)
Extending Context Window of Large Language Models via Positional Interpolation
2307.05695 (2023-07)
ReLoRA: High-Rank Training Through Low-Rank Updates
2307.06945 (2023-07)
In-context Autoencoder for Context Compression in a Large Language Model
and 80 more not named here
pad_path 5 other papers
5 later
2024.naacl-long.88 (2024 (year only))
REST: Retrieval-Based Speculative Decoding
2402.05109 (2024-02)
Hydra: Sequentially-Dependent Draft Heads for Medusa Decoding
2508.16201 (2025-08)
SPECVLM: Enhancing Speculative Decoding of Video LLMs via Verifier-Guided Token Pruning
and 2 more not named here
initialize_logits 1 other paper
1 later
2024.naacl-long.88 (2024 (year only))
REST: Retrieval-Based Speculative Decoding
initialize_past_key_values 1 other paper
1 later
2024.naacl-long.88 (2024 (year only))
REST: Retrieval-Based Speculative Decoding
reset_past_key_values 1 other paper
1 later
2024.naacl-long.88 (2024 (year only))
REST: Retrieval-Based Speculative Decoding

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

We introduce Retrieval-Based Speculative Decoding (REST), a novel algorithm designed to speed up language model generation. The key insight driving the development of REST is the observation that the process of text generation often includes certain common phases and patterns. Unlike previous methods that rely on a draft language model for speculative decoding, REST harnesses the power of retrieval to generate draft tokens. This method draws from the reservoir of existing knowledge, retrieving and employing relevant tokens based on the current context. Its plug-and-play nature allows for seamless integration and acceleration of any language models, all without necessitating additional training. When benchmarked on 7B and 13B language models in a single-batch setting, REST achieves a significant speedup of 1.62X to 2.36X on code or text generation. The code of REST is available at https://github.com/FasterDecoding/REST.

For agents

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

get_harvested_code_for_paper("2311.08252")
get_code_for_paper("2311.08252")
have("2311.08252")

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

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

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

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

Connect an agent — have() is free.