Skip to main content
QUICK REVIEW

[Paper Review] SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design

Seokju Yun, Youngmin Ro|arXiv (Cornell University)|Jan 29, 2024
CCD and CMOS Imaging SensorsEngineering6 citations
TL;DR

SHViT introduces memory-efficient macro design and a single-head self-attention module to achieve fast, accurate vision transformers across GPUs, CPUs, and mobile devices. It uses a large-stride 16x16 patch stem and three-stage architecture with SHSA to maximize speed-accuracy across tasks.

ABSTRACT

Recently, efficient Vision Transformers have shown great performance with low latency on resource-constrained devices. Conventionally, they use 4x4 patch embeddings and a 4-stage structure at the macro level, while utilizing sophisticated attention with multi-head configuration at the micro level. This paper aims to address computational redundancy at all design levels in a memory-efficient manner. We discover that using larger-stride patchify stem not only reduces memory access costs but also achieves competitive performance by leveraging token representations with reduced spatial redundancy from the early stages. Furthermore, our preliminary analyses suggest that attention layers in the early stages can be substituted with convolutions, and several attention heads in the latter stages are computationally redundant. To handle this, we introduce a single-head attention module that inherently prevents head redundancy and simultaneously boosts accuracy by parallelly combining global and local information. Building upon our solutions, we introduce SHViT, a Single-Head Vision Transformer that obtains the state-of-the-art speed-accuracy tradeoff. For example, on ImageNet-1k, our SHViT-S4 is 3.3x, 8.1x, and 2.4x faster than MobileViTv2 x1.0 on GPU, CPU, and iPhone12 mobile device, respectively, while being 1.3% more accurate. For object detection and instance segmentation on MS COCO using Mask-RCNN head, our model achieves performance comparable to FastViT-SA12 while exhibiting 3.8x and 2.0x lower backbone latency on GPU and mobile device, respectively.

Motivation & Objective

  • Identify computational redundancies in macro and micro design of efficient ViTs.
  • Propose memory-efficient macro design to reduce memory access and latency.
  • Develop a Single-Head Self-Attention (SHSA) to mitigate multi-head redundancy.
  • Construct the SHViT family with fast inference while maintaining high accuracy.
  • Demonstrate SHViT's effectiveness on ImageNet classification and COCO detection/segmentation.

Proposed method

  • Analyze macro design redundancy by comparing 4x4 patch embeddings versus larger-stride stems and 3-stage designs.
  • Propose memory-efficient macro design with 16x16 patchify stem and stage-wise token reduction.
  • Introduce Single-Head Self-Attention (SHSA) where a single head operates on a subset of channels, preserving others as residuals.
  • Assemble SHViT blocks with Depthwise Convolution, SHSA, and FFN, using BN passthrough and ReLU activations for speed.
  • Train four SHViT variants (S1–S4) with varying depth/width, leveraging a large channel count and overlapping patch embedding.
  • Evaluate SHViT on ImageNet-1K for classification and on COCO for RetinaNet/Mask R-CNN, including mobile latency.
  • Compare SHViT against state-of-the-art efficient models and ONNX-runtime performance.
Figure 1 : Comparison of throughput and accuracy between our SHViT and other recent methods.
Figure 1 : Comparison of throughput and accuracy between our SHViT and other recent methods.

Experimental results

Research questions

  • RQ1Does a larger-stride patch embedding stem reduce memory access costs while maintaining accuracy?
  • RQ2Can early-stage attention be replaced with convolutions to improve speed without sacrificing performance?
  • RQ3Is there substantial head redundancy in later MHSA layers that can be mitigated by a single-head design?
  • RQ4How does SHViT perform across devices (GPU, CPU, mobile) and tasks (classification, detection, segmentation) compared to SOTA efficient models?

Key findings

  • A 16x16 patch stem with a 3-stage design reduces memory access and maintains competitive accuracy versus 4x4 stems.
  • Early-stage convolutions can outperform attention for efficiency on initial stages, reducing latency.
  • Single-Head Self-Attention (SHSA) reduces head redundancy and memory-bound operations by computing attention on a partial channel set with a final projection applied to all channels.
  • SHViT variants achieve superior speed-accuracy tradeoffs across GPUs, CPUs, and mobile devices, e.g., SHViT-S4 shows notable throughput and Top-1 accuracy gains over comparable models.
  • On COCO, SHViT backbones provide competitive or superior AP metrics with lower latency in RetinaNet and Mask R-CNN heads.
  • ONNX runtime benefits from SHViT’s reduced reshapes and memory-bound operations, enhancing real-time performance.
Figure 2 : Macro design analysis. All stages are composed of MetaFormer blocks [ 28 ] . The stages depicted in blue and red utilize depthwise convolution and attention layers as token mixer, respectively. In the table below, the macro design numbers represent the number of channels, while the number
Figure 2 : Macro design analysis. All stages are composed of MetaFormer blocks [ 28 ] . The stages depicted in blue and red utilize depthwise convolution and attention layers as token mixer, respectively. In the table below, the macro design numbers represent the number of channels, while the number

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.