betaFeedback

WorksComputer Science

REViT-v2: Hierarchical Windowed Roto-reflection Equivariant ViT for Equivariant Feature Extraction

Abstract

We propose a scalable roto-reflection-group-equivariant vision transformer based on windowed group-convolutional self-attention and a hierarchical feature architecture. We demonstrate that our approach can be scaled to group-equivariant vision transformers (ViTs) with millions of parameters and large datasets with practically sized images, i.e., ImageNet. The code and pretrained weights for the proposed Hierarchical Windowed Roto-reflection Equivariant ViTs (REViT-v2) are available at https://github.com/kc-ml2/revit.

Introduction

Standard vision transformers (ViTs) ([4]) do not explicitly encode common image symmetries. A conventional model must learn from data that a visual pattern retains its identity after a rotation or reflection. Group-equivariant neural networks instead incorporate this relationship into the architecture. Group-equivariant convolutional networks introduced group convolutions as a systematic means of sharing filters across translations, rotations, and reflections ([2, 9]).

Romero and Cordonnier [8] extended the same principle to attention and showed that attention can be made equivariant to symmetry groups by constructing positional encodings that are invariant under the corresponding group action. This provides a general theoretical formulation, but it does not scale beyond low-resolution images. Moreover, group-relative positional terms must be repeatedly evaluated in all attention layers. Zaheer et al. (2026) subsequently introduced rot-reflection equivariant convolutional vision transformer (REViT) with group-convolutional self-attention (G-CSA), in which convolutional projections remove the dependence on explicit positional encoding. This makes equivariant transformers considerably simpler. Nevertheless, when group-convolutional attention is evaluated globally, its spatial attention matrix remains quadratic with respect to input size. The cost is especially important for equivariant models because regular group representations typically allocate several orientation channels to each feature field.

Several developments in efficient vision transformers suggest a path toward addressing this limitation. CvT introduced convolutional token embedding and convolutional attention projections showing that convolutional structure can reduce the need for explicit positional encoding ((Wu et al., 2021)). Swin transformer restricted attention to local windows and organized the network into a multiscale pyramid ([7]). Multiscale Vision Transformers similarly demonstrated the value of progressively reducing token resolution while increasing channel capacity ([5]).

In this paper, we propose REViT-v2. REViT-v2 combines hierarchical vision transformers with local group-equivariant convolutional self attention. REViT-v2 introduces two central components. First, it utilizes Windowed Group Convolutional Self-Attention (wG-CSA), which performs attention within local spatial windows while preserving complete group-representation fields in each attention head. Second, it constructs a multi-stage equivariant feature pyramid using group-convolutional tokenization and downsampling. Consequently, REViT-v2 reduces the spatial complexity of group-equivariant attention from quadratic to linear in the image area. This design targets large-scale image recognition while maintaining equivariance throughout the feature extractor. We demonstrate its effectiveness through classification results on ImageNet-1K ([3]) and a complexity comparison with global G-CSA.

Windowed Group Convolutional Self-Attention

wG-CSA is a local window extension of G-CSA ((Zaheer et al., 2026)). The aim is to reduce the quadratic complexity of G-CSA in image size to linear complexity.

Equivariant Projections

Let the input to an attention block be a feature map. The channels of input xx are organized according to a representation ρ\rho of a finite planar symmetry group GG, such as the cyclic rotation group pNpN or the dihedral group pNmpNm. Queries, keys, and values are produced by group-equivariant convolutional projections Zaheer et al. (2025):

Q=ϕQ(x),K=ϕK(x),V=ϕV(x),(1)Q = \phi_Q(x), \qquad K = \phi_K(x), \qquad V = \phi_V(x), \tag*{(1)}

The attention output is followed by another group-equivariant projection ϕO\phi_O.

Local Window Attention

The spatial lattice is partitioned into non-overlapping windows, W={W1,…,WK}\mathcal{W} = \{W_1, \ldots, W_K\}, where each window contains M2M^2 positions. Let W(p)W(p) denote the window containing position pp. For head hh, the attention score between pp and q∈W(p)q \in W(p) is

spqh=⟨Qh(p),Kh(q)⟩dh,(2)s_{pq}^{h} = \frac{\left\langle Q^{h}(p), K^{h}(q) \right\rangle}{\sqrt{d_h}}, \tag*{(2)}

where QhQ^h and KhK^h are query and key projections for head hh. The normalized attention coefficient and output are

apqh=exp⁡(spqh)∑r∈W(p)exp⁡(sprh),(3)a_{pq}^{h} = \frac{\exp(s_{pq}^{h})}{\sum_{r \in W(p)} \exp(s_{pr}^{h})}, \tag*{(3)}
Yh(p)=∑q∈W(p)apqhVh(q),(4)Y^{h}(p) = \sum_{q \in W(p)} a_{pq}^{h} V^{h}(q), \tag*{(4)}

where VhV^h is the value projection. Outputs from all heads are concatenated along complete representation fields and projected using ϕO\phi_O:

wG-CSA⁡(x)=ϕO(Concat⁡h=1HYh).(5)\operatorname{wG\text{-}CSA}(x)=\phi_O\left(\operatorname{Concat}_{h=1}^{H}Y^h\right). \tag*{(5)}

No absolute positional embedding is introduced. Spatial structure is instead preserved by the equivariant convolutional stem and the convolutional query, key, and value projections. We demonstrate the equivariance of wG-CSA in Appendix § 6.

Linear Complexity of Windowed G-CSA

For xx of size H×WH \times W, N=HWN=HW denote the number of positions in a feature map. Global attention computes N2N^2 pairwise scores per head and has approximate complexity O(N2C)O(N^2C) [4]. Windowed attention with M×MM \times M sized windows, however, contains N/M2N/M^2 windows, each requiring M4M^4 pairwise comparisons. Its total complexity is therefore

O((N/M2)M4C)=O(NM2C).(6)O\left((N/M^2)M^4C\right)=O(NM^2C). \tag*{(6)}

For fixed MM, the cost is linear in image area.

REViT-v2

REViT-v2 arranges the proposed wG-CSA in a multi-stage feature hierarchy. The early layers need to preserve sufficient spatial resolution to identify local structures, whereas the deeper layers need greater representation capacity and wider effective receptive fields.

Equivariant Patching and Lifting

The input image is interpreted as a field of trivial representations because rotating an image changes spatial positions but does not permute its RGB channels. A group-equivariant convolutional stem lifts this input into regular group representations. Two strided group-equivariant convolutions reduce the image resolution by a factor of four.

Equivariant Transformer Block

Each block contains a pre-normalized wG-CSA module and an equivariant feed-forward network. Given input xlx_l, the block is

zl=xl+DropPath⁡(αlwG-CSA⁡(N1(xl))),(7)z_l=x_l+\operatorname{DropPath}\left(\alpha_l\operatorname{wG\text{-}CSA}(\mathcal{N}_1(x_l))\right), \tag*{(7)}
xl+1=zl+DropPath⁡(βlMG(N2(zl))).(8)x_{l+1}=z_l+\operatorname{DropPath}\left(\beta_l\mathcal{M}_G(\mathcal{N}_2(z_l))\right). \tag*{(8)}

Here, N1\mathcal{N}_1 and N2\mathcal{N}_2 are representation-compatible normalization operations, while αl\alpha_l and βl\beta_l are trainable residual scaling parameters. The equivariant MLP MG\mathcal{M}_G replaces ordinary fully connected layers with 1×11 \times1 group convolutions. DropPath implements stochastic depth. Stochastic depth regularizes the residual branches without independently dropping orientation channels, which would violate their representation structure.

Multistage Hierarchy

After the blocks in each of the first three stages, a strided group convolution reduces the spatial resolution while the number of representation fields is increased. Later stages can therefore use more channels and attention heads without exceeding the cost. At deeper stages, a fixed M×MM \times M window also corresponds to a progressively larger region of the original image. The final stage can therefore model high-level interactions over a substantial portion of the input without constructing a global high-resolution attention matrix.

The hierarchy and local windows address different parts of the scaling problem: windowing eliminates the quadratic dependence on the number of tokens, while downsampling prevents the high-resolution representation from being propagated through the complete network. Together, they provide a practical route toward symmetry-aware ViT backbones for ImageNet-scale classification and, with suitable interfaces, dense prediction tasks.

Experimental Results

Table 1 compares the performance of a p4mp4m-equivariant REViT-v2 with two baselines: a vanilla ViT trained with rotation and flip augmentations and a p4mp4m-equivariant RE-ResNet model. REViT-v2 outperforms both. Additional details are provided in Appendix § 7.

ModelTop-1 Accuracy (%)Top-5 Accuracy (%)Params.
ViT-S w/ aug72.0889.5422 M
RE-ResNet77.3793.7411 M
REViT-v2-T72.5890.885 M
REViT-v2-S79.2794.4518 M
REViT-v2-S80.995.147 M

Table 1. Performance Comparison on ImageNet-1K.

Complexity Comparison with Global G-CSA

Table 2 compares wG-CSA with global G-CSA on Rotated MNIST [6] trained for 200 epochs and a batch size of 128. The proposed windowed architecture substantially reduces model size, forward FLOPs, latency, and peak memory while maintaining comparable accuracy. Since REViT-v2 combines a downsampling stem with hierarchical windowed attention, we also evaluate global attention after the same downsampling stem to distinguish the effect of early downsampling from that of windowed attention.

AttentionParams.Forward FLOPsLatency vs globalPeak Training MemoryAccuracy (%)
Global97.7 K1.69 GFLOPs1×429.7 MB98.23
Global w/downsampling97.7 K333.6 MFLOPs0.75×50.98 MB98.28
Windowed102.9 K80.1 MFLOPs0.61×26.47 MB98.26

Table 2. Comparison with global G-CSA on Rotated MNIST.

Conclusion

In this paper, we demonstrate the effectiveness of REViT-v2 as scalable group-equivariant vision transformers that can serve as backbone feature extractors in the same manner as conventional ViTs. We also provide code and pretrained weights to support further research.

Equivariance Analysis

Theoretical Analysis

Assume that the group representations within a head are orthogonal, as is the case for permutation-based regular representations ([1]) used in this work:

ρh(g)Tρh(g)=I.(9)\rho_h(g)^{\mathsf{T}}\rho_h(g)=I. \tag*{(9)}

Under a transformation gg, the projected features satisfy

Qh′(gp)=ρh(g)Qh(p),Kh′(gq)=ρh(g)Kh(q).(10)Q^{h'}(gp)=\rho_h(g)Q^h(p),\qquad K^{h'}(gq)=\rho_h(g)K^h(q). \tag*{(10)}

Their dot product is therefore unchanged:

⟨Qh′(gp),Kh′(gq)⟩=Qh(p)Tρh(g)Tρh(g)Kh(q)(11)\left\langle Q^{h'}(gp),K^{h'}(gq)\right\rangle =Q^h(p)^{\mathsf{T}}\rho_h(g)^{\mathsf{T}}\rho_h(g)K^h(q) \tag*{(11)}
=⟨Qh(p),Kh(q)⟩.(12)=\left\langle Q^h(p),K^h(q)\right\rangle. \tag*{(12)}

The attention coefficients are consequently permuted consistently with the transformed spatial positions. Since the values transform through the same representation, the output satisfies

Yh′(gp)=ρh(g)Yh(p).(13)Y^{h'}(gp)=\rho_h(g)Y^h(p). \tag*{(13)}

Thus,

wG-CSA(Tgx)=Tg wG-CSA(x),(14)\mathrm{wG\text{-}CSA}(T_gx)=T_g\,\mathrm{wG\text{-}CSA}(x), \tag*{(14)}

provided that the transformation maps complete windows to complete windows:

W(gp)=gW(p).(15)W(gp)=gW(p). \tag*{(15)}

This condition is satisfied by square windows under 90∘90^\circ rotations and axis-aligned reflections when the square feature-map dimensions are divisible by the window size.

Quantitative Analysis

We also evaluated the architectural equivariance of REViT-v2s on the ImageNet validation set through equivariance error analysis.

Definition: For a feature map f(⋅)f(\cdot), the equivariance error is defined as

Eeq=∥f(g⋅x)−g⋅f(x)∥1,(16)\mathcal{E}_{\mathrm{eq}} = \lVert f(g \cdot x) - g \cdot f(x) \rVert_1, \tag*{(16)}

where ∥⋅∥1\lVert\cdot\rVert_1 denotes the mean absolute difference over all spatial locations, channels, and batch elements.

This metric is evaluated at two stages: 1) after the lifting layer (lifting equivariance error) and 2) at the final feature representation after all the G-CSA transformer blocks and immediately preceding the classification head (pre-class equivariance error). In this setting, no trained checkpoint is loaded; the model is randomly initialized, so the experiment isolates equivariance induced by the network design rather than invariance learned through optimization. 1024 images were taken from ImageNet validation set and processed with standard ImageNet evaluation transforms: resize to 256, center cropping to 224x224, and normalization with ImageNet mean and standard deviation.

For each sampled image and each non-identity element of the p4p4, p4mp4m, and p8p8 groups, we compared the network response to the transformed input against the transformed response to the original input. Equivariance was measured at the stem output and immediately before the classification head (after all G-CSA blocks). Table 3 summarizes the results of these equivariance tests. For the p8p8 group, errors accumulate starting at the lifting layer, which we attribute to interpolation artifacts introduced by rotations at angles such as 45∘45^\circ and 135∘135^\circ, where pixel locations fall between the original grid. This results in approximation error at the input level.

GroupLifting Stem Equivariance Err.↓\downarrowPre-Class Equivariance Err.↓\downarrow
p4p40.000142 ±\pm 0.0000170.00218 ±\pm 0.000471
p4mp4m0.001316 ±\pm 0.0006140.00008 ±\pm 0.000034
p8p80.001474 ±\pm 0.0003660.000102 ±\pm 0.000013

Table 3. Equivariance error analysis

Training Setup

REViT-v2 was trained on ImageNet using distributed data parallelism on four Nvidia GeForce RTX 4090 GPUs, with a per-GPU batch size of 128, giving an effective batch size of 512. We optimize the model for 300 epochs with AdamW, using an initial learning rate of 3e-4, weight decay of 0.05, and a learning-rate schedule consisting of 20 epochs of linear warmup followed by cosine decay. The model is instantiated with a window size of 7, and a 3×33 \times3 equivariant kernel for the Q/K/V projections in the attention layers.

References

  1. [1]Gabriele Cesa, Leon Lang, and Maurice Weiler. A program to build E(N)-equivariant steerable CNNs. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=WE4qe9xlnQw.
  2. [2]Taco S. Cohen and Max Welling. Group equivariant convolutional networks. In Proceedings of the 33rd International Conference on Machine Learning, volume 48 of Proceedings of Machine Learning Research, pages 2990–2999. PMLR, 2016. URL https://proceedings.mlr.press/v48/cohenc16.html.arxiv.org/abs/1602.07576
  3. [3]Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255, 2009. doi: 10.1109/CVPR.2009.5206848.DOI
  4. [4]Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=YicbFdNTTy.
  5. [5]Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6824–6835, 2021. URL https://openaccess.thecvf.com/content/ICCV2021/html/Fan_Multiscale_Vision_Transformers_ICCV_2021_paper.html.
  6. [6]H. Larochelle, D. Erhan, Aaron C. Courville, James Bergstra, and Yoshua Bengio. An empirical evaluation of deep architectures on problems with many factors of variation. In International Conference on Machine Learning, 2007. URL https://api.semanticscholar.org/CorpusID:14805281.DOI
  7. [7]Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10012–10022, 2021. URL https://openaccess.thecvf.com/content/ICCV2021/html/Liu_Swin_Transformer_Hierarchical_Vision_Transformer_Using_Shifted_Windows_ICCV_2021_paper.html.arxiv.org/abs/2103.14030
  8. [8]David W. Romero and Jean-Baptiste Cordonnier. Group equivariant stand-alone self-attention for vision. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=JkfYjn0Eo6M.arxiv.org/abs/2010.00977
  9. [9]Maurice Weiler and Gabriele Cesa. General E(2)-equivariant steerable CNNs. In Advances in Neural Information Processing Systems, volume 32, 2019. URL https://proceedings.neurips.cc/paper_files/paper/2019/hash/45d6637b718d0f24a237069fe41b0db4-Abstract.html.arxiv.org/abs/1911.08251

Paper details

vlnc:W_q5994x4q
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents