EfficientViT-SAM (fastforks)
EfficientViT-SAM (Zhang, Cai et al. 2024, MIT Han lab): Segment Anything with the ViT-H image encoder replaced by an EfficientViT (conv stages + ReLU linear attention) distilled from it; SAM's prompt encoder and mask decoder, so points, boxes and mask logits work the same. The portable module() is the image encoder only.
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/mit-han-lab/efficientvit at de7d7733cc03.
Author weight repos: https://huggingface.co/mit-han-lab/efficientvit-sam.
Task: promptable_segmentation. Tier: stable. Outputs: pred_masks, iou_scores. Backends: portable, kernels.
Input: one image plus a point, box or text prompt. Output: masks with quality scores.
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
efficientvit-sam-l0@1 |
efficientvit_sam_l0.pt | c4f994b01a16 |
Apache-2.0 | yes |
efficientvit-sam-l1@1 |
efficientvit_sam_l1.pt | fa151df2b9b9 |
Apache-2.0 | yes |
efficientvit-sam-l2@1 |
efficientvit_sam_l2.pt | d4bfd842224c |
Apache-2.0 | yes |
efficientvit-sam-xl0@1 |
efficientvit_sam_xl0.pt | 9bc2f87bd23d |
Apache-2.0 | yes |
efficientvit-sam-xl1@1 |
efficientvit_sam_xl1.pt | 10f422776794 |
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. Licence files: LICENSE, LICENSE-segment-anything.
Training data: distilled from SAM ViT-H, then trained on SA-1B (11M licensed images, 1.1B automatically generated masks) per the paper; the dataset itself is under the SA-1B research licence.
Licence evidence: https://huggingface.co/mit-han-lab/efficientvit-sam/blob/a2f0c5929196a13ef1ffc9338d3f9e482e1e0e68/README.md (license: apache-2.0, with LICENSE.txt); code: https://github.com/mit-han-lab/efficientvit/blob/de7d7733cc0329f391b33f1f459271562ec27bd5/LICENSE
Input size
any H x W >= 1, resized inside to the fixed encoder input 1024x1024 (the default export size)
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): efficientvit-sam-l0 1080x1920 (0.2 GiB peak allocated, 0.2 reserved); efficientvit-sam-l1 1080x1920 (0.2 GiB peak allocated, 0.2 reserved); efficientvit-sam-l2 1080x1920 (0.2 GiB peak allocated, 0.3 reserved); efficientvit-sam-xl0 1080x1920 (0.4 GiB peak allocated, 0.5 reserved); efficientvit-sam-xl1 1080x1920 (0.6 GiB peak allocated, 0.7 reserved)
Speed and memory
Promptable segmentation, synthetic, 1024x1024
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|
efficientvit-sam-l0 |
26.9 | 26.3 | 11.1 | 4.55 | 5.8x | 2.4x | 211 / 232 | 158 / 190 | 164 / 236 |
efficientvit-sam-l1 |
30.1 | 29.9 | 14.4 | 5.47 | 5.5x | 2.6x | 260 / 278 | 183 / 234 | 191 / 264 |
efficientvit-sam-l2 |
34.4 | 34.4 | 17.8 | 6.54 | 5.3x | 2.7x | 313 / 344 | 209 / 240 | 219 / 292 |
efficientvit-sam-xl0 |
46.9 | 28.2 | 19.0 | 9.75 | 2.9x | 1.9x | 654 / 670 | 433 / 506 | 401 / 492 |
efficientvit-sam-xl1 |
72.6 | 40.9 | 28.9 | 15.3 | 2.7x | 1.9x | 984 / 1022 | 586 / 676 | 569 / 686 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
efficientvit-sam-l0 |
0.35 | 1.36 | 0.81 | 0.82 | 0.74 | 0.24 |
efficientvit-sam-l1 |
0.31 | 0.86 | 0.90 | 0.03 | 0.67 | 0.23 |
efficientvit-sam-l2 |
0.39 | 0.93 | 1.00 | 0.04 | 0.67 | 0.24 |
efficientvit-sam-xl0 |
0.62 | 2.67 | 2.14 | 0.59 | 0.52 | 0.26 |
efficientvit-sam-xl1 |
1.06 | 3.24 | 3.21 | 0.04 | 0.53 | 0.24 |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT (fp16 unless shown) | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|---|---|---|---|---|---|---|---|---|---|---|---|
efficientvit-sam-l0 |
1024x1024 | 11.1 ms | 6.44 ms | 5.56 ms, fp32 engine (image encoder only) | 4.55 ms | 25.2 s | 19.9 s | 158 / 190 | 188 / 228 | 164 / 236 | 404 / 428 |
efficientvit-sam-l1 |
1024x1024 | 14.4 ms | 11.3 ms | 7.30 ms, fp32 engine (image encoder only) | 5.47 ms | 24.8 s | 22.0 s | 183 / 234 | 212 / 252 | 191 / 264 | 517 / 578 |
efficientvit-sam-l2 |
1024x1024 | 17.8 ms | 10.8 ms | 9.65 ms, fp32 engine (image encoder only) | 6.54 ms | 26.1 s | 24.1 s | 209 / 240 | 238 / 278 | 219 / 292 | 633 / 690 |
efficientvit-sam-xl0 |
1024x1024 | 19.0 ms | 14.2 ms | 22.7 ms, fp32 engine (image encoder only) | 9.75 ms | 24.0 s | 29.8 s | 433 / 506 | 397 / 424 | 401 / 492 | 1288 / 1328 |
efficientvit-sam-xl1 |
1024x1024 | 28.9 ms | 22.9 ms | 38.4 ms, fp32 engine (image encoder only) | 15.3 ms | 26.7 s | 36.6 s | 586 / 676 | 562 / 616 | 569 / 686 | 1894 / 1960 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above 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
On public datasets
One point per ground-truth instance (the interior point farthest from the border); IoU of the best-scored of 3 masks / of the single mask. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
efficientvit-sam-l0 |
COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 54.45 / 50.57 | 54.60 / 50.50 | 54.58 / 50.54 | 54.62 / 50.57 | 54.59 / 50.52 | |
efficientvit-sam-l1 |
COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 55.48 / 51.26 | 55.38 / 51.06 | 55.37 / 51.01 | 55.44 / 51.22 | 55.42 / 51.08 | |
efficientvit-sam-l2 |
COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 56.50 / 52.23 | 56.58 / 52.29 | 56.44 / 52.25 | 56.33 / 52.20 | 56.34 / 52.22 | |
efficientvit-sam-xl0 |
COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 59.00 / 54.47 | 58.90 / 54.48 | 58.99 / 54.51 | 59.01 / 54.48 | 58.90 / 54.51 | |
efficientvit-sam-xl1 |
COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 59.38 / 54.84 | 59.33 / 54.84 | 59.40 / 54.85 | 59.45 / 54.84 | 59.43 / 54.85 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-10; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-10.
Parity with the original code
Every variant is checked against reference 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| <= 2.5 % and p99 <= 7.3 % of the reference's median |value| (absolute error of the output pred_masks).
Limitations
- On the RTX 5060 Ti at 3840 ร 2160 with 12 point prompts and 36 output masks, EfficientViT-SAM L0 used 621 MiB portable and 626 MiB kernels, down from 1,546 and 1,552 MiB. Masks, scores and logits matched bit for bit. Paired latency was 37.0 to 38.6 ms portable and 35.3 to 36.9 ms kernels.
- Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~90 MiB above portable at 1024 x 1024 (280 vs 190 MiB, RTX 5060 Ti, Windows; peak allocated is not);
cuda_graphs=falseorrelease_graphs()frees it.
Usage
from fastforks import promptable_segmentation
model = promptable_segmentation.load("efficientvit-sam-l0") # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg", input_points=[[x, y]], input_labels=[1])
result.masks # [M, H, W] bool
# SAM 3 (text prompts): model("photo.jpg", text="coin") -> boxes, scores, masks
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-sam-l0, efficientvit-sam-l1, efficientvit-sam-l2, efficientvit-sam-xl0, efficientvit-sam-xl1.
Kernels backend
promptable_segmentation.load("efficientvit-sam-l0", mode="kernels") runs our CUDA kernels (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.
Model tree for fastforks/efficientvit-sam
Base model
mit-han-lab/efficientvit-sam