SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2101.11605 · CVPR · 2021

Bottleneck Transformers for Visual Recognition

U Berkeley, Pieter Abbeel, Aravind Srinivas, Tsung-Yi Lin, Jonathon Shlens, Ashish Vaswani, Niki Parmar

arXiv · PDF · Open in the Atlas

Code that ran

26 of 49 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (9 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 18 have no contract verdict; 7 failures of our instrument; 23 no recorded run), 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/2101.11605.json · badge: /api/ran/2101.11605.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
BIGBALLON/distribuuuu community
Papers with Code archive
7 ran · 0 no recorded run
The-AI-Summer/self_attention community
Papers with Code archive
6 ran · 1 no recorded run
lucidrains/bottleneck-transformer-pytorch community
Papers with Code archive
4 ran · 3 no recorded run
nachiket273/VisTrans community
Papers with Code archive
2 ran · 9 no recorded run
CandiceD17/Bottleneck-Transformers-for-Visual-Recognition community
Papers with Code archive
2 ran · 2 no recorded run
scheshmi/BottleneckTransformers community
Papers with Code archive
2 ran · 1 no recorded run
leaderj1001/BottleneckTransformers community
Papers with Code archive
2 ran · 0 no recorded run
MartinGer/Bottleneck-Transformers-for-Visual-Recognition community
Papers with Code archive
1 ran · 0 no recorded run
NZ99/bottleneck-transformer-flax community
Papers with Code archive
0 ran · 7 no recorded run
FunctionStatusWhere it lives
AbsPosEmb Ran
ran on a synthesized input · constructed an object; no result was computed
BIGBALLON/distribuuuu/distribuuuu/models/botnet.py
code served (permissive licence) · get_code("bf90d53646507d1c")
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 an instance of its own class, AbsPosEmb: the run constructed the object and did not call it, so no result was computed. 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
from torch import nn

torch.manual_seed(0)

# The AbsPosEmb class uses:
# - height: an integer dimension for the height parameter
# - width: an integer dimension for the width parameter
# - dim_head: an integer dimension for the head dimension

# From the forward method:
# - self.height is used in rearrange with shape (height, dim_head)
# - self.width is used in rearrange with shape (width, dim_head)
# - q is expected to have shape (batch, heads, sequence_length, dim_head)
#   and is used in einsum 'b h i d, j d -> b h i j'

# Creating distinct sizes for clarity
height = 5
width = 6
dim_head = 4

ARGS = {
    'height': height,
    'width': width,
    'dim_head': dim_head
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type AbsPosEmb — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AbsPosEmb 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
AbsPosEmb Ran
ran on a synthesized input
CandiceD17/Bottleneck-Transformers-for-Visual-Recognition/model/botnet.py
pointer only (licence: NONE) · get_code("abdfbeb02321716b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, CandiceD17/Bottleneck-Transformers-for-Visual-Recognition 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.

AbsPosEmb Ran
ran on a synthesized input
lucidrains/bottleneck-transformer-pytorch/bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
code served (permissive licence) · get_code("55cdbdffabd748b8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 2, 5, 12) 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
from torch import nn, einsum
from einops import rearrange

def pair(x):
    return (x, x) if not isinstance(x, tuple) else x

class AbsPosEmb(nn.Module):

    def __init__(self, fmap_size, dim_head):
        super().__init__()
        height, width = pair(fmap_size)
        scale = dim_head ** (-0.5)
        self.height = nn.Parameter(torch.randn(height, dim_head) * scale)
        self.width = nn.Parameter(torch.randn(width, dim_head) * scale)

    def forward(self, q):
        emb = rearrange(self.height, 'h d -> h () d') + rearrange(self.width, 'w d -> () w d')
        emb = rearrange(emb, ' h w d -> (h w) d')
        logits = einsum('b h i d, b h i j -> b h i j', q, emb)
        return logits

INIT_ARGS = {
    'fmap_size': (4, 3),
    'dim_head': 8,
}

ARGS = {
    'q': torch.randn(2, 2, 5, 8),
}

if __name__ == '__main__':
    model = AbsPosEmb(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 2, 5, 12) — shape (2, 2, 5, 12) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Attention Ran
ran on a synthesized input
lucidrains/bottleneck-transformer-pytorch/bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
code served (permissive licence) · get_code("1ee91139c3f9ceb2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 32, 4, 3) 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
from torch import nn, einsum
from einops import rearrange

def expand_dim(t, dim, k):
    t = t.unsqueeze(dim=dim)
    expand_shape = [-1] * len(t.shape)
    expand_shape[dim] = k
    return t.expand(*expand_shape)

def pair(x):
    return (x, x) if not isinstance(x, tuple) else x

def rel_to_abs(x):
    b, h, l, _, device, dtype = (*x.shape, x.device, x.dtype)
    dd = {'device': device, 'dtype': dtype}
    col_pad = torch.zeros((b, h, l, 1), **dd)
    x = torch.cat((x, col_pad), dim=3)
    flat_x = rearrange(x, 'b h l c -> b h (l c)')
    flat_pad = torch.zeros((b, h, l - 1), **dd)
    flat_x_padded = torch.cat((flat_x, flat_pad), dim=2)
    final_x = flat_x_padded.reshape(b, h, l + 1, 2 * l - 1)
    final_x = final_x[:, :, :l, l - 1:]
    return final_x

def relative_logits_1d(q, rel_k):
    b, heads, h, w, dim = q.shape
    logits = einsum('b h x y d, r d -> b h x y r', q, rel_k)
    logits = rearrange(logits, 'b h x y r -> b (h x) y r')
    logits = rel_to_abs(logits)
    logits = logits.reshape(b, heads, h, w, w)
    logits = expand_dim(logits, dim=3, k=h)
    return logits

class AbsPosEmb(nn.Module):

    def __init__(self, fmap_size, dim_head):
        super().__init__()
        height, width = pair(fmap_size)
        scale = dim_head ** (-0.5)
        self.height = nn.Parameter(torch.randn(height, dim_head) * scale)
        self.width = nn.Parameter(torch.randn(width, dim_head) * scale)

    def forward(self, q):
        emb = rearrange(self.height, 'h d -> h () d') + rearrange(self.width, 'w d -> () w d')
        emb = rearrange(emb, ' h w d -> (h w) d')
        logits = einsum('b h i d, j d -> b h i j', q, emb)
        return logits

class RelPosEmb(nn.Module):

    def __init__(self, fmap_size, dim_head):
        super().__init__()
        height, width = pair(fmap_size)
        scale = dim_head ** (-0.5)
        self.fmap_size = fmap_size
        self.rel_height = nn.Parameter(torch.randn(height * 2 - 1, dim_head) * scale)
        self.rel_width = nn.Parameter(torch.randn(width * 2 - 1, dim_head) * scale)

    def forward(self, q):
        h, w = self.fmap_size
        q = rearrange(q, 'b h (x y) d -> b h x y d', x=h, y=w)
        rel_logits_w = relative_logits_1d(q, self.rel_width)
        rel_logits_w = rearrange(rel_logits_w, 'b h x i y j-> b h (x y) (i j)')
        q = rearrange(q, 'b h x y d -> b h y x d')
        rel_logits_h = relative_logits_1d(q, self.rel_height)
        rel_logits_h = rearrange(rel_logits_h, 'b h x i y j -> b h (y x) (j i)')
        return rel_logits_w + rel_logits_h

class Attention(nn.Module):

    def __init__(self, *, dim, fmap_size, heads=4, dim_head=128, rel_pos_emb=False):
        super().__init__()
        self.heads = heads
        self.scale = dim_head ** (-0.5)
        inner_dim = heads * dim_head
        self.to_qkv = nn.Conv2d(dim, inner_dim * 3, 1, bias=False)
        rel_pos_class = AbsPosEmb if not rel_pos_emb else RelPosEmb
        self.pos_emb = rel_pos_class(fmap_size, dim_head)

    def forward(self, fmap):
        heads, b, c, h, w = (self.heads, *fmap.shape)
        q, k, v = self.to_qkv(fmap).chunk(3, dim=1)
        q, k, v = map(lambda t: rearrange(t, 'b (h d) x y -> b h (x y) d', h=heads), (q, k, v))
        q = q * self.scale
        sim = einsum('b h i d, b h j d -> b h i j', q, k)
        sim = sim + self.pos_emb(q)
        attn = sim.softmax(dim=-1)
        out = einsum('b h i j, b h j d -> b h i d', attn, v)
        out = rearrange(out, 'b h (x y) d -> b (h d) x y', x=h, y=w)
        return out

INIT_ARGS = {
    'dim': 8,
    'fmap_size': (4, 3),
    'heads': 2,
    'dim_head': 16,
    'rel_pos_emb': False,
}

ARGS = {
    'fmap': torch.randn(2, 8, 4, 3),
}

if __name__ == '__main__':
    model = Attention(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 32, 4, 3) — shape (2, 32, 4, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Block Ran
ran on a synthesized input
scheshmi/BottleneckTransformers/model.py
pointer only (licence: NONE) · get_code("5f213d496b96f84d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, scheshmi/BottleneckTransformers 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.

BoTBlock Ran
ran on a synthesized input · constructed an object; no result was computed
BIGBALLON/distribuuuu/distribuuuu/models/botnet.py
code served (permissive licence) · get_code("3f06d18fc36f803d")
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 an instance of its own class, BoTBlock: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
from torch import nn

torch.manual_seed(0)

ARGS = {
    'dim': 4,
    'fmap_size': [8, 8],
    'dim_out': 4,
    'stride': 1,
    'heads': 2,
    'proj_factor': 4,
    'dim_qk': 32,
    'dim_v': 32,
    'rel_pos_emb': False,
    'activation': nn.ReLU()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BoTBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BoTBlock 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
BoTNet_Layer Ran
ran on a synthesized input · constructed an object; no result was computed
MartinGer/Bottleneck-Transformers-for-Visual-Recognition/BoTNet_Layer.py
pointer only (licence: NONE) · get_code("eda28b8215e9ff22")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, MartinGer/Bottleneck-Transformers-for-Visual-Recognition 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.

Bottleneck Ran
ran on a synthesized input
leaderj1001/BottleneckTransformers/model.py
code served (permissive licence) · get_code("a1c9f8ce96f754a0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, 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

# INIT_ARGS for Bottleneck
INIT_ARGS = {
    'in_planes': 8,
    'planes': 4,
    'stride': 1,
    'heads': 2,
    'mhsa': True,
    'resolution': (7, 5)
}

# ARGS for forward method
# Input tensor shape: (batch, in_planes, height, width)
# Since stride=1 and mhsa=True with resolution=(7, 5), input should be (batch, 8, 7, 5)
ARGS = {
    'x': torch.randn(2, 8, 7, 5)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 4, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
BottleneckAttention Ran
ran on a synthesized input · constructed an object; no result was computed
The-AI-Summer/self_attention/self_attention_cv/bottleneck_transformer/bot_block.py
code served (permissive licence) · get_code("47c97b7ed35a625f")
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 an instance of its own class, BottleneckAttention: the run constructed the object and did not call it, so no result was computed. 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)

ARGS = {
    'dim': 4,
    'fmap_size': (2, 3),
    'heads': 2,
    'dim_head': 2,
    'content_positional_embedding': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BottleneckAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BottleneckAttention 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
GroupPointWise Ran
ran on a synthesized input · constructed an object; no result was computed
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("228f55a9b608179b")
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 an instance of its own class, GroupPointWise: the run constructed the object and did not call it, so no result was computed. 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)

ARGS = {
    'in_dim': 16,
    'n_heads': 4,
    'proj_factor': 2,
    'target_dim': 32,
}
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 GroupPointWise — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GroupPointWise 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
MHSA Ran
ran on a synthesized input · constructed an object; no result was computed
BIGBALLON/distribuuuu/distribuuuu/models/botnet.py
code served (permissive licence) · get_code("3d387b9ea3a491be")
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 an instance of its own class, MHSA: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 einops import rearrange
from torch import einsum

torch.manual_seed(0)

# Define ARGS dict with all parameters for MHSA
ARGS = {
    'dim': 4,
    'fmap_size': [2, 3],
    'heads': 2,
    'dim_qk': 8,
    'dim_v': 8,
    'rel_pos_emb': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MHSA — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MHSA 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
MHSA Ran
ran on a synthesized input
leaderj1001/BottleneckTransformers/model.py
code served (permissive licence) · get_code("b4f23ec7b5e89157")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 8, 4, 3) 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

class MHSA(nn.Module):

    def __init__(self, n_dims, width=14, height=14, heads=4):
        super(MHSA, self).__init__()
        self.heads = heads
        self.query = nn.Conv2d(n_dims, n_dims, kernel_size=1)
        self.key = nn.Conv2d(n_dims, n_dims, kernel_size=1)
        self.value = nn.Conv2d(n_dims, n_dims, kernel_size=1)
        self.rel_h = nn.Parameter(torch.randn([1, heads, n_dims // heads, 1, height]), requires_grad=True)
        self.rel_w = nn.Parameter(torch.randn([1, heads, n_dims // heads, width, 1]), requires_grad=True)
        self.softmax = nn.Softmax(dim=-1)

    def forward(self, x):
        n_batch, C, width, height = x.size()
        q = self.query(x).view(n_batch, self.heads, C // self.heads, -1)
        k = self.key(x).view(n_batch, self.heads, C // self.heads, -1)
        v = self.value(x).view(n_batch, self.heads, C // self.heads, -1)
        content_content = torch.matmul(q.permute(0, 1, 3, 2), k)
        content_position = (self.rel_h + self.rel_w).view(1, self.heads, C // self.heads, -1).permute(0, 1, 3, 2)
        content_position = torch.matmul(content_position, q)
        energy = content_content + content_position
        attention = self.softmax(energy)
        out = torch.matmul(v, attention.permute(0, 1, 3, 2))
        out = out.view(n_batch, C, width, height)
        return out


INIT_ARGS = {
    'n_dims': 8,
    'width': 4,
    'height': 3,
    'heads': 2
}

ARGS = {
    'x': torch.randn(2, 8, 4, 3)
}

if __name__ == '__main__':
    model = MHSA(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, 8, 4, 3)")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 4, dtype family float, shape (2, 8, 4, 3) — shape (2, 8, 4, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
MHSA Ran
ran on a synthesized input
scheshmi/BottleneckTransformers/model.py
pointer only (licence: NONE) · get_code("e3afa08cab48c4cf")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, scheshmi/BottleneckTransformers 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.

RelPosEmb Ran
ran on a synthesized input · constructed an object; no result was computed
BIGBALLON/distribuuuu/distribuuuu/models/botnet.py
code served (permissive licence) · get_code("1e8e321a97002a33")
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 an instance of its own class, RelPosEmb: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 einops import rearrange

torch.manual_seed(0)

# RelPosEmb.__init__ takes: height, width, dim_head
# The forward method expects q of shape [b, h, (x*y), d]
# where h is num_heads, x=height, y=width, d=dim_head

height = 4
width = 3
dim_head = 8

ARGS = {
    'height': height,
    'width': width,
    'dim_head': dim_head
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RelPosEmb — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RelPosEmb 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
RelPosEmb Ran
ran on a synthesized input
CandiceD17/Bottleneck-Transformers-for-Visual-Recognition/model/botnet.py
pointer only (licence: NONE) · get_code("90d22099bc8bc6ad")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, CandiceD17/Bottleneck-Transformers-for-Visual-Recognition 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.

RelPosEmb Ran
ran on a synthesized input
lucidrains/bottleneck-transformer-pytorch/bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
code served (permissive licence) · get_code("5f7d1c16442b0f3c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 2, 12, 12) 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
from torch import nn, einsum
from einops import rearrange

def expand_dim(t, dim, k):
    t = t.unsqueeze(dim=dim)
    expand_shape = [-1] * len(t.shape)
    expand_shape[dim] = k
    return t.expand(*expand_shape)

def pair(x):
    return (x, x) if not isinstance(x, tuple) else x

def rel_to_abs(x):
    b, h, l, _, device, dtype = (*x.shape, x.device, x.dtype)
    dd = {'device': device, 'dtype': dtype}
    col_pad = torch.zeros((b, h, l, 1), **dd)
    x = torch.cat((x, col_pad), dim=3)
    flat_x = rearrange(x, 'b h l c -> b h (l c)')
    flat_pad = torch.zeros((b, h, l - 1), **dd)
    flat_x_padded = torch.cat((flat_x, flat_pad), dim=2)
    final_x = flat_x_padded.reshape(b, h, l + 1, 2 * l - 1)
    final_x = final_x[:, :, :l, l - 1:]
    return final_x

def relative_logits_1d(q, rel_k):
    b, heads, h, w, dim = q.shape
    logits = einsum('b h x y d, r d -> b h x y r', q, rel_k)
    logits = rearrange(logits, 'b h x y r -> b (h x) y r')
    logits = rel_to_abs(logits)
    logits = logits.reshape(b, heads, h, w, w)
    logits = expand_dim(logits, dim=3, k=h)
    return logits

class RelPosEmb(nn.Module):

    def __init__(self, fmap_size, dim_head):
        super().__init__()
        height, width = pair(fmap_size)
        scale = dim_head ** (-0.5)
        self.fmap_size = fmap_size
        self.rel_height = nn.Parameter(torch.randn(height * 2 - 1, dim_head) * scale)
        self.rel_width = nn.Parameter(torch.randn(width * 2 - 1, dim_head) * scale)

    def forward(self, q):
        h, w = self.fmap_size
        q = rearrange(q, 'b h (x y) d -> b h x y d', x=h, y=w)
        rel_logits_w = relative_logits_1d(q, self.rel_width)
        rel_logits_w = rearrange(rel_logits_w, 'b h x i y j-> b h (x y) (i j)')
        q = rearrange(q, 'b h x y d -> b h y x d')
        rel_logits_h = relative_logits_1d(q, self.rel_height)
        rel_logits_h = rearrange(rel_logits_h, 'b h x i y j -> b h (y x) (j i)')
        return rel_logits_w + rel_logits_h


INIT_ARGS = {
    'fmap_size': (4, 3),
    'dim_head': 8,
}

ARGS = {
    'q': torch.randn(2, 2, 12, 8),
}

if __name__ == '__main__':
    model = RelPosEmb(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 2, 12, 12) — shape (2, 2, 12, 12) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RelPosEmb1D Ran
ran on a synthesized input · constructed an object; no result was computed
The-AI-Summer/self_attention/self_attention_cv/bottleneck_transformer/bot_block.py
code served (permissive licence) · get_code("612b904217f4544b")
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 an instance of its own class, RelPosEmb1D: the run constructed the object and did not call it, so no result was computed. 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
from torch import nn
from einops import rearrange

torch.manual_seed(0)

def rel_pos_emb_1d(q, rel_emb, shared_heads):
    """
    Same functionality as RelPosEmb1D

    Args:
        q: a 4d tensor of shape [batch, heads, tokens, dim]
        rel_emb: a 2D or 3D tensor
        of shape [ 2*tokens-1 , dim] or [ heads, 2*tokens-1 , dim]
    """
    if shared_heads:
        emb = torch.einsum('b h t d, r d -> b h t r', q, rel_emb)
    else:
        emb = torch.einsum('b h t d, h r d -> b h t r', q, rel_emb)
    return relative_to_absolute(emb)

def relative_to_absolute(q):
    """
    Converts the dimension that is specified from the axis
    from relative distances (with length 2*tokens-1) to absolute distance (length tokens)
      Input: [bs, heads, length, 2*length - 1]
      Output: [bs, heads, length, length]
    """
    b, h, l, _, device, dtype = (*q.shape, q.device, q.dtype)
    dd = {'device': device, 'dtype': dtype}
    col_pad = torch.zeros((b, h, l, 1), **dd)
    x = torch.cat((q, col_pad), dim=3)
    flat_x = rearrange(x, 'b h l c -> b h (l c)')
    flat_pad = torch.zeros((b, h, l - 1), **dd)
    flat_x_padded = torch.cat((flat_x, flat_pad), dim=2)
    final_x = flat_x_padded.reshape(b, h, l + 1, 2 * l - 1)
    final_x = final_x[:, :, :l, l - 1:]
    return final_x

class RelPosEmb1D(nn.Module):

    def __init__(self, tokens, dim_head, heads=None):
        """
        Output: [batch head tokens tokens]
        Args:
            tokens: the number of the tokens of the seq
            dim_head: the size of the last dimension of q

            heads: if None representation is shared across heads.
            else the number of heads must be provided
        """
        super().__init__()
        scale = dim_head ** (-0.5)
        self.shared_heads = heads if heads is not None else True
        if self.shared_heads:
            self.rel_pos_emb = nn.Parameter(torch.randn(2 * tokens - 1, dim_head) * scale)
        else:
            self.rel_pos_emb = nn.Parameter(torch.randn(heads, 2 * tokens - 1, dim_head) * scale)

    def forward(self, q):
        return rel_pos_emb_1d(q, self.rel_pos_emb, self.shared_heads)

ARGS = {
    'tokens': 5,
    'dim_head': 4,
    'heads': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RelPosEmb1D — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RelPosEmb1D 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
RelPosEmb2D Ran
ran on a synthesized input · constructed an object; no result was computed
The-AI-Summer/self_attention/self_attention_cv/bottleneck_transformer/bot_block.py
code served (permissive licence) · get_code("22fb48daf7ae0cc4")
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 an instance of its own class, RelPosEmb2D: the run constructed the object and did not call it, so no result was computed. 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
from torch import nn

torch.manual_seed(0)

# RelPosEmb2D expects:
# - feat_map_size: tuple of (height, width)
# - dim_head: int, dimension of head
# - heads: int or None, number of heads

ARGS = {
    'feat_map_size': (4, 3),
    'dim_head': 8,
    'heads': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RelPosEmb2D — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RelPosEmb2D 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
_conv2d1x1 Ran
ran; our contract draft was wrong, not the code
The-AI-Summer/self_attention/self_attention_cv/bottleneck_transformer/bot_block.py
code served (permissive licence) · get_code("b4c16d4e84a73b3d")
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 Sequential. 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)

ARGS = {
    "in_channels": 3,
    "out_channels": 64,
    "stride": 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 Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 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
expand_dim Ran
ran; our contract draft was wrong, not the code
BIGBALLON/distribuuuu/distribuuuu/models/botnet.py
code served (permissive licence) · get_code("ddac376537265a32")
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)

# Create a small tensor with batch size 2 and feature dimension 4
t = torch.randn(2, 4)

# Define the dimension to expand and the expansion factor
dim = 1
k = 3

ARGS = {
    "t": t,
    "dim": dim,
    "k": k
}
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
pair Ran
ran, honoured the contract we drafted
lucidrains/bottleneck-transformer-pytorch/bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
code served (permissive licence) · get_code("3e27684df29ad41d")
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 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 `pair` takes a single parameter `x` and returns either (x, x) if x is not a tuple,
# or returns x itself if it is already a tuple.
# We need to test both cases.

# Test case 1: x is not a tuple (e.g., a tensor, int, or other object)
x_not_tuple = torch.randn(2, 4)

ARGS = {
    "x": x_not_tuple
}
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 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
rel_pos_emb_1d Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
The-AI-Summer/self_attention/self_attention_cv/bottleneck_transformer/bot_block.py
code served (permissive licence) · get_code("227b65e34b12edd5")
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 4, dtype family float, shape (2, 3, 4, 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
from einops import rearrange

torch.manual_seed(0)

# Define parameters for rel_pos_emb_1d function
batch_size = 2
num_heads = 3
num_tokens = 4
dim = 5

# Create query tensor: [batch, heads, tokens, dim]
q = torch.randn(batch_size, num_heads, num_tokens, dim)

# Create relative embedding tensor
# For shared_heads=True: [2*tokens-1, dim]
# For shared_heads=False: [heads, 2*tokens-1, dim]
rel_emb_shared = torch.randn(2 * num_tokens - 1, dim)
rel_emb_not_shared = torch.randn(num_heads, 2 * num_tokens - 1, dim)

# Test with shared_heads=True
ARGS = {
    'q': q,
    'rel_emb': rel_emb_shared,
    'shared_heads': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 3, 4, 4) — shape (2, 3, 4, 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
rel_to_abs Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
BIGBALLON/distribuuuu/distribuuuu/models/botnet.py
code served (permissive licence) · get_code("560641da841eeb15")
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 4, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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)

# Create a tensor with shape [B, Nh, L, 2L - 1]
# B=2 (batch), Nh=3 (num heads), L=4 (sequence length)
# So shape is [2, 3, 4, 7] where 7 = 2*4 - 1
B = 2
Nh = 3
L = 4
x = torch.randn(B, Nh, L, 2 * L - 1)

ARGS = {
    "x": x
}
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 4, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
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
relative_logits Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("bb969778cf283586")
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 6, dtype family float, shape (2, 2, 3, 4, 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)

# Analyzing the function signature:
# relative_logits(w, h, q)
# w: used in relative_logits_1d(q, w, ...) - passed as k parameter
# h: used in relative_logits_1d(..., h, ...) - passed as k parameter
# q: used in multiple places with shape operations expecting (batch, heads, h, w, dim)

# From the code analysis:
# q has shape [bs, heads, h, w, dim] where operations expect 5D tensor
# w and h are 1D embeddings used in einsum 'bhxyd,md->bhxym'
# So w and h should have shape [dim] or [m, dim] where m is some dimension

# Let's trace through:
# In relative_logits_1d: einsum('bhxyd,md->bhxym', q, k)
# q is [bs, heads, h, w, dim], k should broadcast to [m, dim]
# After reshape: [bs*heads*h, w, 2*w-1]
# So k needs to be shape [2*w-1, dim]

# For q: shape should be [bs, heads, h, w, dim]
# Let's use: bs=2, heads=2, h=3, w=4, dim=5

bs = 2
heads = 2
h = 3
w = 4
dim = 5

# q: [bs, heads, h, w, dim]
q = torch.randn(bs, heads, h, w, dim)

# w (relative position embeddings for width): [2*w-1, dim]
# From einsum result shape, we need [2*w-1, dim]
w_param = torch.randn(2 * w - 1, dim)

# h (relative position embeddings for height): [2*h-1, dim]
# Similar logic for height dimension
h_param = torch.randn(2 * h - 1, dim)

ARGS = {
    'w': w_param,
    'h': h_param,
    'q': q,
}
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 6, dtype family float, shape (2, 2, 3, 4, 3, 4) — shape (2, 2, 3, 4, 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
relative_logits_1d Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
BIGBALLON/distribuuuu/distribuuuu/models/botnet.py
code served (permissive licence) · get_code("93ec7f5a59863d1a")
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 6, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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)

# Parameters for relative_logits_1d(q, rel_k)
# q: [B, Nh, H, W, d]
# rel_k: [2W - 1, d]

B = 2  # batch size
Nh = 3  # number of heads
H = 4  # height dimension
W = 5  # width dimension
d = 6  # feature dimension

# Create q tensor: [B, Nh, H, W, d]
q = torch.randn(B, Nh, H, W, d)

# Create rel_k tensor: [2W - 1, d]
# 2W - 1 = 2*5 - 1 = 9
rel_k = torch.randn(2 * W - 1, d)

ARGS = {
    'q': q,
    'rel_k': rel_k
}
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 6, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
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
relative_to_absolute Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
The-AI-Summer/self_attention/self_attention_cv/bottleneck_transformer/bot_block.py
code served (permissive licence) · get_code("c692e058b3b543f2")
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 4, dtype family float, shape (2, 4, 3, 3) 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
from einops import rearrange

torch.manual_seed(0)

# Construct a valid input tensor for relative_to_absolute
# Input shape: [bs, heads, length, 2*length - 1]
# Let's use: bs=2, heads=4, length=3
# So the last dimension should be 2*3-1 = 5

bs = 2
heads = 4
length = 3
relative_dim = 2 * length - 1  # 5

q = torch.randn(bs, heads, length, relative_dim)

ARGS = {
    'q': q
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 4, 3, 3) — shape (2, 4, 3, 3) 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
AbsolutePosEmb Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("60b38ccc9cd86edd")
How it ran

no invocation recorded.

BoTBlock Not yet run
unverified (harvested, no recorded run)
CandiceD17/Bottleneck-Transformers-for-Visual-Recognition/model/botnet.py
pointer only (licence: NONE) · get_code("c89f1a9517a0905e")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, CandiceD17/Bottleneck-Transformers-for-Visual-Recognition 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.

BoTBlock Not yet run
unverified (harvested, no recorded run)
NZ99/bottleneck-transformer-flax/bottleneck_transformer_flax/botnet.py
code served (permissive licence) · get_code("635303b35edfe8e2")
How it ran

no invocation recorded.

BoTMHSA Not yet run
unverified (harvested, no recorded run)
NZ99/bottleneck-transformer-flax/bottleneck_transformer_flax/botnet.py
code served (permissive licence) · get_code("4246cb32d13d3b98")
How it ran

no invocation recorded.

BoTNet Not yet run
unverified (harvested, no recorded run)
scheshmi/BottleneckTransformers/model.py
pointer only (licence: NONE) · get_code("14a63975366ccc24")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, scheshmi/BottleneckTransformers 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.

BoTNet Not yet run
unverified (harvested, no recorded run)
NZ99/bottleneck-transformer-flax/bottleneck_transformer_flax/botnet.py
code served (permissive licence) · get_code("93c353b1b05ef701")
How it ran

no invocation recorded.

BoTNetConfig Not yet run
unverified (harvested, no recorded run)
NZ99/bottleneck-transformer-flax/bottleneck_transformer_flax/botnet.py
code served (permissive licence) · get_code("58200aabf211669a")
How it ran

no invocation recorded.

BotNet Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("771d64f60cf10b0d")
How it ran

no invocation recorded.

BotnetX Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("3d7d4980902b0da3")
How it ran

no invocation recorded.

BottleBlock Not yet run
unverified (harvested, no recorded run)
lucidrains/bottleneck-transformer-pytorch/bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
code served (permissive licence) · get_code("957f9748a5caf504")
How it ran

no invocation recorded.

Bottleneck Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("6fd5faa3cfeccf67")
How it ran

no invocation recorded.

BottleneckBlock Not yet run
unverified (harvested, no recorded run)
The-AI-Summer/self_attention/self_attention_cv/bottleneck_transformer/bot_block.py
code served (permissive licence) · get_code("31358a487667e5f1")
How it ran

no invocation recorded.

BottleneckResNetBlock Not yet run
unverified (harvested, no recorded run)
NZ99/bottleneck-transformer-flax/bottleneck_transformer_flax/botnet.py
code served (permissive licence) · get_code("685fb6581dbbfbec")
How it ran

no invocation recorded.

MHSA Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("4a8e8eb7d2edff3d")
How it ran

no invocation recorded.

MHSA Not yet run
unverified (harvested, no recorded run)
CandiceD17/Bottleneck-Transformers-for-Visual-Recognition/model/botnet.py
pointer only (licence: NONE) · get_code("0eb9211a00bd7524")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, CandiceD17/Bottleneck-Transformers-for-Visual-Recognition 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.

RelativeLogits Not yet run
unverified (harvested, no recorded run)
NZ99/bottleneck-transformer-flax/bottleneck_transformer_flax/botnet.py
code served (permissive licence) · get_code("c92dd55c1dc2fa04")
How it ran

no invocation recorded.

RelativePosEmb Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("e1685f603e910d5a")
How it ran

no invocation recorded.

SELayer Not yet run
unverified (harvested, no recorded run)
NZ99/bottleneck-transformer-flax/bottleneck_transformer_flax/botnet.py
code served (permissive licence) · get_code("09e1a6a94cc17376")
How it ran

no invocation recorded.

absolute_logits Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("8c47eb5f2d30130b")
How it ran

no invocation recorded.

rel_to_abs Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("1d5fc659fc20f4b8")
How it ran

no invocation recorded.

rel_to_abs Not yet run
unverified (harvested, no recorded run)
lucidrains/bottleneck-transformer-pytorch/bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
code served (permissive licence) · get_code("2c273760ec522435")
How it ran

no invocation recorded.

relative_logits_1d Not yet run
unverified (harvested, no recorded run)
nachiket273/VisTrans/vistrans/models/botnet.py
code served (permissive licence) · get_code("dde3921cad5d0cc0")
How it ran

no invocation recorded.

relative_logits_1d Not yet run
unverified (harvested, no recorded run)
lucidrains/bottleneck-transformer-pytorch/bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
code served (permissive licence) · get_code("5b41b7a682f4c678")
How it ran

no invocation recorded.

Also present in other papers' code

Of 49 samples lifted from this paper's linked repositories, 49 carry a function identity and 0 do not. Of the 47 distinct functions with an identity, 5 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 2 later) and 42 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
expand_dim
brick of this paper's assembly: helper
4 other papers
4 later
2103.12731 (2021-03)
Scaling Local Self-Attention for Parameter Efficient Visual Backbones
2310.11881 (2023-10)
A Comparative Study of Image Restoration Networks for General Backbone Network Design
2404.07846 (2024-04)
Rethinking Transformer-Based Blind-Spot Network for Self-Supervised Image Denoising
and 1 more not named here
pair
brick of this paper's assembly: helper
3 other papers
3 later
2103.12731 (2021-03)
Scaling Local Self-Attention for Parameter Efficient Visual Backbones
2310.11881 (2023-10)
A Comparative Study of Image Restoration Networks for General Backbone Network Design
2404.07846 (2024-04)
Rethinking Transformer-Based Blind-Spot Network for Self-Supervised Image Denoising
RelPosEmb1D
brick of this paper's assembly: helper
1 other paper
1 dated earlier
1803.02155 (2018-03)
Self-Attention with Relative Position Representations
rel_pos_emb_1d
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
1803.02155 (2018-03)
Self-Attention with Relative Position Representations
relative_to_absolute
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
1803.02155 (2018-03)
Self-Attention with Relative Position Representations

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

We present BoTNet, a conceptually simple yet powerful backbone architecture that incorporates self-attention for multiple computer vision tasks including image classification, object detection and instance segmentation. By just replacing the spatial convolutions with global self-attention in the final three bottleneck blocks of a ResNet and no other changes, our approach improves upon the baselines significantly on instance segmentation and object detection while also reducing the parameters, with minimal overhead in latency. Through the design of BoTNet, we also point out how ResNet bottleneck blocks with self-attention can be viewed as Transformer blocks. Without any bells and whistles, BoTNet achieves 44.4% Mask AP and 49.7% Box AP on the COCO Instance Segmentation benchmark using the Mask R-CNN framework; surpassing the previous best published single model and single scale results of ResNeSt [67] evaluated on the COCO validation set. Finally, we present a simple adaptation of the BoTNet design for image classification, resulting in models that achieve a strong performance of 84.7% top-1 accuracy on the ImageNet benchmark while being up to 1.64x faster in "compute" 1 time than the popular EfficientNet models on TPU-v3 hardware. We hope our simple and effective approach will serve as a strong baseline for future research in self-attention models for vision. 2

For agents

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

get_harvested_code_for_paper("2101.11605")
get_code_for_paper("2101.11605")
have("2101.11605")

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

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

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

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

Connect an agent — have() is free.