Models · Promptable segmentation
Segment Anything 2.1 (SAM 2.1), image
Segment Anything 2.1 in image mode: masks from clicks, boxes or mask prompts, in four sizes. Commercially usable.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
sam2.1-hiera-tiny | synthetic (1024x1024) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 66.3 38.0 16.6 13.9 14.2 8.56 (image encoder only) | 622 / 676 577 / 636 304 / 382 316 / 362 270 / 322 266 (engine) |
sam2.1-hiera-small | synthetic (1024x1024) | original (fp32) original portable kernels | 74.8 41.8 18.8 15.6 | 649 / 698 618 / 662 318 / 366 330 / 386 |
sam2.1-hiera-base-plus | synthetic (1024x1024) | original (fp32) original portable kernels | 107 47.2 32.0 25.1 | 830 / 868 823 / 870 412 / 464 426 / 524 |
sam2.1-hiera-large | synthetic (1024x1024) | original (fp32) original portable kernels | 242 86.4 68.0 48.8 | 1474 / 1518 1656 / 1724 742 / 768 760 / 828 |
Details
- Original code: https://github.com/facebookresearch/sam2 at
2b90b9f - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
- Licence evidence: https://github.com/facebookresearch/sam2/blob/main/README.md (License section: model checkpoints and code under Apache 2.0)
- Training data: SA-1B and the SA-V video dataset (plus internal data) per the paper; SA-V itself is under CC BY 4.0, SA-1B under its research licence
- Kernel libraries:
dpt_fused - Variants:
sam2.1-hiera-tiny,sam2.1-hiera-small,sam2.1-hiera-base-plus,sam2.1-hiera-large - 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):
sam2.1-hiera-tiny1080x1920 (0.3 GiB peak allocated, 0.4 reserved);sam2.1-hiera-small1080x1920 (0.3 GiB peak allocated, 0.4 reserved);sam2.1-hiera-base-plus1080x1920 (0.4 GiB peak allocated, 0.6 reserved);sam2.1-hiera-large1080x1920 (0.7 GiB peak allocated, 0.9 reserved) sam2.1-hiera-tiny1024x1024, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 34 s (ONNX + engine).sam2.1-hiera-tinyoriginal 1024x1024: torch.autocast(float16) around the callsam2.1-hiera-smalloriginal 1024x1024: torch.autocast(float16) around the callsam2.1-hiera-base-plusoriginal 1024x1024: torch.autocast(float16) around the callsam2.1-hiera-largeoriginal 1024x1024: torch.autocast(float16) around the callsam2.1-hiera-tinyload / first call: original 0.41 s / 0.147 s, portable 0.25 s / 0.017† s, kernels 0.11† s / 0.014† ssam2.1-hiera-smallload / first call: original 0.48 s / 0.136 s, portable 0.36 s / 0.019† s, kernels 0.13† s / 0.016† ssam2.1-hiera-base-plusload / first call: original 0.74 s / 0.143 s, portable 0.43 s / 0.032† s, kernels 0.19† s / 0.025† ssam2.1-hiera-largeload / first call: original 1.95 s / 0.184 s, portable 1.1 s / 0.068† s, kernels 0.39† s / 0.049† 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 |
|---|---|---|---|---|---|---|
sam2.1-hiera-tiny | COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 57.63 / 57.69 | 57.56 / 57.64 | 57.62 / 57.72 | 57.61 / 57.77 | |
sam2.1-hiera-small | COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 59.39 / 58.46 | 59.34 / 58.42 | 59.38 / 58.49 | 59.38 / 58.47 | |
sam2.1-hiera-base-plus | COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 58.79 / 58.67 | 58.73 / 58.57 | 58.81 / 58.71 | 58.82 / 58.73 | |
sam2.1-hiera-large | COCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask % | 64.88 / 64.71 | 64.77 / 64.73 | 64.86 / 64.68 | 64.87 / 64.70 |
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 |
|---|---|---|---|
sam2.1-hiera-tiny | 0.00122 / 0.00428 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120 |
sam2.1-hiera-small | 0.00539 / 0.01677 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120 |
sam2.1-hiera-base-plus | 0.00245 / 0.00842 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120 |
sam2.1-hiera-large | 0.01872 / 0.08865 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120 |