SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.10716 · CVPR · 2023

Joint Token Pruning and Squeezing Towards More Aggressive Compression of Vision Transformers

Tianzhu Ye, Yao Tang, Jiajun Liang, Shen Zhang, Siyuan Wei

arXiv · PDF · Open in the Atlas

Code that ran

4 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 4 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/2304.10716.json · badge: /api/ran/2304.10716.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
megvii-research/TPS-CVPR2023 canonical (classifier label)
classifier basis: census
4 ran · 4 no recorded run
FunctionStatusWhere it lives
batch_index_select Ran
ran; our contract draft was wrong, not the code
megvii-research/TPS-CVPR2023/torch_codebase/models/dynamic_vit.py
code served (permissive licence) · get_code("908619be92da9903")
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, 2, 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

torch.manual_seed(0)

# Test case 1: 3D tensor
x_3d = torch.randn(2, 4, 3)  # B=2, N=4, C=3
idx_3d = torch.tensor([[0, 2], [1, 3]])  # B=2, N_new=2

# Test case 2: 2D tensor
x_2d = torch.randn(2, 4)  # B=2, N=4
idx_2d = torch.tensor([[0, 2], [1, 3]])  # B=2, N_new=2

# Use the 3D case for ARGS
ARGS = {
    "x": x_3d,
    "idx": idx_3d,
}
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, 2, 3) — shape (2, 2, 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
build_transform Ran
ran; our contract draft was wrong, not the code
megvii-research/TPS-CVPR2023/torch_codebase/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
contain_bias_and_norm Ran
ran on a synthesized input
megvii-research/TPS-CVPR2023/megengine_codebase/utils.py
code served (permissive licence) · get_code("427f72651ff7cfa0")
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 bool, 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)

# The function takes two parameters:
# 1. name: a string representing a parameter name
# 2. param: a parameter object that needs to have an ndim attribute

# Create a simple parameter object
param_bias = torch.nn.Parameter(torch.randn(4))  # 1D tensor (ndim=1)
param_weight = torch.nn.Parameter(torch.randn(4, 3))  # 2D tensor (ndim=2)

# Test with a bias parameter name and a 1D tensor
name = "layer.bias"
param = param_bias

ARGS = {
    "name": name,
    "param": param
}
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 bool, 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
rand_bbox Ran
ran; our contract draft was wrong, not the code
megvii-research/TPS-CVPR2023/megengine_codebase/mixup.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from terrypei/efficientvmamba, is pointer only (licence: NONE) · get_code("3913c620f6926f42")
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 terrypei/efficientvmamba, 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_dataset Not yet run
unverified (harvested, no recorded run)
megvii-research/TPS-CVPR2023/torch_codebase/datasets.py
code served (permissive licence) · get_code("0d5eb6177974e3b2")
How it ran

no invocation recorded.

get_loss_cls Not yet run
unverified (harvested, no recorded run)
megvii-research/TPS-CVPR2023/torch_codebase/losses/loss.py
code served (permissive licence) · get_code("7026a4f946a4f7a3")
How it ran

no invocation recorded.

get_module_cls Not yet run
unverified (harvested, no recorded run)
megvii-research/TPS-CVPR2023/torch_codebase/models/dynamic_vit.py
code served (permissive licence) · get_code("c0d55edbcda649c3")
How it ran

no invocation recorded.

get_sim Not yet run
unverified (harvested, no recorded run)
megvii-research/TPS-CVPR2023/torch_codebase/models/dynamic_vit.py
code served (permissive licence) · get_code("b31af37bba5ce554")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 3 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
24 dated earlier, 10 later, 3 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
rand_bbox 14 other papers
6 dated earlier, 8 later
2109.03508 (2021-09)
RepNAS: Searching for Efficient Re-parameterizing Blocks
2111.06377 (2021-11)
Masked Autoencoders Are Scalable Vision Learners
2206.13559 (2022-06)
ST-Adapter: Parameter-Efficient Image-to-Video Transfer Learning
and 11 more not named here
batch_index_select 10 other papers
2 dated earlier, 7 later, 1 same year, order not determinable · 1 only as an assembly brick
2106.02034 (2021-06)
DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification
2202.06258 (2022-02)
Flowformer: Linearizing Transformers with Conservation Flows
aaai_25860 (2023 (year only))
CF-ViT: A General Coarse-to-Fine Method for Vision Transformer
and 7 more not named here

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

Although vision transformers (ViTs) have shown promising results in various computer vision tasks recently, their high computational cost limits their practical applications. Previous approaches that prune redundant tokens have demonstrated a good trade-off between performance and computation costs. Nevertheless, errors caused by pruning strategies can lead to significant information loss. Our quantitative experiments reveal that the impact of pruned tokens on performance should be noticeable. To address this issue, we propose a novel joint Token Pruning & Squeezing module (TPS) for compressing vision transformers with higher efficiency. Firstly, TPS adopts pruning to get the reserved and pruned subsets. Secondly, TPS squeezes the information of pruned tokens into partial reserved tokens via the unidirectional nearest-neighbor matching and similarity-based fusing steps. Compared to state-of-theart methods, our approach outperforms them under all token pruning intensities. Especially while shrinking DeiT-tiny&small computational budgets to 35%, it improves the accuracy by 1%-6% compared with baselines on ImageNet classification. The proposed method can accelerate the throughput of DeiT-small beyond DeiT-tiny, while its accuracy surpasses DeiT-tiny by 4.78%. Experiments on various transformers demonstrate the effectiveness of our method, while analysis experiments prove our higher robustness to the errors of the token pruning policy. Code is available at https://github.com/megvii-research/TPS-CVPR2023.

For agents

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

get_harvested_code_for_paper("2304.10716")
get_code_for_paper("2304.10716")
have("2304.10716")

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

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

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

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

Connect an agent — have() is free.