SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · aaai_28109 · AAAI · 2024

Bi-ViT: Pushing the Limit of Vision Transformer Quantization

Sheng Xu, Baochang Zhang, Mingbao Lin, Chuanjian Liu, Xiao Sun, Xianbin Cao, Yanjing Li

Open in the Atlas

Code that ran

11 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; 2 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 5 failures of our instrument; 1 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/aaai_28109.json · badge: /api/ran/aaai_28109.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
YanjingLi0202/Bi-ViT canonical (classifier label)
classifier basis: census
11 ran · 1 no recorded run
FunctionStatusWhere it lives
build_dataset Ran
ran on a synthesized input
YanjingLi0202/Bi-ViT/datasets.py
pointer only (licence: Apache-2.0) · get_code("935b59a987b6e745")
How it ran

The body of this sample is withheld: Apache-2.0, as GitHub detects it on this paper's repository, YanjingLi0202/Bi-ViT, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

build_transform Ran
ran; our contract draft was wrong, not the code
YanjingLi0202/Bi-ViT/datasets.py
code served (permissive licence) · get_code("3bc74137ab36aa79")
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 Compose. 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 numpy as np
from torchvision import transforms

torch.manual_seed(0)

class ArgsConfig:
    def __init__(self):
        self.input_size = 224
        self.color_jitter = 0.4
        self.aa = "rand-m9-mstd0.5"
        self.train_interpolation = "bicubic"
        self.reprob = 0.25
        self.remode = "pixel"
        self.recount = 2

ARGS = {
    "is_train": True,
    "args": ArgsConfig()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, timm, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
checkpoint_filter_fn Ran
ran; our contract draft was wrong, not the code
YanjingLi0202/Bi-ViT/bi_vision_transformer.py
code served (permissive licence) · get_code("0b3795f9775ce118")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import math

torch.manual_seed(0)

# Build a minimal model that has the attributes accessed in checkpoint_filter_fn
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        # patch_embed.proj needs to be a Conv2d with weight shape (O, I, H, W)
        self.patch_embed = nn.Module()
        self.patch_embed.proj = nn.Conv2d(3, 16, kernel_size=4, stride=4)
        
        # pos_embed needs to match the shape that will be checked
        # For a model with 64x64 input, 4x4 patches, we get 16x16 = 256 patches
        # Plus 1 for class token = 257 tokens, embed_dim=8
        self.pos_embed = torch.randn(1, 257, 8)

model = MinimalModel()

# Create a state_dict that will be processed
# Include a pos_embed with different shape to trigger resize_pos_embed
# Old pos_embed: 1 cls token + 100 grid tokens (10x10 grid) = 101 tokens, dim 8
old_pos_embed = torch.randn(1, 101, 8)

state_dict = {
    'pos_embed': old_pos_embed,
    'patch_embed.proj.weight': torch.randn(16, 3, 4, 4),
    'some_other_param': torch.randn(10, 10),
}

ARGS = {
    'state_dict': state_dict,
    'model': model,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
conv3x3 Ran
ran; our contract draft was wrong, not the code
YanjingLi0202/Bi-ViT/patchconvnet_models.py
code served (permissive licence) · get_code("ba6aa5f07daca9cd")
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 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_planes': 8,
    'out_planes': 16,
    'stride': 2
}
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 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
get_sparsity_mask Ran
ran; our contract draft was wrong, not the code
YanjingLi0202/Bi-ViT/_binary_base_plus.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from biclab/spikeyolo, is pointer only (licence: AGPL-3.0) · get_code("16941a8d0425664f")
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 biclab/spikeyolo, and AGPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

grad_scale Ran
ran, honoured the contract we drafted
YanjingLi0202/Bi-ViT/_binary_base_plus.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from hustzxd/LSQuantization, is pointer only (licence: NONE) · get_code("d75564df9359ef7b")
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 hustzxd/LSQuantization, 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.

layer_mf_loss Ran
ran on a synthesized input
YanjingLi0202/Bi-ViT/losses.py
pointer only (licence: Apache-2.0) · get_code("df0fa00356a96092")
How it ran

The body of this sample is withheld: Apache-2.0, as GitHub detects it on this paper's repository, YanjingLi0202/Bi-ViT, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

mf_loss Ran
ran on a synthesized input
YanjingLi0202/Bi-ViT/losses.py
pointer only (licence: Apache-2.0) · get_code("52c7c7af9cec90df")
How it ran

The body of this sample is withheld: Apache-2.0, as GitHub detects it on this paper's repository, YanjingLi0202/Bi-ViT, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

resize_pos_embed Ran
ran; our contract draft was wrong, not the code
YanjingLi0202/Bi-ViT/bi_vision_transformer.py
code served (permissive licence) · get_code("109c74bc1997c975")
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 (1, 10, 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 math
import logging
import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Setup logging
logging.basicConfig(level=logging.INFO)

# Create position embeddings
# posemb: [batch, num_tokens, embed_dim]
# The function expects:
# - posemb[:, :1] to be the token embedding (CLS token)
# - posemb[0, 1:] to be the grid embeddings
# For a 4x4 grid, we need 1 + 16 = 17 tokens
# Let's use a smaller grid: 2x2 = 4 grid tokens + 1 cls token = 5 total tokens

embed_dim = 8
old_grid_size = 2  # 2x2 grid
num_old_tokens = 1 + old_grid_size * old_grid_size  # 1 cls + 4 grid = 5
posemb = torch.randn(1, num_old_tokens, embed_dim)

# Create new position embedding with different grid size
# Let's resize to a 3x3 grid: 1 + 9 = 10 tokens
new_grid_size = 3  # 3x3 grid
num_new_tokens = 1 + new_grid_size * new_grid_size  # 1 cls + 9 grid = 10
posemb_new = torch.randn(1, num_new_tokens, embed_dim)

ARGS = {
    'posemb': posemb,
    'posemb_new': posemb_new,
}
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 (1, 10, 8) — shape (1, 10, 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
round_pass Ran
ran, honoured the contract we drafted
YanjingLi0202/Bi-ViT/_binary_base_plus.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from hustzxd/LSQuantization, is pointer only (licence: NONE) · get_code("40027e5e78ca8837")
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 hustzxd/LSQuantization, 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.

sign_pass Ran
ran on a synthesized input
YanjingLi0202/Bi-ViT/Bi_Quant.py
pointer only (licence: Apache-2.0) · get_code("2ad3bbb0e266ae97")
How it ran

The body of this sample is withheld: Apache-2.0, as GitHub detects it on this paper's repository, YanjingLi0202/Bi-ViT, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

merge Not yet run
unverified (harvested, no recorded run)
YanjingLi0202/Bi-ViT/losses.py
pointer only (licence: Apache-2.0) · get_code("14b5de82375793ff")
How it ran

The body of this sample is withheld: Apache-2.0, as GitHub detects it on this paper's repository, YanjingLi0202/Bi-ViT, is in the permissive set, but a licence decision keeps the body a pointer: the reason for that decision is not recorded with it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. 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, 7 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 0 the same month, 4 later) and 5 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
build_transform 37 other papers
30 dated earlier, 1 later, 6 same year, order not determinable
2104.05707 (2021-04)
LocalViT: Analyzing Locality in Vision Transformers
2104.13840 (2021-04)
Twins: Revisiting the Design of Spatial Attention in Vision Transformers
2106.00515 (2021-06)
KVT: k-NN Attention for Boosting Vision Transformers
and 34 more not named here
resize_pos_embed 8 other papers
6 dated earlier, 2 same year, order not determinable
2106.00515 (2021-06)
KVT: k-NN Attention for Boosting Vision Transformers
2107.00645 (2021-07)
Global Filter Networks for Image Classification
2108.01390 (2021-08)
Evo-ViT: Slow-Fast Token Evolution for Dynamic Vision Transformer
and 5 more not named here
checkpoint_filter_fn 7 other papers
5 dated earlier, 2 same year, order not determinable
2106.00515 (2021-06)
KVT: k-NN Attention for Boosting Vision Transformers
2107.00645 (2021-07)
Global Filter Networks for Image Classification
2108.01390 (2021-08)
Evo-ViT: Slow-Fast Token Evolution for Dynamic Vision Transformer
and 4 more not named here
grad_scale 5 other papers
2 dated earlier, 1 later, 2 same year, order not determinable
1902.08153 (2019-02)
Learned Step Size Quantization
2201.07703 (2022-01)
Q-ViT: Fully Differentiable Quantization for Vision Transformer
2404.05662 (2024-04)
BinaryDM: Accurate Weight Binarization for Efficient Diffusion Models
and 2 more not named here
round_pass 5 other papers
2 dated earlier, 1 later, 2 same year, order not determinable
1902.08153 (2019-02)
Learned Step Size Quantization
2201.07703 (2022-01)
Q-ViT: Fully Differentiable Quantization for Vision Transformer
2404.05662 (2024-04)
BinaryDM: Accurate Weight Binarization for Efficient Diffusion Models
and 2 more not named here
conv3x3 4 other papers
3 dated earlier, 1 later
2112.13692 (2021-12)
Augmenting Convolutional networks with attention-based aggregation
Yu_LaPE_Layer-adaptive_Position_Embedding_for_Vision_Transformers_with_Independent_Layer_ICCV_2023_paper (2023 (year only))
LaPE: Layer-adaptive Position Embedding for Vision Transformers with Independent Layer Normalization
2310.01812 (2023-10)
PPT: Token Pruning and Pooling for Efficient Vision Transformers
and 1 more not named here
get_sparsity_mask 1 other paper
1 same year, order not determinable
2407.20708 (2024-07)
Integer-Valued Training and Spike-Driven Inference Spiking Neural Network for High-performance and Energy-efficient Object Detection

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

Vision transformers (ViTs) quantization offers a promising prospect to facilitate deploying large pre-trained networks on resource-limited devices. Fully-binarized ViTs (Bi-ViT) that pushes the quantization of ViTs to its limit remain largely unexplored and a very challenging task yet, due to their unacceptable performance. Through extensive empirical analyses, we identify the severe drop in ViT binarization is caused by attention distortion in self-attention, which technically stems from the gradient vanishing and ranking disorder. To address these issues, we first introduce a learnable scaling factor to reactivate the vanished gradients and illustrate its effectiveness through theoretical and experimental analyses. We then propose a ranking-aware distillation method to rectify the disordered ranking in a teacher-student framework. Bi-ViT achieves significant improvements over popular DeiT and Swin backbones in terms of Top-1 accuracy and FLOPs. For example, with DeiT-Tiny and Swin-Tiny, our method significantly outperforms baselines by 22.1% and 21.4% respectively, while 61.5× and 56.1× theoretical acceleration in terms of FLOPs compared with real-valued counterparts on ImageNet. Our codes and models are attached on https: //github.com/YanjingLi0202/Bi-ViT/

For agents

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

get_harvested_code_for_paper("aaai_28109")
get_code_for_paper("aaai_28109")
have("aaai_28109")

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

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

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

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

Connect an agent — have() is free.