SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.18668 · 2024

Simple linear attention language models balance the recall-throughput tradeoff

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 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; 10 failures of our instrument; 0 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/2402.18668.json · badge: /api/ran/2402.18668.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
hazyresearch/zoology canonical (classifier label)
classifier basis: census
9 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
compute_ce_with_embeddings Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/metrics.py
code served (permissive licence) · get_code("a65bb41664db0e54")
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.functional as F

torch.manual_seed(0)

# Create tiny tensors with distinct dimensions
# outputs: (batch_size=2, embedding_dim=4)
outputs = torch.randn(2, 4)

# true_indices: (batch_size=2,) with class indices
true_indices = torch.tensor([0, 1])

# value_embeddings: (num_classes=3, embedding_dim=4)
# Must have embedding_dim matching outputs' second dimension
value_embeddings = torch.randn(3, 4)

ARGS = {
    "outputs": outputs,
    "true_indices": true_indices,
    "value_embeddings": value_embeddings,
}
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
compute_mse Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/metrics.py
code served (permissive licence) · get_code("262da45c48c24f7b")
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 torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors for outputs and targets
# Using shape (2, 4) for batch_size=2, feature_dim=4
outputs = torch.randn(2, 4)
targets = torch.randn(2, 4)

ARGS = {
    "outputs": outputs,
    "targets": targets,
}
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, 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
elu_p1 Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/mixers/delta_net.py
code served (permissive licence) · get_code("bc4bddefd7540078")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 4) 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

torch.manual_seed(0)

x = torch.randn(2, 4)

ARGS = {
    'x': x
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
fetch_wandb_runs Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/analysis/utils.py
code served (permissive licence) · get_code("b65e20a414f96742")
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 DataFrame. 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 wandb
import pandas as pd
from unittest.mock import Mock, MagicMock
from typing import List

# Create mock wandb API and runs
class MockUser:
    def __init__(self):
        self.name = "test_user"

class MockRun:
    def __init__(self, run_id, name, project, config, summary):
        self.id = run_id
        self.name = name
        self.project = project
        self.user = MockUser()
        self.state = "finished"
        self.config = config
        self.summary = summary

# Mock the wandb.Api class
def mock_runs(project_name, filters=None):
    run1_config = {
        "learning_rate": 0.001,
        "batch_size": 32,
        "model": {
            "layers": 3,
            "hidden_dim": 128
        }
    }
    run1_summary = {
        "accuracy": 0.95,
        "loss": 0.05,
        "metrics": {
            "precision": 0.93,
            "recall": 0.94
        }
    }
    
    run2_config = {
        "learning_rate": 0.0001,
        "batch_size": 64,
        "model": {
            "layers": 4,
            "hidden_dim": 256
        }
    }
    run2_summary = {
        "accuracy": 0.97,
        "loss": 0.03,
        "metrics": {
            "precision": 0.96,
            "recall": 0.97
        }
    }
    
    return [
        MockRun("run_1", "exp_1", project_name, run1_config, run1_summary),
        MockRun("run_2", "exp_2", project_name, run2_config, run2_summary)
    ]

# Patch wandb.Api
original_api = wandb.Api
wandb.Api = Mock(return_value=Mock(runs=mock_runs))

ARGS = {
    "project_name": "test_project",
    "filters": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, wandb — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
flatten Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/utils.py
code served (permissive licence) · get_code("e66720e1309bfffc")
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.

torch = None  # Not needed for this function

ARGS = {
    'data': {
        'a': 1,
        'b': {
            'c': 2,
            'd': {
                'e': 3
            }
        },
        'f': [4, 5]
    },
    'parent_key': None,
    'sep': '.'
}
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
import_from_str Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/utils.py
code served (permissive licence) · get_code("24282d4941c8fc1f")
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 type. 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)

# Test case 1: importing a built-in class
path1 = "torch.nn.Linear"

# Test case 2: importing a built-in function
path2 = "torch.sum"

# Test case 3: importing from a standard library
path3 = "os.path.exists"

# Use the first test case as the main argument
ARGS = {
    "path": path1
}
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 type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type 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
sliding_window_additions Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from hazyresearch/based
pointer only · get_code("5b9fbe85e112d9c2")
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.

sum_norm Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/mixers/delta_net.py
code served (permissive licence) · get_code("e544fdb6373b9f42")
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 2, dtype family float, shape (2, 4) 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

torch.manual_seed(0)

# Create a small tensor with shape (2, 4)
# The function divides by sum along the last dimension (-1)
x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
unflatten Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/utils.py
code served (permissive licence) · get_code("fa6e454f96200975")
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 numpy as np

# Create a flat dictionary with '.' separated keys
d = {
    'model.layer1.weight': np.float32(0.5),
    'model.layer1.bias': np.float32(0.1),
    'model.layer2.weight': np.float32(0.3),
    'metadata.version': '1.0',
    'metadata.author': 'test',
    'list_data.0': 'first',
    'list_data.1': 'second',
    'list_data.2': 'third',
    'nested.deep.value': np.float64(1.5),
    'nested.deep.nan_value': np.float64(np.nan),
}

ARGS = {
    'd': d
}
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 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
unflatten Ran
ran; our contract draft was wrong, not the code
hazyresearch/zoology/zoology/analysis/utils.py
code served (permissive licence) · get_code("50615df14da6c8bb")
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 numpy as np

# Construct a flat dictionary with '.' separated keys
# The function will unflatten this and convert numeric keys to lists
flat_dict = {
    'model.layer.0': 1.5,
    'model.layer.1': 2.5,
    'model.layer.2': 3.5,
    'config.name': 'test_config',
    'config.learning_rate': 0.001,
    'data.train.0': 100,
    'data.train.1': 200,
    'data.train.2': 300,
    'metadata': 'some_value',
    'sparse_value': np.nan,  # This should be skipped
}

ARGS = {
    'd': flat_dict,
}
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 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

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 4 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 1 the same month, 2 later) and 5 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
elu_p1 4 other papers
4 later
2406.06484 (2024-06)
Parallelizing Linear Transformers with the Delta Rule over Sequence Length
2502.10297 (2025-02)
DeltaProduct: Improving State-Tracking in Linear RNNs via Householder Products
2503.02130 (2025-03)
Forgetting Transformer: Softmax Attention with a Forget Gate
and 1 more not named here
sum_norm 3 other papers
3 later
2502.10297 (2025-02)
DeltaProduct: Improving State-Tracking in Linear RNNs via Householder Products
2503.02130 (2025-03)
Forgetting Transformer: Softmax Attention with a Forget Gate
2603.28743 (2026-03)
Rethinking Language Model Scaling under Transferable Hypersphere Optimization
import_from_str 1 other paper
1 the same month
2402.10644 (2024-02)
Linear Transformers with Learnable Kernel Functions are Better In-Context Models
sliding_window_additions 1 other paper
1 dated earlier
2312.04927 (2023-12)
Zoology: Measuring and Improving Recall in Efficient Language Models

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

Recent work has shown that attention-based language models excel at recall, the ability to ground generations in tokens previously seen in context. However, the efficiency of attention-based models is bottle-necked during inference by the KV-cache's aggressive memory consumption. In this work, we explore whether we can improve language model efficiency (e.g. by reducing memory consumption) without compromising on recall. By applying experiments and theory to a broad set of architectures, we identify a key tradeoff between a model's state size and recall ability. We show that efficient alternatives to attention (e.g. H3, Mamba, RWKV) maintain a fixed-size recurrent state, but struggle at recall. We propose BASED a simple architecture combining linear and sliding window attention. By varying BASED window size and linear attention feature dimension, we can dial the state size and traverse the pareto frontier of the recall-memory tradeoff curve, recovering the full quality of attention on one end and the small state size of attention-alternatives on the other. We train language models up to 1.3b parameters and show that BASED matches the strongest sub-quadratic models (e.g. Mamba) in perplexity and outperforms them on real-world recall-intensive tasks by 6.22 accuracy points. Implementations of linear attention are often less efficient than optimized standard attention implementations. To make BASED competitive, we develop IO-aware algorithms that enable 24x higher throughput on language generation than FlashAttention-2, when generating 1024 tokens using 1.3b parameter models. Code for this work is provided at: https://github.com/HazyResearch/based.

For agents

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

get_harvested_code_for_paper("2402.18668")
get_code_for_paper("2402.18668")
have("2402.18668")

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

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

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

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

Connect an agent — have() is free.