SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2302.02451 · 2023

KDEformer: Accelerating Transformers via Kernel Density Estimation

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; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 7 failures of our instrument; 4 no recorded run), measured 2026-11-21; 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/2302.02451.json · badge: /api/ran/2302.02451.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
majid-daliri/kdeformer canonical (classifier label)
classifier basis not recorded on the link
8 ran · 4 no recorded run
FunctionStatusWhere it lives
batched_index_select Ran
ran; our contract draft was wrong, not the code
majid-daliri/kdeformer/Reformer.py
code served (permissive licence) · get_code("8429e6520e353d4d")
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, 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)

# Construct arguments for batched_index_select
# The function expects:
# - values: a tensor with shape (batch, seq_len, features)
# - indices: a tensor with shape (batch, num_indices) containing indices to select from seq_len dimension

batch_size = 2
seq_len = 5
feature_dim = 4
num_indices = 3

# values tensor: shape (batch_size, seq_len, feature_dim)
values = torch.randn(batch_size, seq_len, feature_dim)

# indices tensor: shape (batch_size, num_indices) with valid indices in range [0, seq_len)
indices = torch.tensor([[0, 2, 4], [1, 3, 2]], dtype=torch.long)

ARGS = {
    "values": values,
    "indices": indices,
}
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, 4) — shape (2, 3, 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
chunked_sum Ran
ran; our contract draft was wrong, not the code
majid-daliri/kdeformer/Reformer.py
code served (permissive licence) · get_code("0af97909186cbf48")
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 1, dtype family float, shape (2,) 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)
# This will test the basic functionality
tensor = torch.randn(2, 4)

# chunks parameter - number of chunks to split the tensor into
chunks = 2

ARGS = {
    "tensor": tensor,
    "chunks": chunks,
}
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 1, dtype family float, shape (2,) — shape (2,) 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
sn_embedding Ran
ran; our contract draft was wrong, not the code
majid-daliri/kdeformer/biggan_models/model_kdeformer.py
code served (permissive licence) · get_code("abed13633552f3d0")
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 Embedding. 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)

# The function sn_embedding takes eps and **kwargs
# The **kwargs are passed to nn.Embedding
# nn.Embedding requires num_embeddings and embedding_dim at minimum

ARGS = {
    'eps': 1e-12,
    'num_embeddings': 10,
    'embedding_dim': 4
}
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 Embedding — a Embedding output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Embedding 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
snconv2d Ran
ran; our contract draft was wrong, not the code
majid-daliri/kdeformer/biggan_models/model_kdeformer.py
code served (permissive licence) · get_code("b76bf7615e32c07d")
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 Conv2d. 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)

# snconv2d creates a spectral normalized Conv2d
# We need to provide kwargs for nn.Conv2d and eps for spectral_norm

# nn.Conv2d required parameters: in_channels, out_channels, kernel_size
# Common optional parameters: stride, padding, dilation, groups, bias, padding_mode

ARGS = {
    'eps': 1e-12,
    'in_channels': 3,
    'out_channels': 5,
    'kernel_size': 3,
    'stride': 1,
    'padding': 1,
    'bias': True
}
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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
snlinear Ran
ran; our contract draft was wrong, not the code
majid-daliri/kdeformer/biggan_models/model_kdeformer.py
code served (permissive licence) · get_code("de3577618251b913")
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 Linear. 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)

# The function snlinear takes eps and **kwargs
# The **kwargs are passed to nn.Linear
# nn.Linear requires at minimum: in_features and out_features
# Optional parameters include: bias (default True), device, dtype

ARGS = {
    'eps': 1e-12,
    'in_features': 4,
    'out_features': 3,
    'bias': True
}
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 Linear — a Linear output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Linear 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
sort_key_val Ran
ran; our contract draft was wrong, not the code
majid-daliri/kdeformer/Reformer.py
code served (permissive licence) · get_code("8b42f84b228597d9")
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 3, 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)

# The function sorts t1 along a dimension and gathers t2 according to the sort indices
# t1 needs to be a tensor that supports .sort() method
# t2 needs to be a tensor that supports .expand_as() and .gather() methods
# Both should be sortable tensors with numeric values

t1 = torch.randn(2, 4)
t2 = torch.randn(2, 1)

ARGS = {
    "t1": t1,
    "t2": t2,
    "dim": -1
}
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 3, 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
unit_hamming_distance_array Ran
ran on a synthesized input
majid-daliri/kdeformer/KDEformer.py
code served (permissive licence) · get_code("4a96fc2b81429b4e")
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 1, dtype family int, shape (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

torch.manual_seed(0)

ARGS = {
    "size_n": 3
}
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 1, dtype family int, shape (8,) — shape (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
url_to_filename Ran
ran; our contract draft was wrong, not the code
majid-daliri/kdeformer/biggan_models/file_utils.py
code served (permissive licence) · get_code("5eff22fa0a651276")
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 str. 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.

from hashlib import sha256

ARGS = {
    "url": "https://example.com/model/checkpoint.bin",
    "etag": "abc123def456"
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
cached_path Not yet run
unverified (harvested, no recorded run)
majid-daliri/kdeformer/biggan_models/file_utils.py
code served (permissive licence) · get_code("9dba35ef1c6281eb")
How it ran

no invocation recorded.

filename_to_url Not yet run
unverified (harvested, no recorded run)
majid-daliri/kdeformer/biggan_models/file_utils.py
code served (permissive licence) · get_code("c5ba2abfbf6a9dfa")
How it ran

no invocation recorded.

power_method Not yet run
unverified (harvested, no recorded run)
majid-daliri/kdeformer/KDEformer.py
code served (permissive licence) · get_code("00be53f1a2a197a4")
How it ran

no invocation recorded.

power_method Not yet run
unverified (harvested, no recorded run)
majid-daliri/kdeformer/vit_models/kdeformer.py
code served (permissive licence) · get_code("a1a0332373feae9e")
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, 9 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 0 the same month, 5 later) and 3 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
url_to_filename 48 other papers
40 dated earlier, 8 later · 8 only as an assembly brick
1610.02424 (2016-10)
Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence Models
1809.11096 (2018-09)
Large Scale GAN Training for High Fidelity Natural Image Synthesis
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
and 45 more not named here
batched_index_select 5 other papers
3 dated earlier, 2 later · 1 only as an assembly brick
1804.04637 (2018-04)
EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
2205.08897 (2022-05)
FiLM: Frequency improved Legendre Memory Model for Long-term Time Series Forecasting
and 2 more not named here
snlinear 4 other papers
2 dated earlier, 2 later
2004.05675 (2020-04)
A Non-Parametric Test to Detect Data-Copying in Generative Models
2206.00048 (2022-06)
PandA: Unsupervised Learning of Parts and Appearances in the Feature Maps of GANs
2311.01323 (2023-11)
Towards Evaluating Transfer-based Attacks Systematically, Practically, and Fairly
and 1 more not named here
sort_key_val 3 other papers
2 dated earlier, 1 later
1804.04637 (2018-04)
EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models
2205.08897 (2022-05)
FiLM: Frequency improved Legendre Memory Model for Long-term Time Series Forecasting
2602.18473 (2026-02)
Decentralized Attention Fails Centralized Signals: Rethinking Transformers for Medical Time Series
cached_path 2 other papers
2 dated earlier
1809.11096 (2018-09)
Large Scale GAN Training for High Fidelity Natural Image Synthesis
2206.00048 (2022-06)
PandA: Unsupervised Learning of Parts and Appearances in the Feature Maps of GANs
filename_to_url 2 other papers
2 dated earlier
1809.11096 (2018-09)
Large Scale GAN Training for High Fidelity Natural Image Synthesis
2206.00048 (2022-06)
PandA: Unsupervised Learning of Parts and Appearances in the Feature Maps of GANs
sn_embedding 2 other papers
2 dated earlier
2004.05675 (2020-04)
A Non-Parametric Test to Detect Data-Copying in Generative Models
2206.00048 (2022-06)
PandA: Unsupervised Learning of Parts and Appearances in the Feature Maps of GANs
snconv2d 2 other papers
2 dated earlier
2004.05675 (2020-04)
A Non-Parametric Test to Detect Data-Copying in Generative Models
2206.00048 (2022-06)
PandA: Unsupervised Learning of Parts and Appearances in the Feature Maps of GANs
chunked_sum 1 other paper
1 later
2602.18473 (2026-02)
Decentralized Attention Fails Centralized Signals: Rethinking Transformers for Medical Time Series

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

Repositories linked to this paper

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

Abstract

Dot-product attention mechanism plays a crucial role in modern deep architectures (e.g., Transformer) for sequence modeling, however, naïve exact computation of this model incurs quadratic time and memory complexities in sequence length, hindering the training of long-sequence models. Critical bottlenecks are due to the computation of partition functions in the denominator of softmax function as well as the multiplication of the softmax matrix with the matrix of values. Our key observation is that the former can be reduced to a variant of the kernel density estimation (KDE) problem, and an efficient KDE solver can be further utilized to accelerate the latter via subsampling-based fast matrix products. Our proposed KDEformer can approximate the attention in sub-quadratic time with provable spectral norm bounds, while all prior results merely provide entry-wise error bounds. Empirically, we verify that KDEformer outperforms other attention approximations in terms of accuracy, memory, and runtime on various pre-trained models. On BigGAN image generation, we achieve better generative scores than the exact computation with over $4\times$ speedup. For ImageNet classification with T2T-ViT, KDEformer shows over $18\times$ speedup while the accuracy drop is less than $0.5\%$.

For agents

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

get_harvested_code_for_paper("2302.02451")
get_code_for_paper("2302.02451")
have("2302.02451")

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

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

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

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

Connect an agent — have() is free.