EfficientFormerV2
EfficientFormerV2 (Li et al. 2022, Snap Research; S0, S1, S2, L; distilled on ImageNet-1k): a mobile hybrid of convolutions and attention. Apache-2.0.
experimental Fork of huggingface/pytorch-image-models@0df212b · backends: portable, kernels
- Paper Rethinking Vision Transformers for MobileNet Size and Speed ICCV 2023 · first released 15 Dec 2022
- Authors’ code snap-research/EfficientFormer (PyTorch), not the code forked here: timm carries the architecture and the converted authors' checkpoints in its own, simpler API.
Paper 2022 Added in 0.2.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install "fastforks-core[timm]"
from fastforks import classification
model = classification.load("efficientformerv2_s0.snap_dist_in1k") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.logits
result.backend # what ran: mode, device, dtype, kernels fastforks bench efficientformerv2_s0.snap_dist_in1k Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
Input: synthetic, 224x224 (the task’s standard size)
| Backend | dtype | Time per call (ms) | vs original fp32 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 8.16 | – | 55 MiB/62 MiB | 3.2 | 0.36 |
| Original fp16torch.autocast(float16) around the call | fp16 | 11.8 | 0.69× | 55 MiB/64 MiB | 0.2 | 1.76 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 7.62 | 1.1× | 44 MiB/64 MiB | 1.9 | 0.50 |
| Kernels | not measured | – | – | – | – | |
| Portable + torch.compile | 3.34 | 2.4× | 76 MiB/104 MiB | 11 (build) | – | |
| TensorRT fp16 | fp16 | 0.550 | 15× | 36 MiBenginenot comparable | 36 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-11. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | 21.0 | 483 MiB process | – | 224x224 |
| Portable | fp16 | 14.9 | 559 MiB process | matches | 224x224 | |
| Portable | fp32 | 13.9 | 510 MiB process | matches | 224x224 | |
| Kernels | fp32 | not implemented | – | 224x224 | ||
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Commercial use allowed
- Code
- Apache-2.0
- Weights
- Apache-2.0 source
- Training data
-
- ImageNet-1k (ILSVRC 2012 classification) noncommercial, non-commercial
Our reading of the licences, not legal advice.
Weights
efficientformerv2_s0.snap_dist_in1k.safetensors 14.7 MB· hosted on Hugging Facefastforks downloads and checks these files on first use (fastforks download efficientformerv2_s0.snap_dist_in1k).
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
ImageNet-1k val
5000 random images, top-1 / top-5 %
| Run | dtype | top-1 % ↑ | top-5 % ↑ | Δ top-1 % vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 77.04 | 92.94 | reference | 5000 | 1.26 |
| Original fp16 | fp16 | 77.00 | 92.76 | −0.04 | 5000 | 1.18 |
| Portable fp32 | fp32 | 77.02 | 92.88 | −0.02 | 5000 | 1.82 |
| Portable | fp16 | 77.34 | 92.82 | +0.30 | 5000 | 0.943 |
| Kernels | not measured | |||||
fastforks: the model's own resize / crop on the GPU; original: the library's pretrained loader and its PIL eval transform. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-11; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1, 2026-11-17; portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7ba7307f, 2026-11-11.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 4.7e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.12 and p99 <= 0.42 (absolute error of the output logits).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.000047 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.12 | 0.04356 |
| GPU default dtypes, p99 |diff| | ≤ 0.42 | 0.13661 |
Recorded for efficientformerv2_s0.snap_dist_in1k on RTX 5060 Ti, torch 2.10.0+cu130, 2026-11-17, with these kernels: cudnn_haccfvm_convfvm_extrafvm_mbfvm_r3
Details
EfficientFormerV2 (Li et al. 2022, Snap Research): a mobile hybrid classifier, convolutional stages with attention in the last two.
- Input / output
- Input: one RGB image. Output: ImageNet-1k class logits.
- Input size
- fixed 224x224: the input is resized (short side 235) and centre-cropped to it; tested up to 224x224 (44 MiB allocated)
- Outputs
logits- Checkpoint
arch="efficientformerv2_s0.snap_dist_in1k"- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)fvm_convfused convolutions for image classifiersfvm_extrafused transformer row operations (rotary split, SwiGLU with LayerNorm)fvm_mbfused MBConv blocks (MobileNet and EfficientNet families)fvm_r3further fused classifier blocks
- Apple (MPS)
- fp32, fp16
Full reference, generated from the repository
EfficientFormerV2 (Li et al. 2022, Snap Research; S0, S1, S2, L; distilled on ImageNet-1k): a mobile hybrid of convolutions and attention. Apache-2.0.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
efficientformerv2_s0.snap_dist_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 8.16 11.8 7.62 – 3.34 0.550 | 55 / 62 55 / 64 44 / 64 – 76 / 104 78 / 100 |
efficientformerv2_s1.snap_dist_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 10.1 14.9 8.91 – 3.91 0.632 | 65 / 72 70 / 80 50 / 88 – 82 / 108 86 / 126 |
efficientformerv2_s2.snap_dist_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 15.2 21.8 13.9 – 5.55 0.919 | 91 / 116 108 / 116 64 / 104 – 96 / 124 100 / 142 |
efficientformerv2_l.snap_dist_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 19.9 29.0 17.1 – 7.32 1.20 | 145 / 168 186 / 198 93 / 144 – 125 / 184 161 / 214 |
Details
- Original code: https://github.com/huggingface/pytorch-image-models at
0df212b369a5 - Code licence: Apache-2.0 (permissive); files:
- Weights licence: Apache-2.0
- Licence evidence: https://huggingface.co/timm/efficientformerv2_s0.snap_dist_in1k/blob/aa226e91a076e760bc7957e5990f19f6ae322c5f/README.md
- Training data: ImageNet-1k (ILSVRC 2012 classification)
- Kernel libraries:
cudnn_hacc,fvm_conv,fvm_extra,fvm_mb,fvm_r3 - Variants:
efficientformerv2_s0.snap_dist_in1k(default ofefficientformerv2_s0),efficientformerv2_s1.snap_dist_in1k(default ofefficientformerv2_s1),efficientformerv2_s2.snap_dist_in1k(default ofefficientformerv2_s2),efficientformerv2_l.snap_dist_in1k(default ofefficientformerv2_l) - Outputs: logits; label_set:
imagenet-1k - Input size: fixed 224x224: the input is resized (short side 235) and centre-cropped to it
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
efficientformerv2_s0.snap_dist_in1k224x224 (0.0 GiB peak allocated, 0.1 reserved);efficientformerv2_s1.snap_dist_in1k224x224 (0.0 GiB peak allocated, 0.1 reserved);efficientformerv2_s2.snap_dist_in1k224x224 (0.1 GiB peak allocated, 0.1 reserved);efficientformerv2_l.snap_dist_in1k224x224 (0.1 GiB peak allocated, 0.1 reserved) efficientformerv2_s0.snap_dist_in1k224x224, first call: portable + torch.compile 11 s (cold Inductor cache), TensorRT fp16 36 s (ONNX + engine).efficientformerv2_s1.snap_dist_in1k224x224, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 41 s (ONNX + engine).efficientformerv2_s2.snap_dist_in1k224x224, first call: portable + torch.compile 16 s (cold Inductor cache), TensorRT fp16 39 s (ONNX + engine).efficientformerv2_l.snap_dist_in1k224x224, first call: portable + torch.compile 21 s (cold Inductor cache), TensorRT fp16 45 s (ONNX + engine).efficientformerv2_s0.snap_dist_in1koriginal 224x224: torch.autocast(float16) around the callefficientformerv2_s1.snap_dist_in1koriginal 224x224: torch.autocast(float16) around the callefficientformerv2_s2.snap_dist_in1koriginal 224x224: torch.autocast(float16) around the callefficientformerv2_l.snap_dist_in1koriginal 224x224: torch.autocast(float16) around the callefficientformerv2_s0.snap_dist_in1kload / first call: original 0.17 s / 1.757 s, portable 1.88 s / 0.502 sefficientformerv2_s1.snap_dist_in1kload / first call: original 0.19 s / 0.586 s, portable 1.96 s / 0.433 sefficientformerv2_s2.snap_dist_in1kload / first call: original 0.24 s / 0.861 s, portable 2.68 s / 0.438 sefficientformerv2_l.snap_dist_in1kload / first call: original 0.32 s / 0.73 s, portable 2.74 s / 0.432 s- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Measured
fastforks: the model's own resize / crop on the GPU; original: the library's pretrained loader and its PIL eval transform. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | note |
|---|---|---|---|---|---|---|
efficientformerv2_s0.snap_dist_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 77.04 / 92.94 | 77.00 / 92.76 | 77.34 / 92.82 | 77.02 / 92.88 | |
efficientformerv2_s1.snap_dist_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 80.80 / 95.00 | 81.02 / 94.88 | 80.88 / 95.00 | 80.84 / 95.06 | |
efficientformerv2_s2.snap_dist_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 83.22 / 96.28 | 83.10 / 96.34 | 83.18 / 96.30 | 83.22 / 96.24 | |
efficientformerv2_l.snap_dist_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 83.88 / 96.58 | 83.96 / 96.58 | 84.02 / 96.50 | 83.98 / 96.62 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7ba7307f, 2026-11-11; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1, 2026-11-17.
Parity
CPU, float32: max |diff| <= 4.7e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.12 and p99 <= 0.42 (absolute error of the output logits).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
efficientformerv2_s0.snap_dist_in1k | 0.04356 / 0.13661 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
efficientformerv2_s1.snap_dist_in1k | 0.02079 / 0.06618 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
efficientformerv2_s2.snap_dist_in1k | 0.0744 / 0.27361 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
efficientformerv2_l.snap_dist_in1k | 0.01908 / 0.07145 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
Example output
One fixed input through this checkpoint, the same for every model of the task (portable · float16 · NVIDIA GeForce RTX 5060 Ti).
Top 5
Input: Chelsea the cat, Stéfan van der Walt (CC0).