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
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.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 695 | 0.36× | 3,865 MiB/3,934 MiB | – | – |
| Original fp16Transformers FP16 weights, FP16 inputs; original adapter casting hooks; 500-image COCO accuracy checked | fp16 | 254 | – | 2,052 MiB/2,124 MiB | 1.4 | 0.26 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 179 | 1.4× | 1,910 MiB/1,984 MiB | 3.9 | 0.30 |
| Kernels | fp16 | 117 | 2.2× | 1,974 MiB/2,264 MiB | 4.0 | 0.20 |
| Portable + torch.compile | 168 | 1.5× | 1,910 MiB/2,004 MiB | 20 (build) | – | |
| TensorRT fp16image encoder only | fp16 | 89.5 | 2.8× | 1,122 MiBenginenot comparable | 54 (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
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-12 | Original | fp32 | 2203 | 4,842 MiB process | matches | 1024x1024 |
| Portable | fp16 | 3688 | 3,523 MiB process | matches | 1024x1024 | |
| Portable | fp32 | 3620 | 5,807 MiB process | matches | 1024x1024 | |
| Kernels | fp16 | not implemented | – | 1024x1024 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 197 | 1,886 MiB/1,964 MiB | – | 1024x1024 |
| Kernels | fp16 | 161 | 1,926 MiB/2,144 MiB | – | 1024x1024 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 72.2 | 1,886 MiB/1,964 MiB | – | 1024x1024 |
| Kernels | fp16 | 48.6 | 1,926 MiB/2,144 MiB | – | 1024x1024 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 151 | 1,886 MiB/1,964 MiB | – | 1024x1024 |
| Kernels | fp16 | 136 | 1,927 MiB/2,144 MiB | – | 1024x1024 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 69.7 | 1,886 MiB/1,964 MiB | – | 1024x1024 |
| Kernels | fp16 | 50.8 | 1,926 MiB/2,144 MiB | – | 1024x1024 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 33.4 | 1,910 MiB/1,984 MiB | – | 1024x1024 |
| Kernels | fp16 | 29.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.
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
| Run | dtype | box mAP ↑ | mask mAP ↑ | Δ box mAP vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 52.54 | 44.56 | reference | 500 | 876 |
| Original fp16 | fp16 | 52.54 | 44.54 | ±0.00 | 500 | 394 |
| Portable fp32 | not measured | |||||
| Portable | fp16 | 52.79 | 45.13 | +0.25 | 500 | 238 |
| Kernels | fp16 | 52.83 | 45.14 | +0.29 | 500 | 164 |
| Original .half() | fp16 | 52.38 | 44.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).
| Check | Tolerance | Measured |
|---|---|---|
| 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 backbonescudnn_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.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
sam3 | synthetic (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):
sam31080x1920 (1.9 GiB peak allocated, 2.1 reserved) sam31024x1024, first call: portable + torch.compile 20 s (cold Inductor cache), TensorRT fp16 54 s (ONNX + engine).sam3original 1024x1024: Transformers FP16 weights, FP16 inputs; original adapter casting hooks; 500-image COCO accuracy checkedsam3load / 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.
| variant | dataset | original fp32 | original fp16 | original half | portable | kernels | note |
|---|---|---|---|---|---|---|---|
sam3 | COCO val2017, every 10th image, class-name prompts, box / mask mAP | 52.54 / 44.56 | 52.54 / 44.54 | 52.38 / 44.54 | 52.79 / 45.13 | 52.83 / 45.14 | original = 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).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
sam3 | 0.13462 / 0.7662 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_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=falseorrelease_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".
- cup 0.95
Input: A cup of coffee, Rachel Michetti (CC0).