Paper commentary
RepVGG: Making VGG-style ConvNets Great Again
Plain VGG-style networks can match multi-branch accuracy when trained with side branches
- Problem Multi-branch networks like ResNet are accurate but slow and memory-hungry at inference. Earlier plain networks without branches could not reach their accuracy.
- Method RepVGG trains with identity and 1×1 side branches, then folds every branch and batch normalization layer into one 3×3 convolution. Instead of keeping the branches, it deploys a plain stack of 3×3 convolutions with ReLU.
- Results RepVGG-B3 reached 80.52 top-1 accuracy on ImageNet when trained for 200 epochs. That is the first time a plain model passed 80 percent, to the authors' knowledge.
Why plain networks were set aside
Multi-branch designs such as residual addition in ResNet and branch concatenation in Inception raise accuracy but are harder to implement and customize, slow inference and use memory less efficiently. Plain networks avoid these costs, yet earlier attempts to train them without branches mainly aimed at making very deep models converge, and the resulting accuracy stayed below the complicated models.
The open question is whether a plain network with a simple topology can reach the accuracy of multi-branch networks while keeping its speed advantage.
Speed is the second concern: lower FLOPs do not guarantee faster inference, so the paper compares models by measured throughput rather than by operation counts.
Training with branches, deploying without them
RepVGG has two forms of one network: a training-time form in which every 3×3 convolution sits beside an identity branch and a 1×1 branch, and an inference-time form built only from 3×3 convolutions followed by ReLU. The side branches are borrowed from ResNet, but they are used only during training and are removed before deployment.
The authors argue that a multi-branch block behaves like an implicit ensemble of shallower models, which helps training, while the branch-joining operations cost time and memory at inference. Within a block, the output is the input plus the 1×1 branch output plus the 3×3 branch output, with the identity term included only when the input and output shapes match.
Removing the branches is possible because an identity mapping can be written as a 1×1 convolution with an identity matrix as its kernel, and a 1×1 convolution can be written as a 3×3 convolution with zeros around the center.
Folding batch normalization and branches
Each branch passes its convolution output through its own batch normalization layer before the branches are summed, so the block output is the sum of three normalized branch outputs, with the identity term present only when the channel counts and spatial sizes of the input and output agree. The batch normalization at inference is an affine map per output channel, built from the stored mean, standard deviation, scale and bias.
Each batch normalization layer and the convolution before it are merged into one convolution with a bias: the kernel of each output channel is multiplied by its learned scale divided by its standard deviation, and the bias absorbs the mean and the shift. The identity branch is handled the same way, since it is a 1×1 convolution whose kernel is the identity matrix.
The two 1×1 kernels are zero-padded to 3×3 and added to the center of the 3×3 kernel, and the three bias vectors are summed into a single bias, so the block becomes one 3×3 convolution. The equivalence requires the 3×3 and 1×1 layers to share the same stride, and the 1×1 layer has to use one pixel less padding than the 3×3 layer, so a 3×3 layer with padding 1 pairs with a 1×1 layer with padding 0.
Why a 3×3-only body runs fast
In a speed test with batch size 32, 2048 input and output channels, 56×56 resolution and stride 1 on a 1080Ti, 3×3 convolution reaches 38.10 theoretical TFLOPS, while 1×1 convolution reaches 9.96. Theoretical FLOPs alone therefore cannot rank operators by their real speed.
The Winograd algorithm cuts the multiplications of a stride-1 3×3 convolution, and the paper counts these multiplications as Wino MULs. With the F(2×2, 3×3) variant the multiplications drop to 49 of the original. Whether a given operator is accelerated depends on the library and hardware, because small convolutions may not gain from it.
The gap is attributed to memory access cost and degree of parallelism. A prior work counted 13 fragmented operators in one NASNET-A building block, against 2 or 3 in ResNets and 1 in RepVGG. Residual branches also keep their inputs alive until the addition, so their peak memory is about twice the input, whereas a plain layer can release its input immediately.
Stage layout and width scaling
RepVGG arranges its 3×3 layers in five stages, with the first layer of each stage downsampling by stride 2, and it uses no max pooling so that the body has only one operator type. The layer counts follow three guidelines: the first stage is kept to one layer for latency, the last stage to one layer to limit parameters, and most layers go to the second-to-last stage at 14×14 resolution.
RepVGG-A uses 1, 2, 4, 14, 1 layers across the five stages, and RepVGG-B adds layers to stages 2, 3 and 4 to form a deeper variant. Widths follow the classic setting of 64, 128, 256 and 512 scaled by a multiplier a for the first four stages and by b for the last one, with b usually larger than a. Stage 1 is scaled down when a is below 1 but not scaled up, so its width is min(64, 64a).
Table 3 instantiates this rule: RepVGG-A0 uses a of 0.75 and b of 2.5, RepVGG-B0 uses a of 1 and b of 2.5, and RepVGG-B3 uses a of 3 and b of 5. Some 3×3 layers can use groupwise convolution with 1, 2 or 4 groups, applied to the 3rd, 5th and later layers of RepVGG-A and to the additional layers of RepVGG-B, with the 1×1 branch sharing the same group count.
ImageNet classification results
The lightweight models use ImageNet-1K, which has 1.28M training images and 50K validation images, and are trained for 120 epochs with random cropping and left-right flipping. The heavyweight models are trained for 200 epochs with label smoothing, mixup and Autoaugment, and the baselines are the authors' own implementations under the same settings.
RepVGG-A0 reaches 72.41 top-1 at 3256 examples/second, above ResNet-18 at 71.16 and 2442 examples/second. Within the 120-epoch group RepVGG-A1 reaches 74.46 against 74.17 for ResNet-34, and RepVGG-A2 reaches 76.48 against 76.31 for ResNet-50, with speeds of 1322 against 719 examples/second for the ResNet-50 comparison. The text puts RepVGG-A0 at 1.25% higher accuracy and 33% higher speed than ResNet-18, and RepVGG-A2 at 0.17% higher accuracy and 83% higher speed than ResNet-50.
The headline claim is that RepVGG models run 83% faster than ResNet-50 and 101% faster than ResNet-101 on a 1080Ti GPU with higher accuracy. Grouped variants trade a little accuracy for more speed: RepVGG-B1g4 is 0.37% more accurate and 101% faster than ResNet-101.
At 200 epochs RepVGG-B3 reaches 80.52 top-1 at 363 examples/second, RepVGG-B3g4 reaches 80.21 at 464, and RepVGG-B2g4 reaches 79.38, while RegNetX-12GF reaches 80.55 at 277. The authors state that RepVGG-B3 runs 31% faster than RegNetX-12GF, and that the 80% level at 200 epochs is the first time a plain model reaches it, to their knowledge.
Against the highest-accuracy VGG reported with RePr, 74.5%, RepVGG-B2 is 4.28% higher.
Ablations on the re-parameterization
On RepVGG-B0 trained for 120 epochs, removing both the identity and the 1×1 branch gives 72.39 top-1, the 1×1 branch alone gives 73.15, the identity branch alone gives 74.79, and the full structure gives 75.14. Before conversion, the full structure runs at 1061 examples/second, against 1810 for the model with no side branches, so the branches have a speed cost in the unconverted form.
Several variants test whether the exact BN placement and branch design matter: removing the BN from the identity branch gives 74.18, moving BN after the addition gives 73.52, and inserting ReLU in each branch gives 75.69. The ReLU variant scores higher than the full model, but it cannot be merged into one convolution, so it has no deployment value.
The variants built from kernel re-parameterization are DiracNet at 73.97, Trivial Re-param at 73.51, ACB at 73.58 and Residual Reorg at 74.56, all below the full structure at 75.14.
The authors read these results as showing that the trained BN-with-branch dataflow matters, and that equivalence at inference does not imply equivalence in training. ACB uses more parameters yet performs worse, which the authors take as evidence against a simple over-parameterization explanation.
When every 3×3 convolution of ResNet-50 is replaced with a RepVGG block and trained for 120 epochs, the accuracy is 76.34%, which is 0.03% above the ResNet-50 baseline of 76.31. Residual Reorg, which has a similar count of 3×3 convolutions and real shortcuts, is 0.58% below RepVGG-B0, and the authors attribute the gap to RepVGG's far larger number of branches.
Cityscapes segmentation
Only the ResNet-50 and ResNet-101 backbones are replaced by RepVGG-B1g2 and RepVGG-B2, so the rest of the setup stays the same.
The RepVGG-B2 backbone reaches 80.57 mean IoU and 96.50 mean pixel accuracy on the validation subset, at 4.5 examples/second with batch size 16 and 713×713 input.
Dilated convolutions in the last two stages follow PSPNet, but the dilated 3×3 implementation is slow, so the fast variants dilate only the last five layers. Dilation adds 1.05% mean IoU to RepVGG-B2 at a reasonable cost in speed, which the authors read as dilation helping larger models more.
Limitations
RepVGG is designed for maximum speed on GPU and specialized hardware and pays less attention to parameter count. For low-power devices, the mobile-regime models MobileNets and ShuffleNets may be preferred.
The benefit on specialized inference chips is argued from the design, and no measurement on such a chip is reported. All speed figures come from a 1080Ti GPU in fp32 with cuDNN 7.5.0, and the accuracy comparisons rely on the authors' reimplemented baselines.
Paper info
- Authors
- Xiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, Jian Sun
- Venue
- arXiv · Preprint
- First published
- 2021-1-11
- Added
- 2026-11-12
- Updated
- 2021-3-29
- Version
- v3
- arXiv
- 2101.03697
- Category
- cs.CV · cs.AI · cs.LG
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Xiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, Jian Sun (2021). RepVGG: Making VGG-style ConvNets Great Again. arXiv:2101.03697v3. https://arxiv.org/abs/2101.03697v3
BibTeX
@misc{ding2021repvgg,
title = {{RepVGG: Making VGG-style ConvNets Great Again}},
author = {Xiaohan Ding and Xiangyu Zhang and Ningning Ma and Jungong Han and Guiguang Ding and Jian Sun},
year = {2021},
eprint = {2101.03697},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2101.03697v3}
}