All models

shvit_s4

A memory-efficient vision transformer with a 16x16 stem, three stages and single-head partial-channel attention.

Image classification · 539 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 (31 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

Family
shvit
Parameters
16.6M
Operations
539
Framework
PyTorch
Recurrent
No
Published
CVPR (arXiv 2024)
Cited by
181 (as of 9 October 2026)
Authors
Seokju Yun, Youngmin Ro
License
Apache-2.0
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
m9187
Graph hash
0b2944bb32a2605c0a7cba70e0346c992caa66ade607352d018b646a1b831ca1
Skeleton hash
454aabe282b77c14c734789c37fec131126224a92da9a2807ec6e7c10e42de21
Architecture hash
b748f3aebf9227c687c78daed0087dd36699682e5a94531c372747eaeaedae7d
Diagram SHA-256
0b3685e9507e06c2a01b49eee888900672e137432d0adc9b4aa81045ae5f3b48
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

How this diagram was made

timm.create_model('shvit_s4', pretrained=False)

What it is

About this model's family

SHViT, the Single-Head Vision Transformer, is an efficient vision transformer built around removing computational redundancy at all design levels in a memory-efficient manner. Where conventional efficient ViTs use 4 by 4 patch embeddings and a 4-stage structure, SHViT adopts a 16 by 16 patchify stem and a 3-stage design. The authors find that a larger-stride patchify stem reduces memory access costs and stays competitive by leveraging token representations with reduced spatial redundancy from the early stages.

At the micro level, Single-Head Self-Attention applies an attention layer with a single head on only a part of the input channels and leaves the remaining channels untouched. The partial ratio r defaults to 1/4.67. This removes the redundancy of the multi-head mechanism and reduces memory access cost by processing partial channels. A SHViT block has three parts: a depthwise convolution for local feature aggregation, the SHSA layer for modeling global contexts, and a feed-forward network. The first stage uses no SHSA layer at all, following the finding that early-stage attention can be substituted with convolutions.

Layer Normalization is used only for the SHSA layer, with Batch Normalization elsewhere so it can be merged into adjacent convolution or linear layers. Four variants, S1 to S4, differ in depth and width, and all four are captured here. SHViT-S4 reaches 79.4% top-1 on ImageNet at 14283 images per second on an Nvidia A100 GPU and 509 images per second on an Intel Xeon Gold 5218R CPU.

Key idea. SHViT-S4 is 3.3x, 8.1x and 2.4x faster than MobileViTv2 x1.0 on GPU, CPU and iPhone 12 while being 1.3% more accurate, by using single-head attention on partial channels and a 16 by 16 stem with three stages.

  • shvit
  • single-head vision transformer
  • single head attention
  • shsa
  • shvit_s1
  • shvit_s2
  • shvit_s3
  • shvit_s4
  • efficient vit
  • mobile vit
  • image classification

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

Cite the paper

@misc{yun2024shvitsingleheadvisiontransformer,
      title={SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design}, 
      author={Seokju Yun and Youngmin Ro},
      year={2024},
      eprint={2401.16456},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2401.16456}, 
}