Models · Promptable segmentation

EfficientViT-SAM

EfficientViT-SAM (MIT Han lab): Segment Anything with a fast convolutional image encoder, in five sizes.

stable Fork of mit-han-lab/efficientvit@de7d773 · backends: portable, kernels

Checkpoint

Paper 2024 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 4.55 ms 1024x1024, fp16
vs the faster original 5.8× original fp16: 26.3 ms
Peak memory 164 MiB original: 211 MiB
Accuracy vs original fp32 +0.14 kernels mIoU best of 3 %, COCO val2017 (54.45 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import promptable_segmentation

model = promptable_segmentation.load("efficientvit-sam-l0")  # kernels on a supported GPU, else portable PyTorch
result = model(image, input_points=...)
result.pred_masks  # also: iou_scores
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench efficientvit-sam-l0

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.

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)fp32 26.90.98×251 MiB/290 MiB2.50.62
Original fp16torch.autocast(float16) around the call; upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)fp16 26.3–211 MiB/232 MiB0.30.82
Portable fp32fp32not measured ––––
Portablefp16 11.12.4×158 MiB/190 MiB1.40.74
Kernelsfp16 4.555.8×164 MiB/236 MiB0.80.24
Portable + torch.compile 6.444.1×188 MiB/228 MiB25 (build)–
TensorRT fp32image encoder onlyfp32 5.564.7×202 MiBenginenot comparable20 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-10 to 2026-11-16. 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

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-12Originalfp3270.5 1,959 MiB process–1024x1024
Portablefp3250.6 1,779 MiB processmatches1024x1024
Kernelsfp16not implemented–1024x1024

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 LICENSELICENSE-segment-anything
Weights
Apache-2.0 source
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

Our reading of the licences, not legal advice.

Weights

efficientvit_sam_l0.pt 139 MB· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download efficientvit-sam-l0).

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.

COCO val2017

every 10th image, point prompts, mIoU best of 3 / single mask %

RundtypemIoU best of 3 % ↑mIoU single % ↑Δ mIoU best of 3 % vs fp32 originalimagesms / image
Original fp32fp3254.4550.57 reference 500 21.8
Original fp16fp1654.6050.50 +0.15 500 18.8
Portable fp32fp3254.6250.57 +0.17 500 –
Portablefp1654.5850.54 +0.13 500 15.8
Kernelsfp1654.5950.52 +0.14 500 11.2

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 authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-10; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17.

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| <= 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).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 (relative)not recorded
GPU default dtypes, mean |diff|≤ 0.025 (relative)0.00977 (relative)
GPU default dtypes, p99 |diff|≤ 0.073 (relative)0.02641 (relative)

Recorded for efficientvit-sam-l0 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-10, with these kernels: fvm_convfvm_extrafvm_mbfvm_r3

Details

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.

Input / output
Input: one image plus a point, box or text prompt. Output: masks with quality scores.
Input size
any H x W >= 1, resized inside to the fixed encoder input 1024x1024 (the default export size); tested up to 1080x1920 (180 MiB allocated)
Outputs
pred_masks, iou_scores
Checkpoint
arch="l0", input_size=512
CUDA kernels
  • fvm_convfused convolutions for image classifiers
  • fvm_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

Limitations

  • Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~85 MiB above portable (peak allocated is not); `cuda_graphs=false` or `release_graphs()` frees it.
Full reference, generated from the repository

EfficientViT-SAM (MIT Han lab): Segment Anything with a fast convolutional image encoder, in five sizes.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
efficientvit-sam-l0synthetic (1024x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp32
26.9
26.3
11.1
4.55
6.44
5.56 (image encoder only)
251 / 290
211 / 232
158 / 190
164 / 236
188 / 228
404 / 428
efficientvit-sam-l1synthetic (1024x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp32
30.1
29.9
14.4
5.47
11.3
7.30 (image encoder only)
300 / 316
260 / 278
183 / 234
191 / 264
212 / 252
517 / 578
efficientvit-sam-l2synthetic (1024x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp32
34.4
34.4
17.8
6.54
10.8
9.65 (image encoder only)
352 / 382
313 / 344
209 / 240
219 / 292
238 / 278
633 / 690
efficientvit-sam-xl0synthetic (1024x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp32
46.9
28.2
19.0
9.75
14.2
22.7 (image encoder only)
814 / 828
654 / 670
433 / 506
401 / 492
397 / 424
1288 / 1328
efficientvit-sam-xl1synthetic (1024x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp32
72.6
40.9
28.9
15.3
22.9
38.4 (image encoder only)
1143 / 1182
984 / 1022
586 / 676
569 / 686
562 / 616
1894 / 1960
Details
  • Original code: https://github.com/mit-han-lab/efficientvit at de7d7733cc03
  • Code licence: Apache-2.0 (permissive); files: LICENSE, LICENSE-segment-anything
  • Weights licence: Apache-2.0
  • 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
  • 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
  • Kernel libraries: fvm_conv, fvm_extra, fvm_mb, fvm_r3
  • Variants: efficientvit-sam-l0, efficientvit-sam-l1, efficientvit-sam-l2, efficientvit-sam-xl0, efficientvit-sam-xl1
  • Outputs: pred_masks, iou_scores
  • 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)
  • efficientvit-sam-l0 1024x1024, first call: portable + torch.compile 25 s (cold Inductor cache), TensorRT fp32 20 s (ONNX + engine).
  • efficientvit-sam-l1 1024x1024, first call: portable + torch.compile 25 s (cold Inductor cache), TensorRT fp32 22 s (ONNX + engine).
  • efficientvit-sam-l2 1024x1024, first call: portable + torch.compile 26 s (cold Inductor cache), TensorRT fp32 24 s (ONNX + engine).
  • efficientvit-sam-xl0 1024x1024, first call: portable + torch.compile 24 s (cold Inductor cache), TensorRT fp32 30 s (ONNX + engine).
  • efficientvit-sam-xl1 1024x1024, first call: portable + torch.compile 27 s (cold Inductor cache), TensorRT fp32 37 s (ONNX + engine).
  • efficientvit-sam-l0 original (fp32) 1024x1024: upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-l0 original 1024x1024: torch.autocast(float16) around the call; upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-l1 original (fp32) 1024x1024: upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-l1 original 1024x1024: torch.autocast(float16) around the call; upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-l2 original (fp32) 1024x1024: upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-l2 original 1024x1024: torch.autocast(float16) around the call; upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-xl0 original (fp32) 1024x1024: upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-xl0 original 1024x1024: torch.autocast(float16) around the call; upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-xl1 original (fp32) 1024x1024: upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-xl1 original 1024x1024: torch.autocast(float16) around the call; upstream EfficientViTSamPredictor.set_image + predict (centre point, multimask_output=True)
  • efficientvit-sam-l0 load / first call: original 0.35 s / 0.817 s, portable 1.36 s / 0.743 s, kernels 0.81 s / 0.239 s
  • efficientvit-sam-l1 load / first call: original 0.31 s / 0.032 s, portable 0.86 s / 0.667 s, kernels 0.9 s / 0.235 s
  • efficientvit-sam-l2 load / first call: original 0.39 s / 0.037 s, portable 0.93 s / 0.667 s, kernels 1.0 s / 0.24 s
  • efficientvit-sam-xl0 load / first call: original 0.62 s / 0.592 s, portable 2.67 s / 0.519 s, kernels 2.14 s / 0.259 s
  • efficientvit-sam-xl1 load / first call: original 1.06 s / 0.041 s, portable 3.24 s / 0.531 s, kernels 3.21 s / 0.238 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

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.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
efficientvit-sam-l0COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %54.45 / 50.5754.60 / 50.5054.58 / 50.5454.62 / 50.5754.59 / 50.52
efficientvit-sam-l1COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %55.48 / 51.2655.38 / 51.0655.37 / 51.0155.44 / 51.2255.42 / 51.08
efficientvit-sam-l2COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %56.50 / 52.2356.58 / 52.2956.44 / 52.2556.33 / 52.2056.34 / 52.22
efficientvit-sam-xl0COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %59.00 / 54.4758.90 / 54.4858.99 / 54.5159.01 / 54.4858.90 / 54.51
efficientvit-sam-xl1COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %59.38 / 54.8459.33 / 54.8459.40 / 54.8559.45 / 54.8459.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

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).

variantkernels error vs original, mean / p99GPU, torchkernels used
efficientvit-sam-l00.00977 / 0.02641RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
efficientvit-sam-l10.0096 / 0.03486RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
efficientvit-sam-l20.01609 / 0.04618RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
efficientvit-sam-xl00.00539 / 0.01405RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
efficientvit-sam-xl10.00311 / 0.00859RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120

Limitations

  • Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~85 MiB above portable (peak allocated is not); cuda_graphs=false or release_graphs() frees it.

Example output

One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti). Prompt: one foreground point.

Input
Output
A cup of coffee, input
Input · 100%

Input: A cup of coffee, Rachel Michetti (CC0).