RAFT-Stereo
A recurrent stereo network from the Princeton Vision & Learning Lab, with checkpoints for several datasets.
stable Fork of princeton-vl/RAFT-Stereo@6e93ed2 · backends: portable, kernels
- Paper RAFT-Stereo: Multilevel Recurrent Field Transforms for Stereo Matching 3DV 2021 · first released 15 Sept 2021
Paper 2021 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("raft-stereo-middlebury") # kernels on a supported GPU, else portable PyTorch
result = model(left, right)
result.disparity
result.backend # what ran: mode, device, dtype, kernels fastforks bench raft-stereo-middlebury 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 fp32timed with raft-stereo-eth3d (same network, other weights); corr_implementation=reg_cuda | fp32 | 1775 | 0.58× | 4,825 MiB/4,928 MiB | – | – |
| Original fp16timed with raft-stereo-eth3d (same network, other weights); corr_implementation=reg_cuda | fp16 | 1037 | – | 2,516 MiB/2,628 MiB | – | – |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portablemeasured on raft-stereo-eth3d (same architecture, other checkpoint) | fp16 | 746 | 1.4× | 1,388 MiB/1,492 MiB | 0.3 | 0.75 |
| Kernels | fp16 | 274 | 3.8× | 722 MiB/758 MiB | 0.7 | 0.27 |
| Portable + torch.compile | 506 | 2.0× | 780 MiB/988 MiB | 100 (build) | – | |
| TensorRT fp16 | fp16 | 334 | 3.1× | 884 MiBenginenot comparable | 132 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-01 to 2026-11-16. 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 | 5574 | 9,545 MiB process | matches | 994x1482 |
| Portable | fp16 | 3940 | 4,695 MiB process | matches | 994x1482 | |
| Portable | fp32 | 4395 | 4,712 MiB process | matches | 994x1482 | |
| Kernels | fp16 | 3634 | 4,722 MiB process | matches | 994x1482 | |
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 820 | 1,361 MiB/1,570 MiB | – | 994x1482 |
| Kernels | fp16 | 416 | 730 MiB/758 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 256 | 1,361 MiB/1,570 MiB | – | 994x1482 |
| Kernels | fp16 | 121 | 730 MiB/758 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 643 | 1,361 MiB/1,570 MiB | – | 994x1482 |
| Kernels | fp16 | 313 | 730 MiB/758 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 275 | 1,361 MiB/1,570 MiB | – | 994x1482 |
| Kernels | fp16 | 110 | 730 MiB/758 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 148 | 1,385 MiB/1,490 MiB | – | 994x1482 |
| Kernels | fp16 | 63.6 | 730 MiB/758 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
Commercial use allowed
- Code
- MIT LICENSE
- Weights
- MIT (assumed from code)(not stated by the authors; assumed to follow the code) source
- Training data
-
- Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa) research-only, non-commercial
- Middlebury stereo (2014) not stated
- weights licence not stated by the original authors; assumed to be the code licence
Our reading of the licences, not legal advice.
Weights
raftstereo-middlebury.pth 44.6 MB· inside a 202 MB archive· hosted on Dropboxfastforks downloads and checks these files on first use (fastforks download raft-stereo-middlebury).
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.77 | 0.287 | reference | 27 | 446 |
| Original fp16 | fp16 | 2.77 | 0.289 | ±0.00 | 27 | 249 |
| Portable fp32 | fp32 | 2.77 | 0.287 | ±0.00 | 27 | 368 |
| Portable | fp16 | 2.77 | 0.289 | ±0.00 | 27 | 178 |
| Kernels | fp16 | 2.79 | 0.289 | −0.02 | 27 | 70.2 |
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 % / EPEtrained on this dataset’s public images: not zero-shot
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 7.20 | 1.069 | reference | 15 | 1510 |
| Original fp16 | fp16 | 7.19 | 1.069 | +0.01 | 15 | 882 |
| Portable fp32 | fp32 | 7.20 | 1.068 | ±0.00 | 15 | 1331 |
| Portable | fp16 | 7.20 | 1.069 | ±0.00 | 15 | 627 |
| Kernels | fp16 | 7.21 | 1.071 | −0.01 | 15 | 227 |
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, float16 (the default), portable and kernels: 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.00836 px |
| GPU default dtypes, p99 |diff| | ≤ 0.25 px | 0.07899 px |
Recorded for raft-stereo-middlebury on RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-31, with these kernels: cudnn_hacccutlass_convraft
Details
RAFT-Stereo (Lipson et al. 2021): multi-level GRU updates over a 1-D all-pairs correlation pyramid, 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 3000x4000 (10.2 GiB allocated)
- Options
iters=32>= 1· changes the output
- Outputs
disparity- CUDA kernels
raftRAFT-Stereo: normalisation, GRU gates, correlation, upsamplingcutlass_convCUTLASS convolutions with the recurrent update (GRU) fused incudnn_haccconvolutions with fp16 accumulation (cuDNN)
- Apple (MPS)
stereo_metalMetal: stereo kernels. fp32, fp16
Limitations
- raftstereo-realtime.pth and iraftstereo_rvc.pth from the original zip (another architecture / instance-norm context) are not included and not supported by the kernels engine.
Full reference, generated from the repository
A recurrent stereo network from the Princeton Vision & Learning Lab, with checkpoints for several datasets.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
raft-stereo-middlebury | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 1775 1037 746 274 506 334 | 4825 / 4928 2516 / 2628 1388 / 1492 722 / 758 780 / 988 1012 / 1090 |
raft-stereo-sceneflow | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 1775 1037 746 274 507 333 | 4825 / 4928 2516 / 2628 1388 / 1492 722 / 758 780 / 988 1014 / 1092 |
raft-stereo-eth3d | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 1775 1037 746 275 506 333 | 4825 / 4928 2516 / 2628 1388 / 1492 722 / 738 815 / 988 952 / 972 |
Details
- Original code: https://github.com/princeton-vl/RAFT-Stereo at
6e93ed2169bd - Code licence: MIT (permissive); files:
LICENSE - Weights licence: MIT (assumed from code)
- Licence evidence: https://github.com/princeton-vl/RAFT-Stereo/blob/6e93ed2169bd858dbb43033988563f3b0bb49506/README.md#L79
- Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa)
raft-stereo-middlebury: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa), Middlebury stereo (2014) (SceneFlow, then fine-tuned on the 23 Middlebury 2014 training scenes)raft-stereo-eth3d: ETH3D two-view stereo, not stated by the authors (ETH3D submission model: fine-tuned on ETH3D; the rest of its training is not stated)
- Options:
iters= 32 (>= 1) - Kernel libraries:
raft,cutlass_conv,cudnn_hacc - Variants:
raft-stereo-middlebury,raft-stereo-sceneflow,raft-stereo-eth3d - 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):
raft-stereo-middlebury3000x4000 (10.2 GiB peak allocated, 12.5 reserved);raft-stereo-sceneflow3000x4000 (10.2 GiB peak allocated, 12.5 reserved);raft-stereo-eth3d3000x4000 (10.2 GiB peak allocated, 12.5 reserved) raft-stereo-middlebury994x1482, first call: portable + torch.compile 100 s (cold Inductor cache), TensorRT fp16 132 s (ONNX + engine).raft-stereo-sceneflow994x1482, first call: portable + torch.compile 100 s (cold Inductor cache), TensorRT fp16 132 s (ONNX + engine).raft-stereo-eth3d994x1482, first call: portable + torch.compile 100 s (cold Inductor cache), TensorRT fp16 132 s (ONNX + engine).raft-stereo-middleburyoriginal (fp32) 994x1482, original 994x1482: timed with raft-stereo-eth3d (same network, other weights); corr_implementation=reg_cudaraft-stereo-middleburyportable 994x1482: measured on raft-stereo-eth3d (same architecture, other checkpoint)raft-stereo-scenefloworiginal (fp32) 994x1482, original 994x1482: timed with raft-stereo-eth3d (same network, other weights); corr_implementation=reg_cudaraft-stereo-sceneflowportable 994x1482: measured on raft-stereo-eth3d (same architecture, other checkpoint)raft-stereo-eth3doriginal (fp32) 994x1482, original 994x1482: corr_implementation=reg_cudaraft-stereo-middleburyload / first call: original 0.27 s / 1.452 s (375x1242), portable 0.25 s / 0.746† s, kernels 0.73 s / 0.102 s (375x1242)raft-stereo-sceneflowload / first call: original 0.27 s / 1.452 s (375x1242), portable 0.25 s / 0.746† s, kernels 0.46 s / 0.101 s (375x1242)raft-stereo-eth3dload / first call: original 0.27 s / 1.452 s (375x1242), portable 0.25 s / 0.746† s, kernels 0.55 s / 0.103 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 |
|---|---|---|---|---|---|---|---|
raft-stereo-middlebury | ETH3D two-view train, bad > 1 px % / EPE | 2.77 / 0.287 | 2.77 / 0.289 | 2.77 / 0.289 | 2.77 / 0.287 | 2.79 / 0.289 | |
raft-stereo-middlebury | Middlebury 2014 trainingH, bad > 2 px % / EPE | 7.20 / 1.069 | 7.19 / 1.069 | 7.20 / 1.069 | 7.20 / 1.068 | 7.21 / 1.071 | trained on this dataset's public images; not a zero-shot result |
raft-stereo-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 2.61 / 0.266 | 2.61 / 0.267 | 2.60 / 0.267 | 2.61 / 0.267 | 2.60 / 0.267 | |
raft-stereo-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 11.22 / 1.436 | 11.21 / 1.439 | 11.23 / 1.438 | 11.21 / 1.439 | 11.23 / 1.452 | |
raft-stereo-eth3d | ETH3D two-view train, bad > 1 px % / EPE | 2.61 / 0.274 | 2.60 / 0.274 | 2.60 / 0.274 | 2.60 / 0.274 | 2.61 / 0.274 | trained on this dataset's public images; not a zero-shot result |
raft-stereo-eth3d | Middlebury 2014 trainingH, bad > 2 px % / EPE | 11.95 / 1.635 | 11.99 / 1.634 | 12.00 / 1.635 | 11.98 / 1.636 | 11.98 / 1.635 | possibly in the training data |
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, float16 (the default), portable and kernels: mean |diff| <= 0.02 px and p99 <= 0.25 px.
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
raft-stereo-middlebury | 0.00836 / 0.07899 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, raft@9524a68234cc:sm_120 |
raft-stereo-sceneflow | 0.0019 / 0.01941 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, raft@9524a68234cc:sm_120 |
raft-stereo-eth3d | 0.00166 / 0.01285 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, raft@9524a68234cc:sm_120 |
Limitations
- raftstereo-realtime.pth and iraftstereo_rvc.pth from the original zip (another architecture / instance-norm context) are not included and not supported by the kernels engine.
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).