EfficientFormer
EfficientFormer (Li et al. 2022, Snap Research; L1, L3, L7; distilled on ImageNet-1k): a hybrid of pooling blocks and transformer blocks built for phone latency. Apache-2.0.
experimental Fork of huggingface/pytorch-image-models@0df212b · backends: portable, kernels
- Paper EfficientFormer: Vision Transformers at MobileNet Speed NeurIPS 2022 · first released 2 Jun 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.3.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("efficientformer_l1.snap_dist_in1k") # fastest backend that runs here
result = model("photo.jpg")
# result fields: logits
logits = result.logits # a torch tensor
arrays = result.numpy() # the tensor fields as NumPy arrays: arrays["logits"]
result.backend # what ran: mode, device, dtype
Other ways to run it
- Backend:
classification.load("efficientformer_l1.snap_dist_in1k", mode="kernels") # or "portable", "auto" (default) - Precision:
classification.load("efficientformer_l1.snap_dist_in1k", dtype="float32") # full precision: slower, portable only
fastforks bench efficientformer_l1.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 | 4.87 | – | 87 MiB/98 MiB | 3.8 | 0.35 |
| Original fp16torch.autocast(float16) around the call | fp16 | 6.40 | 0.76× | 104 MiB/124 MiB | 0.2 | 0.22 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 3.72 | 1.3× | 93 MiB/104 MiB | 1.7 | 0.07 |
| KernelsExisting CUDA kernel mode on one fixed input with five warm calls. | fp16 | 0.704 | 6.9× | 91 MiB/126 MiB | 2.0 | 0.07 |
| Portable + torch.compile | 1.69 | 2.9× | 125 MiB/144 MiB | 9 (build) | – | |
| TensorRT fp16 | fp16 | 0.335 | 15× | 38 MiBenginenot comparable | 35 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-11 to 2026-11-19. First call, 2 warm-up, peak reset, median of 1 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 | Load / first call (s) | Output vs reference | Input |
|---|---|---|---|---|---|---|---|
| NVIDIA runs on Linux and Windows | |||||||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-29 | Portable | fp16 | 7.24 | 69 MiB/84 MiB | 6.3 / 0.2 | matches | 224x224 |
| Kernels | fp16 | 1.11 | 68 MiB/106 MiB | 4.6 / 0.2 | matches | 224x224 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-30 | Portable | fp16 | 4.24 | 69 MiB/84 MiB | 5.2 / 0.1 | matches | 224x224 |
| Kernels | fp16 | 0.839 | 68 MiB/106 MiB | 3.4 / 0.1 | matches | 224x224 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-30 | Portable | fp16 | 3.56 | 69 MiB/84 MiB | 4.1 / 0.1 | matches | 224x224 |
| Kernels | fp16 | 0.971 | 68 MiB/106 MiB | 2.6 / 0.1 | matches | 224x224 | |
| Apple silicon runs on macOS | |||||||
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-25 | Original | fp32 | 12.5 | 550 MiB process | 6.4 / 0.1 | – | 224x224 |
| Portable | fp16 | 9.34 | 581 MiB process | 1.4 / 0.1 | matches | 224x224 | |
| Portable | fp32 | 9.36 | 551 MiB process | 1.5 / 0.0 | matches | 224x224 | |
| Kernels | fp16 | not implemented | – | – | 224x224 | ||
| Kernels | fp32 | not implemented | – | – | 224x224 | ||
| Apple M1 Pro 16 GB (MLX, fp16) MLX, torch 2.14.1, 2026-11-26 | Portable | fp16 | 4.35 | 397 MiB process | 1.0 / 0.0 | matches | 224x224 |
| Portable | fp32 | 4.62 | 418 MiB process | 1.1 / 0.1 | matches | 224x224 | |
| Kernels | fp16 | 3.96 | 405 MiB process | 0.9 / 0.0 | matches | 224x224 | |
| Kernels | fp32 | 4.25 | 421 MiB process | 0.8 / 0.0 | matches | 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
efficientformer_l1.snap_dist_in1k.safetensors 49.3 MB· hosted on Hugging Facefastforks downloads and checks these files on first use (fastforks download efficientformer_l1.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 | 81.14 | 95.22 | reference | 5000 | 0.897 |
| Original fp16 | fp16 | 81.16 | 95.24 | +0.02 | 5000 | 0.612 |
| Portable fp32 | fp32 | 81.14 | 95.14 | ±0.00 | 5000 | 0.911 |
| Portable | fp16 | 81.14 | 95.12 | ±0.00 | 5000 | 0.503 |
| Kernels | fp16 | 81.12 | 95.12 | −0.02 | 5000 | 0.458 |
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; kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 0e3805948, 2026-11-20.
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| <= 1.3e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0046 and p99 <= 0.019 (absolute error of the output logits).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.000013 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.0046 | 0.00293 |
| GPU default dtypes, p99 |diff| | ≤ 0.019 | 0.01165 |
Recorded for efficientformer_l1.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
EfficientFormer (Li et al. 2022, Snap Research): a hybrid classifier, pooling blocks on feature maps followed by transformer blocks on tokens.
- 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 (93 MiB allocated)
- Outputs
logits- Checkpoint
arch="efficientformer_l1.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
EfficientFormer (Li et al. 2022, Snap Research; L1, L3, L7; distilled on ImageNet-1k): a hybrid of pooling blocks and transformer blocks built for phone latency. Apache-2.0.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
efficientformer_l1.snap_dist_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 4.87 6.40 3.72 0.704 1.69 0.335 | 87 / 98 104 / 124 93 / 104 91 / 126 125 / 144 128 / 142 |
efficientformer_l3.snap_dist_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 8.39 11.0 6.37 1.21 2.57 0.750 | 164 / 172 214 / 236 161 / 216 160 / 218 193 / 216 227 / 286 |
efficientformer_l7.snap_dist_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 12.3 15.9 9.65 2.04 3.69 1.40 | 363 / 378 505 / 522 300 / 324 298 / 346 332 / 364 460 / 490 |
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/efficientformer_l1.snap_dist_in1k/blob/8738a58190800aaf5995f453b05f643df453a565/README.md
- Training data: ImageNet-1k (ILSVRC 2012 classification)
- Kernel libraries:
cudnn_hacc,fvm_conv,fvm_extra,fvm_mb,fvm_r3 - Variants:
efficientformer_l1.snap_dist_in1k(default ofefficientformer_l1),efficientformer_l3.snap_dist_in1k(default ofefficientformer_l3),efficientformer_l7.snap_dist_in1k(default ofefficientformer_l7) - 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):
efficientformer_l1.snap_dist_in1k224x224 (0.1 GiB peak allocated, 0.1 reserved);efficientformer_l3.snap_dist_in1k224x224 (0.2 GiB peak allocated, 0.2 reserved);efficientformer_l7.snap_dist_in1k224x224 (0.3 GiB peak allocated, 0.3 reserved) efficientformer_l1.snap_dist_in1k224x224, first call: portable + torch.compile 9 s (cold Inductor cache), TensorRT fp16 35 s (ONNX + engine).efficientformer_l3.snap_dist_in1k224x224, first call: portable + torch.compile 12 s (cold Inductor cache), TensorRT fp16 39 s (ONNX + engine).efficientformer_l7.snap_dist_in1k224x224, first call: portable + torch.compile 14 s (cold Inductor cache), TensorRT fp16 40 s (ONNX + engine).efficientformer_l1.snap_dist_in1koriginal 224x224: torch.autocast(float16) around the callefficientformer_l1.snap_dist_in1kkernels 224x224: Existing CUDA kernel mode on one fixed input with five warm calls.efficientformer_l3.snap_dist_in1koriginal 224x224: torch.autocast(float16) around the callefficientformer_l3.snap_dist_in1kkernels 224x224: Existing CUDA kernel mode on one fixed input with five warm calls.efficientformer_l7.snap_dist_in1koriginal 224x224: torch.autocast(float16) around the callefficientformer_l7.snap_dist_in1kkernels 224x224: Existing CUDA kernel mode on one fixed input with five warm calls.efficientformer_l1.snap_dist_in1kload / first call: original 0.22 s / 0.219 s, portable 1.71 s / 0.071 s, kernels 1.99 s / 0.072 sefficientformer_l3.snap_dist_in1kload / first call: original 0.37 s / 0.029 s, portable 1.86 s / 0.076 s, kernels 2.28 s / 0.055 sefficientformer_l7.snap_dist_in1kload / first call: original 0.93 s / 0.03 s, portable 2.27 s / 0.074 s, kernels 2.87 s / 0.057 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 | kernels | note |
|---|---|---|---|---|---|---|---|
efficientformer_l1.snap_dist_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 81.14 / 95.22 | 81.16 / 95.24 | 81.14 / 95.12 | 81.14 / 95.14 | 81.12 / 95.12 | |
efficientformer_l3.snap_dist_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 83.12 / 96.32 | 83.14 / 96.32 | 83.16 / 96.32 | 83.16 / 96.32 | 83.16 / 96.32 | |
efficientformer_l7.snap_dist_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 84.44 / 96.68 | 84.44 / 96.66 | 84.38 / 96.68 | 84.38 / 96.66 | 84.40 / 96.68 |
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; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 0e3805948, 2026-11-20.
Parity
CPU, float32: max |diff| <= 1.3e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0046 and p99 <= 0.019 (absolute error of the output logits).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
efficientformer_l1.snap_dist_in1k | 0.00293 / 0.01165 | 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 |
efficientformer_l3.snap_dist_in1k | 0.00344 / 0.01248 | 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 |
efficientformer_l7.snap_dist_in1k | 0.00193 / 0.00768 | 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).