Models · Promptable segmentation
Segment Anything (SAM)
Segment Anything: masks from clicks, boxes or mask prompts, in sizes B, L and H. Commercially usable.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
sam-vit-b | synthetic (1024x1024) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 168 98.2 48.3 37.0 40.9 27.3 (image encoder only) | 2798 / 2832 1769 / 1802 378 / 420 377 / 420 362 / 400 322 (engine) |
sam-vit-l | synthetic (1024x1024) | original (fp32) original portable kernels | 406 197 116 81.5 | 4428 / 4474 3411 / 3464 833 / 1262 831 / 862 |
sam-vit-h | synthetic (1024x1024) | original (fp32) original portable kernels | 734 306 214 143 | 5702 / 5754 5295 / 5404 1484 / 2524 1480 / 1524 |
Details
- Original code: https://github.com/facebookresearch/segment-anything at
dca509f - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
- Licence evidence: https://github.com/facebookresearch/segment-anything/blob/main/README.md (License section: model checkpoints and code under Apache 2.0)
- Training data: 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:
dpt_fused - Variants:
sam-vit-b,sam-vit-l,sam-vit-h - 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):
sam-vit-b1080x1920 (0.4 GiB peak allocated, 0.5 reserved);sam-vit-l1080x1920 (0.8 GiB peak allocated, 1.0 reserved);sam-vit-h1080x1920 (1.5 GiB peak allocated, 1.9 reserved) sam-vit-b1024x1024, first call: portable + torch.compile 15 s (cold Inductor cache), TensorRT fp16 36 s (ONNX + engine).sam-vit-boriginal 1024x1024: torch.autocast(float16) around the callsam-vit-loriginal 1024x1024: torch.autocast(float16) around the callsam-vit-horiginal 1024x1024: torch.autocast(float16) around the callsam-vit-bload / first call: original 0.75 s / 0.176 s, portable 0.46 s / 0.048† s, kernels 0.17† s / 0.037† ssam-vit-lload / first call: original 1.8 s / 0.268 s, portable 1.21 s / 0.116† s, kernels 0.43† s / 0.081† ssam-vit-hload / first call: original 4.61 s / 0.376 s, portable 2.45 s / 0.214† s, kernels 0.89† s / 0.143† s- † measured in the speed sweep after the portable load (or an earlier size) in the same process: file cache and kernels are warm, so the time is lower than a fresh start.
- Protocol, median of 5 after 3 warm-up, uint8 CUDA input (synthetic for bench_inputs sizes), card defaults; gc before each load; peak = max over the first call and the timed calls
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.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
sam-vit-b | COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 52.91 / 50.31 | 53.08 / 50.39 | 52.91 / 50.31 | 52.89 / 50.32 | |
sam-vit-l | COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 57.89 / 53.32 | 57.76 / 53.31 | 57.84 / 53.32 | 57.85 / 53.33 | |
sam-vit-h | COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 57.93 / 53.13 | 57.92 / 53.13 | 57.97 / 53.12 | 57.99 / 53.12 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Parity
CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 3 % and p99 <= 15 % of the reference's median |value| (absolute error of the output pred_masks).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
sam-vit-b | 0.00044 / 0.00203 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120 |
sam-vit-l | 0.01589 / 0.06758 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120 |
sam-vit-h | 0.00329 / 0.01177 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120 |