Models · Promptable segmentation

Segment Anything 3 (SAM 3), image + video tracker

Segment Anything 3: masks for every object that matches a text or example prompt, as well as clicks and boxes. Meta's SAM License applies; commercially usable under it.

stable Fork of facebookresearch/sam3@0570b3a · backends: portable, kernels

  • Paper SAM 3: Segment Anything with Concepts arXiv · first released 20 Nov 2025
  • Authors’ code facebookresearch/sam3 (PyTorch), not the code forked here: The benchmarked original is the Hugging Face transformers Sam3Model (video: Sam3TrackerVideoModel), which loads the same checkpoint without the repo's training dependencies.

Checkpoint sam3

Paper 2025 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 117 ms 1024x1024, fp16
vs the faster original 2.2× original fp16: 254 ms
Peak memory 1,974 MiB original: 2,052 MiB
Accuracy vs original fp32 +0.29 kernels box mAP, COCO val2017 (52.54 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("sam3")  # kernels on a supported GPU, else portable PyTorch
result = model(image, input_points=...)
result.boxes  # also: scores, masks
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench sam3

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 fp32fp32 6950.36×3,865 MiB/3,934 MiB––
Original fp16Transformers FP16 weights, FP16 inputs; original adapter casting hooks; 500-image COCO accuracy checkedfp16 254–2,052 MiB/2,124 MiB1.40.26
Portable fp32fp32not measured ––––
Portablefp16 1791.4×1,910 MiB/1,984 MiB3.90.30
Kernelsfp16 1172.2×1,974 MiB/2,264 MiB4.00.20
Portable + torch.compile 1681.5×1,910 MiB/2,004 MiB20 (build)–
TensorRT fp16image encoder onlyfp16 89.52.8×1,122 MiBenginenot comparable54 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-17. 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-12Originalfp322203 4,842 MiB processmatches1024x1024
Portablefp163688 3,523 MiB processmatches1024x1024
Portablefp323620 5,807 MiB processmatches1024x1024
Kernelsfp16not implemented–1024x1024
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16197 1,886 MiB/1,964 MiB–1024x1024
Kernelsfp16161 1,926 MiB/2,144 MiB–1024x1024
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1672.2 1,886 MiB/1,964 MiB–1024x1024
Kernelsfp1648.6 1,926 MiB/2,144 MiB–1024x1024
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16151 1,886 MiB/1,964 MiB–1024x1024
Kernelsfp16136 1,927 MiB/2,144 MiB–1024x1024
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1669.7 1,886 MiB/1,964 MiB–1024x1024
Kernelsfp1650.8 1,926 MiB/2,144 MiB–1024x1024
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1633.4 1,910 MiB/1,984 MiB–1024x1024
Kernelsfp1629.5 1,974 MiB/2,224 MiB–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
LicenseRef-SAM-License AND Apache-2.0 LICENSELICENSE-transformers
Weights
LicenseRef-SAM-License source
Training data
the SA-Co data engine's image and video annotations plus public and internal datasets per the paper; not released as one dataset
  • The weights use Meta's SAM License, not Apache-2.0; its terms were not re-checked here.

Our reading of the licences, not legal advice.

Weights

model.safetensors 3.4 GB· hosted on Hugging Face
vocab.json 862 KB· hosted on Hugging Face
merges.txt 525 KB· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download sam3).

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, class-name prompts, box / mask mAP

Rundtypebox mAP ↑mask mAP ↑Δ box mAP vs fp32 originalimagesms / image
Original fp32fp3252.5444.56 reference 500 876
Original fp16fp1652.5444.54 ±0.00 500 394
Portable fp32not measured
Portablefp1652.7945.13 +0.25 500 238
Kernelsfp1652.8345.14 +0.29 500 164
Original .half()fp1652.3844.54 −0.16 500 345

One text prompt (the COCO class name) per class in the image; the top 100 instances go to pycocotools COCOeval. Original = the authors’ code (original = transformers `Sam3Model`, the port this code follows), same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; original .half(): RTX 5060 Ti, torch 2.14.1+cu130, 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.0005 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.35 and p99 <= 2.0 (absolute error of the output boxes).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.0005 not recorded
GPU default dtypes, mean |diff|≤ 0.35 0.13462
GPU default dtypes, p99 |diff|≤ 2 0.7662

Recorded for sam3 on RTX 5060 Ti, torch 2.10.0+cu130, 2026-11-17, with these kernels: cudnn_haccdpt_fusedfastbb

Details

Segment Anything 3 (Meta, 2025), image mode: promptable concept segmentation, every instance matching a text and / or exemplar-box prompt (positive / negative boxes; returns boxes, scores, masks). A ViT trunk with an FPN neck, a CLIP text encoder, a geometry encoder, a DETR encoder / decoder with a presence token and a mask decoder. `video` follows objects prompted on the first frame (points, boxes or masks) through a video with SAM 3's tracker (transformers `Sam3TrackerVideoModel`: the shared ViT trunk, its own neck, SAM 2-style memory attention with RoPE and memory encoder, forward, memory features in bfloat16 as upstream); the memory side has no fused kernels. 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 1008x1008 (the default export size); tested up to 1080x1920 (1,948 MiB allocated)
Outputs
boxes, scores, masks
CUDA kernels
  • fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbones
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
  • dpt_fusedfused fp16 matrix multiplies and convolutions for DINOv2 backbones and DPT depth heads
Apple (MPS)
fp32, fp16

Limitations

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

Segment Anything 3: masks for every object that matches a text or example prompt, as well as clicks and boxes. Meta's SAM License applies; commercially usable under it.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
sam3synthetic (1024x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
695
254
179
117
168
89.5 (image encoder only)
3865 / 3934
2052 / 2124
1910 / 1984
1974 / 2264
1910 / 2004
2926 / 2944
Details
  • Original code: https://github.com/facebookresearch/sam3 at 0570b3a
  • Code licence: LicenseRef-SAM-License AND Apache-2.0 (permissive); files: LICENSE, LICENSE-transformers
  • Weights licence: LicenseRef-SAM-License
  • Licence evidence: https://huggingface.co/facebook/sam3/blob/main/LICENSE (SAM License, Nov 19 2025); the weights are gated: download them from Meta's Hugging Face repo after accepting the licence and point FASTFORKS_WEIGHTS_PATH at the local copy; fastforks never mirrors them
  • Training data: the SA-Co data engine's image and video annotations plus public and internal datasets per the paper; not released as one dataset
  • Licence note: The weights use Meta's SAM License, not Apache-2.0; its terms were not re-checked here.
  • Kernel libraries: fastbb, cudnn_hacc, dpt_fused
  • Variants: sam3
  • Outputs: boxes, scores, masks
  • Input size: any H x W >= 1, resized inside to the fixed encoder input 1008x1008 (the default export size)
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): sam3 1080x1920 (1.9 GiB peak allocated, 2.1 reserved)
  • sam3 1024x1024, first call: portable + torch.compile 20 s (cold Inductor cache), TensorRT fp16 54 s (ONNX + engine).
  • sam3 original 1024x1024: Transformers FP16 weights, FP16 inputs; original adapter casting hooks; 500-image COCO accuracy checked
  • sam3 load / first call: original 1.35 s / 0.256 s, portable 3.85 s / 0.18 s (840x1297), kernels 4.03 s / 0.116 s (840x1297)
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

One text prompt (the COCO class name) per class in the image; the top 100 instances go to pycocotools COCOeval. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16original halfportablekernelsnote
sam3COCO val2017, every 10th image, class-name prompts, box / mask mAP52.54 / 44.5652.54 / 44.5452.38 / 44.5452.79 / 45.1352.83 / 45.14original = transformers Sam3Model, the port this code follows

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Parity

CPU, float32: max |diff| <= 0.0005 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.35 and p99 <= 2.0 (absolute error of the output boxes).

variantkernels error vs original, mean / p99GPU, torchkernels used
sam30.13462 / 0.7662RTX 5060 Ti, torch 2.10.0+cu130cudnn_hacc@cudnn91501, dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120

Limitations

  • Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~300 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: text "cup".

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

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