File size: 5,094 Bytes
75a79cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734e879
75a79cf
 
 
 
 
734e879
 
 
 
 
 
 
75a79cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734e879
75a79cf
 
 
 
 
 
734e879
75a79cf
 
 
 
 
 
 
 
 
 
734e879
6c9cdb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
library_name: "fastforks"
pipeline_tag: "image-classification"
license: "apache-2.0"
tags:
- "classification"
- "image-classification"
- "cuda"
- "pytorch"
- "fastforks"
---
# EfficientViT (MIT) (fastforks)

EfficientViT (Cai et al. 2023, MIT Han lab): MBConv stages with multi-scale ReLU linear attention.

This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: <https://github.com/kleinicke/fastforks>. Kernels for the `kernels` backend: <https://huggingface.co/fastforks/kernels>. Original code: <https://github.com/huggingface/pytorch-image-models> at `0df212b369a5`.

Author weight repos: <https://huggingface.co/timm/efficientvit_b2.r288_in1k>.

Task: classification. Tier: stable. Outputs: `logits`. Backends: `portable`, `kernels`.

Input: one RGB image. Output: ImageNet-1k class logits.

## Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/classification/models/efficientvit/card.toml).

| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `efficientvit_b2.r288_in1k@1` | [efficientvit_b2.r288_in1k.safetensors](https://huggingface.co/timm/efficientvit_b2.r288_in1k/resolve/891530d0c5a400dd2d4549c81d433661b192abe1/model.safetensors) | `f5726851b5c5` | Apache-2.0 | yes |

## Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: .

Training data: ImageNet-1k (ILSVRC 2012 classification).

Licence evidence: <https://huggingface.co/timm/efficientvit_b2.r288_in1k/blob/891530d0c5a400dd2d4549c81d433661b192abe1/README.md>

## Input size

fixed 288x288: the input is resized (short side 288) and centre-cropped to it
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `efficientvit_b2.r288_in1k` 288x288 (0.1 GiB peak allocated, 0.1 reserved)

## Speed and memory

### Classification, synthetic, 224x224

| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `efficientvit_b2.r288_in1k` | 10.67 | 14.66 | 11.9 | 1.105 | 9.7x | 10.8x | 173 / 194 | 85 / 124 | 120 / 212 |

### Startup and first call

| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `efficientvit_b2.r288_in1k` | 1.84 | 0.40 | 1.92 | 1.89 | 0.04 | 0.05 |

### torch.compile and TensorRT

| model | input | portable ms | compile ms | compile s (cold) | TensorRT fp16 ms | ONNX + build s | kernels ms | peak MiB (alloc / reserved): portable | compile | TensorRT (device) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `efficientvit_b2.r288_in1k` | 224x224 | 11.9 | 6.9 | 11.0 | 0.7 | 39 | 1.105 | 85 / 124 | 120 / 164 | 72 |

### Fixed-size speed and peak memory, all models

| model | mode | 224x224 |
| --- | --- | --- |
| `efficientvit_b2.r288_in1k` | portable | 11.9 ms / 87 / 116 |
| `efficientvit_b2.r288_in1k` | kernels | 1.2 ms / 122 / 200 |

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code at the precision of portable (fp16, or `(fp32)` where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.

## Accuracy

### Parity with the original code

Every variant is checked against golden outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.2 (absolute error of the output `logits`).

## Usage

```python
from fastforks import classification

model = classification.load("efficientvit_b2.r288_in1k")  # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg")
result.top(5)  # top-5 classes
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
```

Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `efficientvit_b2.r288_in1k`.

## Kernels backend

`classification.load("efficientvit_b2.r288_in1k", mode="kernels")` runs our CUDA kernels (`cudnn_hacc`, `fvm_conv`, `fvm_extra`, `fvm_mb`, `fvm_r3`). It needs a prebuilt kernel for your GPU architecture (downloaded from <https://huggingface.co/fastforks/kernels> on first use) and a recent NVIDIA driver; if there is none it raises `BackendUnavailableError` with the reason and never falls back silently. `mode="auto"` picks `kernels` when it can run and logs the choice.

<!-- staged from fastforks 03e6fdbc (2026-11-05) -->