All models

DynamicViT

A DeiT-S vision transformer that prunes less informative image tokens at three depths to save computation.

Image classification · 448 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (101 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
22.8M
Operations
448
Framework
PyTorch
Recurrent
No
Published
NeurIPS 2021
Cited by
448 (as of 29 October 2026)
Authors
Yongming Rao, Wenliang Zhao, Benlin Liu and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m16241
Graph hash
d4dbc54064f6df769acb2eb3bd4d5b0e060fd8137fac68864db28274db1930a8
Skeleton hash
601fc36f1acc8fa2551d2e4f4bd9b92417136f98d2c16f6244af4c12087f5d9a
Architecture hash
259deba2069fdc550bd481bd69da30db5ab87ca2869cee0e425cc58eddec3ddb
Diagram SHA-256
2c7161945b179dc27617f546689e62af91d621ec17140522bf032ac48c4b6714
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

DynamicViT is a vision transformer that prunes redundant image tokens progressively as the input passes through the network, choosing which tokens to drop based on the input itself. It rests on the paper's observation that the final prediction of a vision transformer is based only on a subset of the most informative tokens.

The model is a normal vision transformer backbone plus several lightweight prediction modules that decide which tokens to keep. Each prediction module combines a local feature for a token with a global feature pooled over the tokens still kept, and feeds both to an MLP that predicts the probabilities of dropping or keeping the token. In a 12-layer transformer the paper places token sparsification before the 4th, 7th and 10th blocks. During training, tokens are masked instead of removed: an attention masking strategy drops the connection from abandoned tokens to all other tokens in the attention matrix. At inference, a fixed amount of tokens is discarded after certain layers.

The paper reports that hierarchically pruning 66% of the input tokens reduces FLOPs by 31% to 37% and improves throughput by over 40%, with a drop in accuracy within 0.5%. The code repository lists the DeiT-S version at a keeping ratio of 0.7 with 79.32% top-1 accuracy on ImageNet at 2.9G FLOPs.

Key idea. DynamicViT adds lightweight prediction modules to a vision transformer that score each token and prune the uninformative ones hierarchically, trained end to end through an attention masking strategy.

  • dynamicvit
  • dynamic vit
  • dynamic token sparsification
  • token pruning
  • token sparsification
  • efficient vision transformer
  • vision transformer
  • image classification
  • imagenet

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{rao2021dynamicvitefficientvisiontransformers,
      title={DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification}, 
      author={Yongming Rao and Wenliang Zhao and Benlin Liu and Jiwen Lu and Jie Zhou and Cho-Jui Hsieh},
      year={2021},
      eprint={2106.02034},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2106.02034}, 
}