RAFT (fastforks)
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).
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/pytorch/vision at 1f1a920d685d.
Task: flow. Tier: stable. Outputs: flow. Backends: portable, kernels.
Input: two RGB images (consecutive frames). Output: per-pixel motion from the first to the second (dx, dy in pixels).
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
raft-large@1 |
raft_large_C_T_SKHT_V2-ff5fadd5.pth | ff5fadd56d26 |
BSD-3-Clause (assumed from code) | yes |
raft-large-kitti@1 |
raft_large_C_T_SKHT_K_V2-b5c70766.pth | b5c7076664d2 |
BSD-3-Clause (assumed from code) | yes |
raft-large-things@1 |
raft_large_C_T_V2-1bb1363a.pth | 1bb1363a43b4 |
BSD-3-Clause (assumed from code) | yes |
raft-small@1 |
raft_small_C_T_V2-01064c6d.pth | 01064c6dba73 |
BSD-3-Clause (assumed from code) | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: BSD-3-Clause. Licence files: LICENSE.
Code licence: BSD-3-Clause; the authors do not state a separate weights licence.
Training data: FlyingChairs (Freiburg), Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa) (FlyingChairs, then FlyingThings3D (part of SceneFlow)).
Licence evidence: https://github.com/pytorch/vision/blob/1f1a920d685d46dfbe187934b785b7ecb7a182f2/torchvision/models/optical_flow/raft.py#L576
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-kitti 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); raft-large-things 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); raft-small 1024x2048 (8.2 GiB peak allocated, 8.7 reserved)
Speed and memory
Flow, synthetic
| model | input | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|---|
raft-large |
1080x1920 | 480 | 567 | 291 | 83.5 | 5.7x | 3.5x | 7164 / 10928 | 5930 / 6058 | 342 / 372 |
raft-large-kitti |
1080x1920 | 480 | 567 | 291 | 83.6 | 5.7x | 3.5x | 7164 / 10928 | 5930 / 6058 | 333 / 352 |
raft-large-things |
1080x1920 | 481 | 566 | 291 | 83.1 | 5.8x | 3.5x | 7164 / 10928 | 5930 / 6058 | 333 / 352 |
raft-small |
1080x1920 | 196 | 395 | 144 | 36.3 | 5.4x | 4.0x | 7032 / 10888 | 5669 / 5706 | 197 / 224 |
Flow, KITTI 2015, 375x1242
| model | time (ms): portable | kernels | kernels speed-up: vs portable | peak memory (MiB, allocated / reserved): portable | kernels |
|---|---|---|---|---|---|
raft-large |
45.8 | 21.0 | 2.2x | 511 / 738 | 85 / 112 |
raft-large-things |
45.8 | 21.1 | 2.2x | 511 / 738 | 85 / 112 |
raft-small |
23.2 | 12.1 | 1.9x | 483 / 508 | 48 / 66 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
raft-large |
0.14 | 0.17 | 1.07 | 0.76 | 0.30 | 0.11 |
raft-large-kitti |
0.14 | 0.17 | 1.06 | 0.58 | 0.30 | 0.11 |
raft-large-things |
0.13 | 0.25 | 1.07 | 0.58 | 0.30 | 0.11 |
raft-small |
0.09 | 0.16 | 1.06 | 0.43 | 0.17 | 0.07 |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|---|---|---|---|---|---|---|---|---|---|---|---|
raft-large |
1080x1920 | 291 ms | 195 ms | fails: TensorRT engine build failed | 83.5 ms | 41.3 s | β | 5930 / 6058 | 5886 / 5924 | 342 / 372 | β |
raft-large-kitti |
1080x1920 | 291 ms | 195 ms | fails: TensorRT engine build failed | 83.6 ms | 39.3 s | β | 5930 / 6058 | 5886 / 5924 | 333 / 352 | β |
raft-large-things |
1080x1920 | 291 ms | 195 ms | fails: TensorRT engine build failed | 83.1 ms | 39.4 s | β | 5930 / 6058 | 5886 / 5924 | 333 / 352 | β |
raft-small |
1080x1920 | 144 ms | 110 ms | fails: unsupported: engine build needs more than the 16 GB of this | 36.3 ms | 37.0 s | β | 5669 / 5706 | 5704 / 5728 | 197 / 224 | β |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
raft-large-kitti: same network and settings asraft-large, measured once (rows not repeated).
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
Accuracy
On public datasets
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.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
raft-large |
KITTI 2015 train, EPE / Fl-all % | 1.528 / 5.60 | 1.528 / 5.60 | 1.529 / 5.61 | 1.526 / 5.60 | trained on this dataset's public images; not a zero-shot result |
raft-large-things |
KITTI 2015 train, EPE / Fl-all % | 4.838 / 16.55 | 4.831 / 16.54 | 4.828 / 16.51 | 4.834 / 16.53 | |
raft-large-kitti |
KITTI 2015 train, EPE / Fl-all % | 0.614 / 1.44 | 0.614 / 1.44 | 0.614 / 1.44 | 0.614 / 1.44 | trained on this dataset's public images; not a zero-shot result |
raft-small |
KITTI 2015 train, EPE / Fl-all % | 7.854 / 25.91 | 7.838 / 25.92 | 7.846 / 25.92 | 7.834 / 25.92 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f2992269+uncommitted, 2026-11-09.
Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. 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).
Usage
from fastforks import flow
model = flow.load("raft-large") # mode="auto": the preferred backend from recorded measurements
result = model("frame1.png", "frame2.png")
result.flow # [2, H, W] float32 tensor: dx, dy in input pixels
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: raft-large, raft-large-kitti, raft-large-things, raft-small.
Kernels backend
flow.load("raft-large", mode="kernels") runs our CUDA kernels (raft_flow, cutlass_conv, cudnn_hacc). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.