Meta SAM 3 Playground

Fix · SAM 3 / 3.1 · video speed

Meta SAM Video Tracking Is Slow Know what speed to expect, find which stage is slow on your machine, check the hardware, change the settings that matter, and measure every change the same way so the gains are real.

one frame
Animation of the time spent on one video frameA bar shows the time for one frame split into decoding, image encoding, detection, tracking, post-processing and saving. With many objects the tracking part is longest. Upgrading to SAM 3.1 shrinks tracking, and using bfloat16 with fewer, smaller frames shrinks encoding, so the frame finishes much sooner. time per frame → encodetrackslowmany objects · SAM 3 · fp32 · full-size frames encodetrackfasterSAM 3.1 Object Multiplex: tracking shrinks trackfastest+ bf16, lower resolution, masks saved later decodeencodedetecttrackpostsave find the biggest block on your machine before changing settings illustrative proportions, not measurements
Illustration: where time goes in one frame.

Reference points

How Fast Should It Be?

Meta’s published figures are on data-centre GPUs. Use them to judge whether you’re far off, not as a target for a laptop.

multi-GPU
Animation of real-time object counts by number of GPUsBars grow for the number of objects Meta reports SAM 3 can track in real time: about 5 on one H200, 10 on two, 28 on four and 64 on eight. objects tracked in real time (Meta, SAM 3) 1×H200~52×H200104×H200288×H20064 data-centre GPUs with parallel inference; consumer GPUs track fewer
Meta’s reported real-time object counts.
Setup (Meta)Reported
SAM 3 image, H200~30 ms with 100+ objects
SAM 3 video, 1× H200Near real-time for ~5 objects; slower as objects increase
SAM 3 video, 2 / 4 / 8× H200Real-time for 10 / 28 / 64 objects
SAM 3.1, H100, medium object count16 → 32 FPS
SAM 3.1, 128 objects, H100~7× faster than SAM 3

The paper’s own controlled comparison reports a smaller 5.2× at 128 objects and a few percent overhead for a single object. Your GPU, clip and settings will differ, so measure.

Diagnosis

Where the Time Goes

Each frame passes through the same stages. Only one of them grows with the number of objects.

objects vs time
Animation of tracking time growing with object countFor one object, two objects and twelve objects, SAM 3 adds one tracker block per object, so the bar for twelve objects is long. SAM 3.1 tracks up to sixteen objects in one shared pass, so its bar stays short. tracker work per frame 1 objectSAM 3SAM 3.14 objectsSAM 3SAM 3.112 objectsSAM 3SAM 3.1 SAM 3: one tracker pass per object · SAM 3.1: up to 16 per pass
Illustration of tracker work vs object count.
  • Decode: reading frames from the video; CPU work.
  • Encode: the image encoder runs on every frame; grows with resolution.
  • Detect: finds matches for text prompts; grows with prompt count.
  • Track: grows with objects in SAM 3; much less in SAM 3.1.
  • Post-process and save: full-size masks and writing files, often forgotten and often slow.
  • Time each stage with the Stages helper in the benchmark script.

Hardware

Hardware Checks

Before changing settings, make sure the GPU is actually doing the work at full speed.

GPU utilisation
Animation of GPU utilisation patternsTwo GPU utilisation graphs. A spiky line that mostly sits low means the GPU is waiting on the CPU: decoding frames, Python overhead or saving files. A flat line near 100 percent means the GPU itself is the limit, so only lighter settings or a faster GPU will help. 100%0 spiky and low → CPU-boundfix: faster decoding, fewer Python steps, save later flat near 100% → GPU-boundfix: SAM 3.1, bf16, lower resolution, fewer objects capped well below 100% → throttling or shared GPUfix: power mode, cooling, other processes time →
Illustration of utilisation patterns.
  • On the GPU at all? torch.cuda.is_available() must be True; CPU runs take minutes per clip.
  • Watch it run: nvidia-smi -l 1 (or nvtop) shows utilisation, clocks, power and temperature.
  • Spiky, low utilisation: CPU-bound. Decode with a faster reader, pre-extract frames, and don’t save inside the loop.
  • Low clocks or capped power: laptop on battery or power-saving mode, overheating, or a power limit.
  • Shared GPU: other notebooks, browsers or jobs on the same card.
  • Memory pressure: near-full VRAM forces slow paths; see out of memory.
  • GPU class matters: requirements and tiers in system requirements.

Settings

Settings That Change Speed

Ordered by typical impact. Change one at a time and re-measure.

Measured reported by Meta · Documented in official code or docs · Standard general practice

SettingSpeeds upTrade-offEvidence
Upgrade to SAM 3.1Tracking with several objectsUpgrade work; check tool supportMeasured 16 → 32 FPS (H100); ~7× at 128 objects
Track fewer objects / promptsTracking and detectionLess coverageMeasured SAM 3 latency scales with objects
Lower frame rate before trackingEverything, per second of videoLess temporal detailStandard
Lower resolution / image_sizeEncodingSmall objects sufferDocumented Transformers image_size
bfloat16Most GPU workTiny precision changeDocumented used in official examples
torch.compileSteady-state speedSlow first run; warm upDocumented improved in SAM 3.1
Save masks after, not duringPost-process and saveMore RAM or disk stagingStandard
Keep frames on GPU (if memory allows)Avoids CPU↔GPU copiesMore VRAMMeasured Meta, SAM 2: offloading cost 27 → 24 FPS
More GPUsReal-time object countCost, setupMeasured 10 / 28 / 64 objects on 2 / 4 / 8× H200

Code

Settings in Code

official sam3 · SAM 3.1

# SAM 3.1 video predictor with speed options (names as in the current sam3 code;
# check model_builder.py and the SAM 3.1 notebook for your commit)
from sam3.model_builder import build_sam3_multiplex_video_predictor

predictor = build_sam3_multiplex_video_predictor(
    compile=True,          # torch.compile: slow first run, faster afterwards
    max_num_objects=16,    # objects per multiplex bucket
    # use_fa3=True,        # FlashAttention 3: Hopper GPUs (H100/H200) with FA3 installed
)

Transformers · SAM 3 video

# Transformers SAM 3 video: lighter settings
import torch
from transformers import Sam3VideoConfig, Sam3VideoModel

config = Sam3VideoConfig.from_pretrained("facebook/sam3")
config.image_size = 560                       # documented: faster inference / lower memory
model = Sam3VideoModel.from_pretrained("facebook/sam3", config=config).to("cuda", dtype=torch.bfloat16)

ffmpeg · resample the clip

# resample before tracking: lower frame rate and resolution, cut to the part you need
ffmpeg -ss 00:01:00 -t 20 -i input.mp4 -vf "fps=10,scale=-2:720" -c:v libx264 -crf 18 clip_10fps_720p.mp4

FlashAttention 3 needs a Hopper GPU and the FA3 package; leave it off elsewhere. Upgrade steps: upgrade to SAM 3.1. Full pipeline: video segmentation with Python.

Reproducible measurements

Measure Speed the Same Way Every Time

Without a fixed method, “it feels faster” is noise. Warm up, repeat, take the median, record the environment.

benchmark
Animation of a reproducible benchmark runA benchmark runs the same clip four times. The first warm-up run is slow because of loading and compilation and is discarded. The next three timed runs are similar; the median of the three is reported along with the spread and the environment. warm-up41.8 s · discardedrun 125.1 srun 224.6 srun 325.5 s median 25.1 s · 600 frames → 23.9 FPS · spread 3.6% example numbers
Illustration of a benchmark run.
  1. 1Fix the input:one clip (e.g. 20 s, 720p), one prompt, stored with your results.
  2. 2Warm up once:loading, CUDA start-up and compilation are not tracking speed.
  3. 3Time three or more runswith the GPU synchronised before reading the clock.
  4. 4Report the median and spread;over ~10% spread means something else is competing.
  5. 5Change one thing,re-run, compare medians.

Script

Benchmark Script

Works with any pipeline: pass a function that processes the clip once.

bench_video.py

# bench_video.py: reproducible timing for any SAM video pipeline
import json, platform, statistics, subprocess, time
from contextlib import contextmanager
from importlib import metadata

def sync():
    try:
        import torch
        if torch.cuda.is_available():
            torch.cuda.synchronize()          # GPU work is async; wait before reading the clock
    except ImportError:
        pass

def env_info():
    info = {"python": platform.python_version(), "os": platform.platform()}
    for pkg in ["torch", "sam3", "transformers", "ultralytics"]:
        try:
            info[pkg] = metadata.version(pkg)
        except metadata.PackageNotFoundError:
            pass
    try:
        import torch
        info["cuda"] = torch.version.cuda
        if torch.cuda.is_available():
            info["gpu"] = torch.cuda.get_device_name(0)
    except ImportError:
        pass
    try:
        q = "driver_version,clocks.sm,clocks.max.sm,power.draw,temperature.gpu,utilization.gpu"
        info["nvidia_smi"] = subprocess.run(["nvidia-smi", f"--query-gpu={q}", "--format=csv,noheader"],
                                            capture_output=True, text=True, timeout=10).stdout.strip()
    except Exception:
        pass
    return info

class Stages:
    """with stages("track"): ...   accumulates seconds per stage"""
    def __init__(self):
        self.seconds = {}
    @contextmanager
    def __call__(self, name):
        sync(); t = time.perf_counter()
        yield
        sync(); self.seconds[name] = self.seconds.get(name, 0.0) + time.perf_counter() - t

def bench(run, frames, warmup=1, repeats=3, out=None, **settings):
    for _ in range(warmup):                   # loading, CUDA init, torch.compile happen here
        run(); sync()
    times = []
    for _ in range(repeats):
        sync(); t = time.perf_counter()
        run()
        sync(); times.append(time.perf_counter() - t)
    med = statistics.median(times)
    result = {**settings, "frames": frames, "runs_s": [round(x, 3) for x in times],
              "median_s": round(med, 3), "fps": round(frames / med, 2),
              "spread_pct": round(100 * (max(times) - min(times)) / med, 1), "env": env_info()}
    print(json.dumps(result, indent=2))
    if out:
        with open(out, "a") as f:
            f.write(json.dumps(result) + "\n")
    return result

usage

# example: official sam3 predictor, same clip and prompt for every setting
from bench_video import bench, Stages

CLIP, PROMPT, FRAMES = "clips/street_20s_720p.mp4", "person", 600

def make_run(predictor):
    def run():
        sid = predictor.handle_request(dict(type="start_session", resource_path=CLIP))["session_id"]
        predictor.handle_request(dict(type="add_prompt", session_id=sid, frame_index=0, text=PROMPT))
        for _ in predictor.handle_stream_request(dict(type="propagate_in_video", session_id=sid)):
            pass                                  # don't save inside the timed loop
        predictor.handle_request(dict(type="close_session", session_id=sid))
    return run

# bench(make_run(predictor_sam3),  FRAMES, model="sam3",   dtype="bf16", out="results.jsonl")
# bench(make_run(predictor_sam31), FRAMES, model="sam3.1", dtype="bf16", out="results.jsonl")

Each run appends one JSON line to results.jsonl with settings, timings and environment, ready to compare or share.

Report

What to Record or Share

Numbers without this context can’t be compared or reproduced.

FieldExample
Model and checkpointSAM 3.1, sam3.1_multiplex.pt
Code versionsam3 commit git log -1; or Transformers / Ultralytics version
GPU, driver, CUDA, PyTorchRTX 4090, driver, CUDA 12.8, torch 2.10
Clip20 s, 720p, 30 → 10 fps, 200 frames
Prompt and objects“person”, 12 tracked objects
Settingsbf16, compile on, image size, offload on/off
ResultMedian FPS, spread, peak memory

Memory measurement: measure VRAM · Objects lost while speeding up? Tracking loses objects · All problems: troubleshooting

Questions

Slow Tracking FAQ

How fast should SAM 3 video tracking be?

Meta reports near real-time for about five objects on an H200 GPU, with time rising as you add objects. SAM 3.1 roughly doubles throughput at medium object counts on an H100. Consumer GPUs will be slower.

Why does SAM 3 get slower with more objects?

SAM 3’s tracker runs once per object on every frame. SAM 3.1’s Object Multiplex groups up to 16 objects into one pass, which is why it helps most in crowded scenes.

Is the first run always slow?

Yes, usually. Model loading, CUDA start-up and torch.compile all happen on the first call. Measure after a warm-up run.

Does lowering resolution help?

Yes. A smaller internal image size and smaller frames reduce the work per frame, at some cost to small-object detail.

Can I skip frames?

You can lower the frame rate before tracking (for example 30 → 10 fps). Tracking works on consecutive frames, so resample the video rather than skipping frames inside a session.

How do I compare two settings fairly?

Same clip, prompt, GPU and versions; one warm-up; at least three timed runs; report the median and the spread. The script on this page does that.

Keep reading