Models · Stereo matching

CFNet

A stereo network with cascaded and fused cost volumes, trained on synthetic data.

stable Fork of gallenszl/CFNet@982230d · backends: portable, kernels

Checkpoint cfnet-sceneflow

Paper 2021 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 406 ms 994x1482, fp16
vs the faster original 1.3× original fp16: 545 ms
Peak memory 3,403 MiB original: 6,765 MiB
Accuracy vs original fp32 −0.01 kernels bad px %, ETH3D two-view train (5.59 original)

Use it

pip install fastforks

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

from fastforks import stereo

model = stereo.load("cfnet-sceneflow")  # kernels on a supported GPU, else portable PyTorch
result = model(left, right)
result.disparity
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench cfnet-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 fp16 on CUDA.

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 6590.83×8,551 MiB/8,896 MiB1.80.66
Original fp16torch.autocast(float16) around the callfp16 545–6,765 MiB/7,880 MiB0.60.56
Portable fp32fp32not measured ––––
Portablefp16 4891.1×3,398 MiB/4,336 MiB1.00.49
Kernelsfp16 4061.3×3,403 MiB/4,338 MiB1.10.41
Portable + torch.compile 2492.2×1,026 MiB/1,398 MiB53 (build)–
TensorRT fp16fp16 1713.2×1,238 MiBenginenot comparable139 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-06 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-12Originalfp32out of memory–994x1482
Portablefp16out of memory–994x1482
Portablefp32out of memory–994x1482
Kernelsfp162206 5,416 MiB processmatches994x1482
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp16544 3,406 MiB/4,336 MiB–994x1482
Kernelsfp16484 3,628 MiB/4,598 MiB–994x1482
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16175 3,406 MiB/4,336 MiB–994x1482
Kernelsfp16152 3,628 MiB/4,598 MiB–994x1482
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp16461 3,406 MiB/4,336 MiB–994x1482
Kernelsfp16432 3,636 MiB/4,838 MiB–994x1482
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16156 3,406 MiB/4,336 MiB–994x1482
Kernelsfp16145 3,636 MiB/4,838 MiB–994x1482
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1689.5 3,406 MiB/4,336 MiB–994x1482
Kernelsfp1676.4 3,628 MiB/4,598 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
  • weights licence not stated by the original authors; assumed to be the code licence

Our reading of the licences, not legal advice.

Weights

sceneflow_pretraining.ckpt 277 MB· hosted on Google Drive

fastforks downloads and checks these files on first use (fastforks download cfnet-sceneflow).

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

Rundtypebad px % ↓EPE ↓Δ bad px % vs fp32 originalpairsms / pair
Original fp32fp325.590.417 reference 27 157
Original fp16fp1699.9213.132 – 27NaN / inf output 125
Portable fp32fp325.600.417 −0.01 27 151
Portablefp165.590.417 ±0.00 27 91.8
Kernelsfp165.600.416 −0.01 27 74.2
Original .half()fp1699.9213.132 – 27NaN / inf output 99.8

Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16, original .half(): 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

Rundtypebad px % ↓EPE ↓Δ bad px % vs fp32 originalpairsms / pair
Original fp32fp3221.316.445 reference 15 564
Original fp16fp16100.0071.272 – 15NaN / inf output 468
Portable fp32fp3221.326.447 −0.01 15 650
Portablefp1621.326.447 −0.01 15 405
Kernelsfp1621.326.444 −0.01 15 332
Original .half()fp16100.0071.272 – 15NaN / inf output 367

Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16, original .half(): 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.05 px and p99 <= 0.5 px.

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 pxnot recorded
GPU default dtypes, mean |diff|≤ 0.05 px0.00193 px
GPU default dtypes, p99 |diff|≤ 0.5 px0.0126 px

Recorded for cfnet-sceneflow on RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-31, with these kernels: cudnn_hacccutlass_convigev

Details

CFNet (Shen et al. 2021): cascade and fused cost volumes (fused 1/8-1/32 3-D volumes), then two refinement stages that adapt to the uncertainty of the disparity (max disparity 192).

Input / output
Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
Input size
any H x W >= 64, padded to a multiple of 64; tested up to 1988x2880 (8,373 MiB allocated)
Outputs
disparity
CUDA kernels
  • igevIGEV stereo: convolution epilogues, correlation lookups, GRU gates
  • cutlass_convCUTLASS convolutions with the recurrent update (GRU) fused in
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
stereo_metalMetal: stereo kernels. fp32, fp16
Full reference, generated from the repository

A stereo network with cascaded and fused cost volumes, trained on synthetic data.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
cfnet-sceneflowMiddlebury 2014 half (994x1482)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
659
545
489
406
249
171
8551 / 8896
6765 / 7880
3398 / 4336
3403 / 4338
1026 / 1398
1357 / 1410
Details
  • Original code: https://github.com/gallenszl/CFNet at 982230dd3605
  • Code licence: MIT (permissive); files: LICENSE
  • Weights licence: MIT (assumed from code)
  • Licence evidence: https://github.com/gallenszl/CFNet/blob/982230dd360583fc35743d0b7ed528982fe5fd38/README.md#L72
  • Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa)
  • Kernel libraries: igev, cutlass_conv, cudnn_hacc
  • Variants: cfnet-sceneflow
  • Outputs: disparity
  • Input size: any H x W >= 64, padded to a multiple of 64
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): cfnet-sceneflow 1988x2880 (8.2 GiB peak allocated, 11.5 reserved)
  • cfnet-sceneflow 994x1482, first call: portable + torch.compile 53 s (cold Inductor cache), TensorRT fp16 139 s (ONNX + engine).
  • cfnet-sceneflow original 994x1482: torch.autocast(float16) around the call
  • cfnet-sceneflow load / first call: original 0.55 s / 0.56 s, portable 0.96 s / 0.356 s (375x1242), kernels 1.14 s / 0.271 s (375x1242)
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16original halfportableportable fp32kernelsnote
cfnet-sceneflowETH3D two-view train, bad > 1 px % / EPE5.59 / 0.41799.92 / 13.132 (NaN / inf output)99.92 / 13.132 (NaN / inf output)5.59 / 0.4175.60 / 0.4175.60 / 0.416
cfnet-sceneflowMiddlebury 2014 trainingH, bad > 2 px % / EPE21.31 / 6.445100.00 / 71.272 (NaN / inf output)100.00 / 71.272 (NaN / inf output)21.32 / 6.44721.32 / 6.44721.32 / 6.444

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.05 px and p99 <= 0.5 px.

variantkernels error vs original, mean / p99GPU, torchkernels used
cfnet-sceneflow0.00193 / 0.0126RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120

Example output

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

Left view
Right view
Output
Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), left view
Left view · 100%

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