DEFOM-Stereo
A stereo network from the Insta360 Research Team that uses Depth Anything V2 features and an initial depth prior. Non-commercial weights.
stable Fork of Insta360-Research-Team/DEFOM-Stereo@5b27591 · backends: portable, kernels
- Paper DEFOM-Stereo: Depth Foundation Model Based Stereo Matching CVPR 2025 · first released 16 Jan 2025
Checkpoint defom-stereo-vitl-sceneflow
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 stereo
model = stereo.load("defom-stereo-vitl-sceneflow") # kernels on a supported GPU, else portable PyTorch
result = model(left, right)
result.disparity
result.backend # what ran: mode, device, dtype, kernels The weights are non-commercial: fastforks downloads them only with FASTFORKS_NONCOMMERCIAL=1 set.
fastforks bench defom-stereo-vitl-sceneflow 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 bf16 on CUDA.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 4175 | 0.67× | 10.6 GiB/10.8 GiB | 10.8 | 4.18 |
| Original fp16the authors' mixed-precision option (float16) | fp16 | 2816 | – | 8,639 MiB/8,766 MiB | 4.2 | 2.83 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | bf16 | 1531 | 1.8× | 4,362 MiB/4,838 MiB | 2.3 | 1.53 |
| Kernels | fp16 | 642 | 4.4× | 3,154 MiB/3,522 MiB | 2.7 | 0.65 |
| Portable + torch.compile | 1002 | 2.8× | 3,021 MiB/3,292 MiB | 122 (build) | – | |
| TensorRTplanned for 0.2.1 | fails | – | – | – | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-12. 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 | out of memory | – | 994x1482 | |
| Portable | fp32 | 11105 | 12.8 GiB process | matches | 994x1482 | |
| Kernels | fp16 | 8224 | 8,328 MiB process | matches | 994x1482 | |
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | bf16 | 1641 | 4,333 MiB/4,792 MiB | – | 994x1482 |
| Kernels | fp16 | 921 | 3,124 MiB/3,522 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | bf16 | 499 | 4,333 MiB/4,812 MiB | – | 994x1482 |
| Kernels | fp16 | 271 | 3,124 MiB/3,542 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | bf16 | 1211 | 4,333 MiB/4,792 MiB | – | 994x1482 |
| Kernels | fp16 | 689 | 3,124 MiB/3,522 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | bf16 | 475 | 4,333 MiB/4,792 MiB | – | 994x1482 |
| Kernels | fp16 | 248 | 3,124 MiB/3,522 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | bf16 | 266 | 4,357 MiB/4,972 MiB | – | 994x1482 |
| Kernels | fp16 | 146 | 3,148 MiB/3,542 MiB | – | 994x1482 | |
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
Non-commercial only
- Code
- MIT LICENSE
- Weights
- CC-BY-NC-4.0 source
- Training data
-
- Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa) research-only, non-commercial
- weights: CC-BY-NC-4.0
- The weights embed Depth Anything V2 ViT-L weights released under CC-BY-NC-4.0, so they are non-commercial even though the code is MIT.
Our reading of the licences, not legal advice.
Weights
defomstereo_vitl_sceneflow.pth 1.5 GB· hosted on Google Drivefastforks downloads and checks these files on first use (fastforks download defom-stereo-vitl-sceneflow). Non-commercial weights need FASTFORKS_NONCOMMERCIAL=1.
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.
ETH3D two-view train
bad > 1 px % / EPE
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 2.40 | 0.337 | reference | 27 | 748 |
| Original fp16 | fp16 | 99.92 | 13.132 | – | 27NaN / inf output | 405 |
| Portable fp32 | fp32 | 2.34 | 0.328 | +0.06 | 27 | 713 |
| Portable | bf16 | 2.37 | 0.356 | +0.03 | 27 | 336 |
| Kernels | fp16 | 2.44 | 0.341 | −0.04 | 27 | 150 |
Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-05; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 468fba10, 2026-11-05.
Middlebury 2014 trainingH
bad > 2 px % / EPE
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 6.03 | 0.837 | reference | 15 | 3410 |
| Original fp16 | fp16 | 100.00 | 71.272 | – | 15NaN / inf output | 2270 |
| Portable fp32 | fp32 | 6.02 | 0.837 | +0.01 | 15 | 3002 |
| Portable | bf16 | 6.15 | 0.845 | −0.12 | 15 | 1274 |
| Kernels | fp16 | 6.02 | 0.834 | +0.01 | 15 | 544 |
Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-05; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 468fba10, 2026-11-05.
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.002 vs the original. GPU, portable bfloat16 and kernels float16 (the defaults): mean |diff| <= 0.02 px and p99 <= 0.25 px.
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 px | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.02 px | 0.00143 px |
| GPU default dtypes, p99 |diff| | ≤ 0.25 px | 0.00808 px |
Recorded for defom-stereo-vitl-sceneflow on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-12, with these kernels: cudnn_hacccutlass_convdpt_fusedfastbbigev
Details
DEFOM-Stereo (Jiang et al. 2025): Depth Anything V2 (ViT-L) features and initial disparity, then RAFT-style ConvGRU updates with scale updates, 32 iterations.
- Input / output
- Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
- Input size
- any H x W >= 32, padded to a multiple of 32; tested up to 1988x2880 (12.0 GiB allocated)
- Options
iters=32>= 1· changes the outputscale_iters=8>= 0· changes the output
- Outputs
disparity- CUDA kernels
igevIGEV stereo: convolution epilogues, correlation lookups, GRU gatescutlass_convCUTLASS convolutions with the recurrent update (GRU) fused incudnn_haccconvolutions with fp16 accumulation (cuDNN)fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbonesdpt_fusedfused fp16 matrix multiplies and convolutions for DINOv2 backbones and DPT depth heads
- Apple (MPS)
stereo_metalMetal: stereo kernels. fp32
Limitations
- Only the ViT-L SceneFlow checkpoint is included (ViT-S / ViT-B and the Middlebury / ETH3D / KITTI fine-tunes are not).
- Portable is faster than the original code but allocates more memory (about 1.25x at 994x1482); kernels is several times faster and needs a fraction of the memory.
Full reference, generated from the repository
A stereo network from the Insta360 Research Team that uses Depth Anything V2 features and an initial depth prior. Non-commercial weights.
Commercial use: no (weights: CC-BY-NC-4.0).
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
defom-stereo-vitl-sceneflow | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 4175 2816 1531 642 1002 planned for 0.2.1 | 10896 / 11072 8639 / 8766 4362 / 4838 3154 / 3522 3021 / 3292 – |
Details
- Original code: https://github.com/Insta360-Research-Team/DEFOM-Stereo at
5b27591d8395 - Code licence: MIT (permissive); files:
LICENSE - Weights licence: CC-BY-NC-4.0
- Licence evidence: https://github.com/Insta360-Research-Team/DEFOM-Stereo/blob/5b27591d83956e5d329ff66704271a9e68b1c75f/README.md
- Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa)
- Licence note: The weights embed Depth Anything V2 ViT-L weights released under CC-BY-NC-4.0, so they are non-commercial even though the code is MIT.
- Options:
iters= 32 (>= 1),scale_iters= 8 (>= 0) - Kernel libraries:
igev,cutlass_conv,cudnn_hacc,fastbb,dpt_fused - Variants:
defom-stereo-vitl-sceneflow - Not in this release (planned for 0.2.1):
defom-stereo-vitl-sceneflowTensorRT export: the TensorRT 10 engine build fails (Myelin tactic check) - Outputs: disparity
- Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
defom-stereo-vitl-sceneflow1988x2880 (12.0 GiB peak allocated, 14.5 reserved) defom-stereo-vitl-sceneflow994x1482, first call: portable + torch.compile 122 s (cold Inductor cache).defom-stereo-vitl-scenefloworiginal 994x1482: the authors' mixed-precision option (float16)defom-stereo-vitl-sceneflowload / first call: original 4.24 s / 2.83 s, portable 2.31 s / 1.534† s, kernels 2.74 s / 0.305 s (375x1242)- † 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
Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
defom-stereo-vitl-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 2.40 / 0.337 | 99.92 / 13.132 (NaN / inf output) | 2.37 / 0.356 | 2.34 / 0.328 | 2.44 / 0.341 | |
defom-stereo-vitl-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 6.03 / 0.837 | 100.00 / 71.272 (NaN / inf output) | 6.15 / 0.845 | 6.02 / 0.837 | 6.02 / 0.834 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 468fba10, 2026-11-05.
Parity
CPU, float32: max |diff| <= 0.002 vs the original. GPU, portable bfloat16 and kernels float16 (the defaults): mean |diff| <= 0.02 px and p99 <= 0.25 px.
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
defom-stereo-vitl-sceneflow | 0.00143 / 0.00808 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, igev@f075827d68c6:sm_120 |
Limitations
- Only the ViT-L SceneFlow checkpoint is included (ViT-S / ViT-B and the Middlebury / ETH3D / KITTI fine-tunes are not).
- Portable is faster than the original code but allocates more memory (about 1.25x at 994x1482); kernels is several times faster and needs a fraction of the memory.
Example output
One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).
Input: Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), Scharstein et al., Middlebury College (research dataset, no licence stated).