Models · Optical flow

RAFT

RAFT (Teed and Deng, Princeton) with torchvision's weights: dense optical flow refined step by step over an all-pairs correlation volume. BSD-3-Clause code; some training sets (FlyingChairs, Sintel) are research-only.

stable Fork of pytorch/vision@1f1a920 · backends: portable, kernels

Checkpoint

Paper 2020 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 83.4 ms 1080x1920, fp16
vs the faster original 5.7× original fp32: 480 ms
Peak memory 332 MiB original: 13.2 GiB
Accuracy vs original fp32 +0.001 kernels EPE, KITTI 2015 train (1.528 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import flow

model = flow.load("raft-large")  # kernels on a supported GPU, else portable PyTorch
result = model(frame1, frame2)
result.flow
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench raft-large

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.

BackenddtypeTime per call (ms)vs original fp32Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the callfp32 480–13.2 GiB/13.5 GiB1.10.84
Original fp16torch.autocast(fp16) around the call; torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the callfp16 5670.85×7,164 MiB/10.7 GiB0.10.76
Portable fp32fp32not measured ––––
Portablefp16 2911.6×5,930 MiB/6,058 MiB0.20.30
Kernelsfp16 83.45.7×332 MiB/352 MiB0.30.08
Portable + torch.compile 1952.5×5,886 MiB/5,924 MiB41 (build)–
TensorRTTensorRT engine build failedfails––––

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-10 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

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp32out of memory–1080x1920
Portablefp162710 11.4 GiB processmatches1080x1920
Portablefp322522 12.6 GiB processmatches1080x1920
Kernelsfp161351 3,647 MiB processmatches1080x1920

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
BSD-3-Clause LICENSE
Weights
BSD-3-Clause (assumed from code)(not stated by the authors; assumed to follow the code) source
Training data
  • weights licence not stated by the original authors; assumed to be the code licence

Our reading of the licences, not legal advice.

Weights

raft_large_C_T_SKHT_V2-ff5fadd5.pth 21.1 MB· hosted on PyTorch

fastforks downloads and checks these files on first use (fastforks download raft-large).

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.

KITTI 2015 train

EPE / Fl-all %trained on this dataset’s public images: not zero-shot

RundtypeEPE ↓Fl-all % ↓Δ EPE vs fp32 originalpairsms / pair
Original fp32fp321.5285.60 reference 200 86.2
Original fp16fp161.5285.60 −0.001 200 66.0
Portable fp32fp321.5285.60 ±0.000 200 74.2
Portablefp161.5295.61 −0.001 200 46.4
Kernelsfp161.5265.60 +0.001 200 21.7

Frames _10 -> _11 at full size against the flow_occ ground truth; EPE = mean of the per-pair mean end-point error, Fl-all = share of all valid pixels with an error > 3 px and > 5 % of the GT magnitude. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-11; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks f2992269+unc, 2026-11-09.

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.00012 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0019 and p99 <= 0.0091 (absolute error of the output flow).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.00012 not recorded
GPU default dtypes, mean |diff|≤ 0.0019 0.00098
GPU default dtypes, p99 |diff|≤ 0.0091 0.00459

Recorded for raft-large on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-12, with these kernels: cudnn_hacccutlass_convraft_flow

Details

RAFT (Teed & Deng 2020): all-pairs correlation pyramid at 1/8 resolution and a ConvGRU that refines the flow in 12 iterations, upsampled with a learned convex mask (raft-small: bilinear). torchvision's V2 weights (trained from scratch with its optical-flow reference recipe); the network is ported from torchvision (no torchvision dependency).

Input / output
Input: two RGB images (consecutive frames). Output: per-pixel motion from the first to the second (dx, dy in pixels).
Input size
any H x W >= 128, padded to a multiple of 8; tested up to 1024x2048 (8,452 MiB allocated)
Options
  • iters=12>= 1· changes the output
Outputs
flow
CUDA kernels
  • raft_flowRAFT optical flow kernels
  • cutlass_convCUTLASS convolutions with the recurrent update (GRU) fused in
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
flow_metalMetal: RAFT correlation lookup without a volume. fp32, fp16
Full reference, generated from the repository

RAFT (Teed and Deng, Princeton) with torchvision's weights: dense optical flow refined step by step over an all-pairs correlation volume. BSD-3-Clause code; some training sets (FlyingChairs, Sintel) are research-only.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
raft-largesynthetic (1080x1920)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
480
567
291
83.4
195
fails: TensorRT engine build failed
13489 / 13798
7164 / 10928
5930 / 6058
332 / 352
5886 / 5924
–
raft-large-thingssynthetic (1080x1920)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
481
566
291
83.5
195
fails: TensorRT engine build failed
13489 / 13798
7164 / 10928
5930 / 6058
332 / 352
5886 / 5924
–
raft-large-kittisynthetic (1080x1920)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
480
567
291
84.2
195
fails: TensorRT engine build failed
13489 / 13818
7164 / 10928
5930 / 6058
332 / 352
5886 / 5924
–
raft-smallsynthetic (1080x1920)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
196
395
144
36.5
110
fails: unsupported: engine build needs more than the 16 GB of this
13441 / 13686
7032 / 10888
5669 / 5706
196 / 204
5704 / 5728
–
Details
  • Original code: https://github.com/pytorch/vision at 1f1a920d685d
  • Code licence: BSD-3-Clause (permissive); files: LICENSE
  • Weights licence: BSD-3-Clause (assumed from code)
  • Licence evidence: https://github.com/pytorch/vision/blob/1f1a920d685d46dfbe187934b785b7ecb7a182f2/torchvision/models/optical_flow/raft.py#L576
  • Training data: FlyingChairs (Freiburg), Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa) (FlyingChairs, then FlyingThings3D (part of SceneFlow))
    • raft-large: FlyingChairs (Freiburg), Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa), MPI Sintel optical flow, KITTI stereo / optical flow 2012 / 2015, HCI HD1K optical flow benchmark (FlyingChairs, FlyingThings3D, then fine-tuned on a mix of Sintel, KITTI 2015, HD1K and FlyingThings3D (clean pass))
    • raft-large-kitti: FlyingChairs (Freiburg), Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa), MPI Sintel optical flow, KITTI stereo / optical flow 2012 / 2015, HCI HD1K optical flow benchmark (as raft-large, then fine-tuned on KITTI 2015)
  • Options: iters = 12 (>= 1)
  • Kernel libraries: raft_flow, cutlass_conv, cudnn_hacc
  • Variants: raft-large, raft-large-things, raft-large-kitti, raft-small
  • Outputs: flow
  • Input size: any H x W >= 128, padded to a multiple of 8
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): raft-large 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); raft-large-things 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); raft-large-kitti 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); raft-small 1024x2048 (8.2 GiB peak allocated, 8.7 reserved)
  • raft-large 1080x1920, first call: portable + torch.compile 41 s (cold Inductor cache).
  • raft-large-things 1080x1920, first call: portable + torch.compile 39 s (cold Inductor cache).
  • raft-large-kitti 1080x1920, first call: portable + torch.compile 39 s (cold Inductor cache).
  • raft-small 1080x1920, first call: portable + torch.compile 37 s (cold Inductor cache).
  • raft-large original (fp32) 1080x1920: torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-large original 1080x1920: torch.autocast(fp16) around the call; torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-large-things original (fp32) 1080x1920: torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-large-things original 1080x1920: torch.autocast(fp16) around the call; torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-large-kitti original (fp32) 1080x1920: torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-large-kitti original 1080x1920: torch.autocast(fp16) around the call; torchvision 0.29.1+cu130 raft_large, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-small original (fp32) 1080x1920: torchvision 0.29.1+cu130 raft_small, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-small original 1080x1920: torch.autocast(fp16) around the call; torchvision 0.29.1+cu130 raft_small, num_flow_updates=12, [-1, 1] conversion in the call
  • raft-large load / first call: original 0.14 s / 0.762 s, portable 0.17 s / 0.304 s, kernels 1.07 s / 0.107 s
  • raft-large-things load / first call: original 0.13 s / 0.58 s, portable 0.25 s / 0.303 s, kernels 1.07 s / 0.108 s
  • raft-large-kitti load / first call: original 0.14 s / 0.58 s, portable 0.17 s / 0.304 s, kernels 1.06 s / 0.107 s
  • raft-small load / first call: original 0.09 s / 0.433 s, portable 0.16 s / 0.173 s, kernels 1.06 s / 0.068 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

Frames _10 -> _11 at full size against the flow_occ ground truth; EPE = mean of the per-pair mean end-point error, Fl-all = share of all valid pixels with an error > 3 px and > 5 % of the GT magnitude. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
raft-largeKITTI 2015 train, EPE / Fl-all %1.528 / 5.601.528 / 5.601.529 / 5.611.528 / 5.601.526 / 5.60trained on this dataset's public images; not a zero-shot result
raft-large-thingsKITTI 2015 train, EPE / Fl-all %4.838 / 16.554.831 / 16.544.828 / 16.514.838 / 16.554.834 / 16.53
raft-large-kittiKITTI 2015 train, EPE / Fl-all %0.614 / 1.440.614 / 1.440.614 / 1.440.614 / 1.440.614 / 1.44trained on this dataset's public images; not a zero-shot result
raft-smallKITTI 2015 train, EPE / Fl-all %7.854 / 25.917.838 / 25.927.846 / 25.927.854 / 25.917.834 / 25.92

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f2992269+uncommitted, 2026-11-09; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f2992269+uncommitted, 2026-11-09.

Parity

CPU, float32: max |diff| <= 0.00012 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0019 and p99 <= 0.0091 (absolute error of the output flow).

variantkernels error vs original, mean / p99GPU, torchkernels used
raft-large0.00098 / 0.00459RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, raft_flow@a101a33607b6:sm_120
raft-large-things0.00105 / 0.00459RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, raft_flow@a101a33607b6:sm_120
raft-large-kitti0.00096 / 0.00441RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, raft_flow@a101a33607b6:sm_120
raft-small0.00228 / 0.00957RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, raft_flow@a101a33607b6:sm_120

Example output

One fixed input through this checkpoint, the same for every model of the task (portable · float16 · NVIDIA GeForce RTX 5060 Ti).

Frame 1
Frame 2
Output
Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), frame 1
Frame 1 · 100%

Input: Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), Scharstein et al., Middlebury College (research dataset, no licence stated).