Models / sam-vit-base

SAM ViT-Base

Meta's Segment Anything Model: a ViT-Det image encoder with windowed and relative-position attention, whose 64x64 embedding any number of point or box prompts are decoded against by a two-way transformer.

93.7M parameterssamApache-2.0image-segmentationvisionpromptedencoder-decoder

NVIDIA H100 80GB HBM3 · median of 10 runs after 3 warm-ups · measured 2026-09-28T20:02:51+00:00

Linnet 0.1.0, PyTorch 2.14.0, JAX 0.11.2, transformers 5.17.0, diffusers 0.40.0, ONNX Runtime 1.30.0, Python 3.12.3, driver 580.126.09

Linnet against the stack it replaces

Each side in its fastest configuration, on the same GPU and checkpoint. A speed-up is how many times the other's speed; an export is measured against the original checkpoint in the same engine.

vs the reference, in PyTorch1.04× fasterencode
  • Linnet, CUDA graphs27.7 mstransformers, compiled28.9 ms

Each row also carries its distance from reference: the largest absolute difference between its output and transformers (eager)'s on the same input. bf16 outputs differ by rounding (about 0.1 on logits near 16), so a small number is expected; it is there so that a fast wrong answer cannot look like a win.

Encode

ms, lower is better; the best bar is red.

PyTorchJAXONNX Runtime and TensorRT02040mstransformers39.0 mstransformers, compiled28.9 msLinnet, generated PyTorch41.6 msLinnet, inductor28.2 msLinnet, CUDA graphs27.7 msLinnet, XLA (StableHLO)13.7 msLinnet, XLA (generated JAX)13.8 msLinnet, ONNX Runtime f3222.8 msLinnet, ONNX Runtime f1620.9 msLinnet, ONNX Runtime bf1622.9 msLinnet, TensorRT f3214.2 msLinnet, TensorRT f169.64 msLinnet, TensorRT bf169.76 ms

Load time

s, lower is better; the best bar is red.

PyTorchJAXONNX Runtime and TensorRT0123stransformers3.17 stransformers, compiled0.65 sLinnet, generated PyTorch0.50 sLinnet, inductor0.45 sLinnet, CUDA graphs0.50 sLinnet, XLA (StableHLO)0.57 sLinnet, XLA (generated JAX)0.82 sLinnet, ONNX Runtime f320.31 sLinnet, ONNX Runtime f160.36 sLinnet, ONNX Runtime bf160.30 sLinnet, TensorRT f320.30 sLinnet, TensorRT f160.32 sLinnet, TensorRT bf160.32 s

Peak GPU memory

What the driver reports the process holding at its peak, in GiB; lower is better; the best bar is red.

PyTorchJAXONNX Runtime and TensorRT02.557.5GiBtransformers2.99 GiBtransformers, compiled2.34 GiBLinnet, generated PyTorch2.90 GiBLinnet, inductor2.20 GiBLinnet, CUDA graphs2.34 GiBLinnet, XLA (StableHLO)2.78 GiBLinnet, XLA (generated JAX)2.78 GiBLinnet, ONNX Runtime f328.58 GiBLinnet, ONNX Runtime f167.81 GiBLinnet, ONNX Runtime bf167.67 GiBLinnet, TensorRT f324.39 GiBLinnet, TensorRT f164.11 GiBLinnet, TensorRT bf163.81 GiB

Every number

MethodEncodeLoad timePeak GPU memoryAgainst the stack it replacesDistance from referenceNotes
PyTorch
transformers39.0 ms3.17 s2.99 GiB0 (the reference)
transformers, compiled28.9 ms0.65 s2.34 GiB1.0e-4
Linnet, generated PyTorch41.6 ms0.50 s2.90 GiB0.70× transformers, compiled8.2e-5
Linnet, inductor28.2 ms0.45 s2.20 GiB1.03× transformers, compiled9.7e-5
Linnet, CUDA graphs27.7 ms0.50 s2.34 GiB1.04× transformers, compiled9.7e-5
JAX
Linnet, XLA (StableHLO)13.7 ms0.57 s2.78 GiB0.00123peak memory is JAX's allocator peak; the driver shows its pool, which grows in whole regions
Linnet, XLA (generated JAX)13.8 ms0.82 s2.78 GiB0.00128peak memory is JAX's allocator peak; the driver shows its pool, which grows in whole regions
ONNX Runtime and TensorRT
Linnet, ONNX Runtime f3222.8 ms0.31 s8.58 GiB0.00232f32; ONNX Runtime's CUDA execution provider; first calls build the sessions; the image encoder
Linnet, ONNX Runtime f1620.9 ms0.36 s7.81 GiB0.00284f16; ONNX Runtime's CUDA execution provider; first calls build the sessions; the image encoder
Linnet, ONNX Runtime bf1622.9 ms0.30 s7.67 GiB0.0276bf16; ONNX Runtime's CUDA execution provider; first calls build the sessions; the image encoder
Linnet, TensorRT f3214.2 ms0.30 s4.39 GiB0.00123f32; ONNX Runtime's TensorRT execution provider; first calls build the sessions; the image encoder
Linnet, TensorRT f169.64 ms0.32 s4.11 GiB0.00798f16; ONNX Runtime's TensorRT execution provider; first calls build the sessions; the image encoder
Linnet, TensorRT bf169.76 ms0.32 s3.81 GiB0.0298bf16; ONNX Runtime's TensorRT execution provider; first calls build the sessions; the image encoder