SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 00666 · ECCV · 2024

AttnZero: Efficient Attention Discovery for Vision Transformers

Yike Guo, Lujun Li, Wei Xue, Wenhan Luo, Qifeng Liu, Peijie Dong, Zimian Wei

Open in the Atlas

Code that ran

10 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; 3 honoured the contract we drafted, 1 violated it and 1 has no contract verdict; 5 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/00666.json · badge: /api/ran/00666.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
lliai/AttnZero canonical (classifier label)
classifier basis: census
10 ran · 2 no recorded run
FunctionStatusWhere it lives
auto_resume_helper Ran
ran; our contract draft was wrong, not the code
lliai/AttnZero/imagenet/utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("0c32459bef92ff8c")
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 leaplabthu/inline, 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.

build_optimizer Ran
ran; our contract draft was wrong, not the code
lliai/AttnZero/imagenet/optimizer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("fcf2d41dd445a70b")
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 leaplabthu/inline, 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.

build_scheduler Ran
ran; our contract draft was wrong, not the code
lliai/AttnZero/imagenet/lr_scheduler.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("07e8b4b487c0abb6")
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 leaplabthu/inline, 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.

check_keywords_in_name Ran
ran, violated the contract we drafted
lliai/AttnZero/imagenet/optimizer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("b0a5beb34716d5a6")
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 leaplabthu/inline, 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.

count_parameters Ran
ran, honoured the contract we drafted
lliai/AttnZero/imagenet/temp.py
code served (permissive licence) · get_code("f6b944f50d3f15ae")
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 int, ndim 0, dtype family int, shape () 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 SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model
}
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 int, ndim 0, dtype family int, shape () — shape () 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
create_logger Ran
ran; our contract draft was wrong, not the code
lliai/AttnZero/imagenet/logger.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("82e52feafbf040bb")
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 leaplabthu/inline, 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.

get_grad_norm Ran
ran, honoured the contract we drafted
lliai/AttnZero/imagenet/utils.py
code served (permissive licence) · get_code("eec1e7cba51d5e8e")
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 float, ndim 0, dtype family float, shape () 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)

# Create a simple model with parameters that have gradients
model = nn.Linear(4, 3)

# Forward pass to create some gradients
x = torch.randn(2, 4)
y = model(x)
loss = y.sum()
loss.backward()

# Now model.parameters() have gradients attached
parameters = list(model.parameters())

ARGS = {
    "parameters": parameters,
    "norm_type": 2
}
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 float, ndim 0, dtype family float, shape () — shape () 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
load_checkpoint Ran
ran, honoured the contract we drafted
lliai/AttnZero/imagenet/utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("7e0715dc48712749")
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 leaplabthu/inline, 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.

obtain_trial_acc Ran
ran on a synthesized input
lliai/AttnZero/attn-bench-101/prepare_gt.py
code served (permissive licence) · get_code("3d4146ac6e82becd")
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 float, ndim 0, dtype family float, shape () 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 json
import tempfile
import os

# Create a temporary file with valid JSON data matching the function's expectations
temp_dir = tempfile.mkdtemp()
save_path = os.path.join(temp_dir, "trial_result.txt")

# Create a file with the expected format
# The function expects the last line to have format: "prefix_here" + JSON data (skipping first 12 chars)
result_data = {
    'epoch': '300/300',
    'max_top1_acc': 0.95
}

with open(save_path, 'w') as f:
    # Write some prefix (12 characters will be skipped)
    f.write("prefix_here_" + json.dumps(result_data))

ARGS = {
    'save_path': save_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 float, ndim 0, dtype family float, shape () — shape () 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
set_weight_decay_and_lr Ran
ran; our contract draft was wrong, not the code
lliai/AttnZero/imagenet/optimizer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("104af48a94364f24")
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 leaplabthu/inline, 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.

get_config Not yet run
unverified (harvested, no recorded run)
lliai/AttnZero/imagenet/config.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("20681a9065c0a731")
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 leaplabthu/inline, 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.

load_checkpoint Not yet run
unverified (harvested, no recorded run)
lliai/AttnZero/imagenet/utils_ema.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("26a01685ebc8f358")
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 leaplabthu/inline, 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 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, 11 are also present in other papers whose code we hold (9 with at least one paper dated earlier, 0 the same month, 10 later) and 1 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
count_parameters 180 other papers
114 dated earlier, 24 later, 42 same year, order not determinable · 8 only as an assembly brick
1705.08415 (2017-05)
Supervised Community Detection with Line Graph Neural Networks
1707.01926 (2017-07)
Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting
1808.09367 (2018-08)
Deriving Machine Attention from Human Rationales
and 177 more not named here
get_config 51 other papers
25 dated earlier, 5 later, 21 same year, order not determinable
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
2106.03746 (2021-06)
Efficient Training of Visual Transformers with Small Datasets
and 48 more not named here
check_keywords_in_name 31 other papers
18 dated earlier, 3 later, 10 same year, order not determinable
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
2106.03746 (2021-06)
Efficient Training of Visual Transformers with Small Datasets
and 28 more not named here
get_grad_norm 23 other papers
10 dated earlier, 3 later, 10 same year, order not determinable
1910.13616 (2019-10)
Multimodal Model-Agnostic Meta-Learning via Task-Aware Modulation
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
and 20 more not named here
auto_resume_helper 20 other papers
11 dated earlier, 2 later, 7 same year, order not determinable
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
2106.04263 (2021-06)
On the Connection between Local Attention and Dynamic Depth-wise Convolution
and 17 more not named here
build_scheduler 13 other papers
5 dated earlier, 1 later, 7 same year, order not determinable
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2307.06947 (2023-07)
Video-FocalNets: Spatio-Temporal Focal Modulation for Video Action Recognition
2309.01430 (2023-09)
DAT++: Spatially Dynamic Vision Transformer with Deformable Attention
and 10 more not named here
create_logger 5 other papers
2 dated earlier, 1 later, 2 same year, order not determinable
2309.01430 (2023-09)
DAT++: Spatially Dynamic Vision Transformer with Deformable Attention
2312.08874 (2023-12)
Agent Attention: On the Integration of Softmax and Linear Attention
2405.11582 (2024-05)
SLAB: Efficient Transformers with Simplified Linear Attention and Progressive Re-parameterized Batch Normalization
and 2 more not named here
build_optimizer 4 other papers
2 dated earlier, 1 later, 1 same year, order not determinable
2309.01430 (2023-09)
DAT++: Spatially Dynamic Vision Transformer with Deformable Attention
2312.08874 (2023-12)
Agent Attention: On the Integration of Softmax and Linear Attention
2412.06590 (2024-12)
Bridging the Divide: Reconsidering Softmax and Linear Attention
and 1 more not named here
set_weight_decay_and_lr 4 other papers
2 dated earlier, 1 later, 1 same year, order not determinable
2309.01430 (2023-09)
DAT++: Spatially Dynamic Vision Transformer with Deformable Attention
2312.08874 (2023-12)
Agent Attention: On the Integration of Softmax and Linear Attention
2412.06590 (2024-12)
Bridging the Divide: Reconsidering Softmax and Linear Attention
and 1 more not named here
load_checkpoint 2 other papers
1 later, 1 same year, order not determinable
2412.06590 (2024-12)
Bridging the Divide: Reconsidering Softmax and Linear Attention
2506.08297 (2025-06)
SEMA: a Scalable and Efficient Mamba like Attention via Token Localization and Averaging
load_checkpoint 1 other paper
1 same year, order not determinable
2412.06590 (2024-12)
Bridging the Divide: Reconsidering Softmax and Linear Attention

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

In this paper, we present AttnZero, the first framework for automatically discovering efficient attention modules tailored for Vision Transformers (ViTs). While traditional self-attention in ViTs suffers from quadratic computation complexity, linear attention offers a more efficient alternative with linear complexity approximation. However, existing hand-crafted linear attention suffers from performance degradation. To address these issues, our AttnZero constructs search spaces and employs evolutionary algorithms to discover potential linear attention formulations. Specifically, our search space consists of six kinds of computation graphs and advanced activation, normalize, and binary operators. To enhance generality, we derive results of candidate attention applied to multiple advanced ViTs as the multi-objective for the evolutionary search. To expedite the search process, we utilize program checking and rejection protocols to filter out unpromising candidates swiftly. Additionally, we develop Attn-Bench-101, which provides precomputed performance of 2,000 attentions in the search spaces, enabling us to summarize attention design insights. Experimental results demonstrate that the discovered AttnZero module generalizes well to different tasks and consistently achieves improved performance across various ViTs. For instance, the tiny model of DeiT|PVT|Swin|CSwin trained with AttnZero on ImageNet reaches 74.9%|78.1%|82.1%|82.9% top-1 accuracy. Codes at: https://github.com/lliai/AttnZero.

For agents

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

get_harvested_code_for_paper("00666")
get_code_for_paper("00666")
have("00666")

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

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

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

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

Connect an agent — have() is free.