CFNet
A stereo network with cascaded and fused cost volumes, trained on synthetic data.
stable Fork of gallenszl/CFNet@982230d · backends: portable, kernels
- Paper CFNet: Cascade and Fused Cost Volume for Robust Stereo Matching CVPR 2021 · first released 9 Apr 2021
Checkpoint cfnet-sceneflow
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("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.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 659 | 0.83× | 8,551 MiB/8,896 MiB | 1.8 | 0.66 |
| Original fp16torch.autocast(float16) around the call | fp16 | 545 | – | 6,765 MiB/7,880 MiB | 0.6 | 0.56 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 489 | 1.1× | 3,398 MiB/4,336 MiB | 1.0 | 0.49 |
| Kernels | fp16 | 406 | 1.3× | 3,403 MiB/4,338 MiB | 1.1 | 0.41 |
| Portable + torch.compile | 249 | 2.2× | 1,026 MiB/1,398 MiB | 53 (build) | – | |
| TensorRT fp16 | fp16 | 171 | 3.2× | 1,238 MiBenginenot comparable | 139 (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
| 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 | fp16 | out of memory | – | 994x1482 | ||
| Portable | fp32 | out of memory | – | 994x1482 | ||
| Kernels | fp16 | 2206 | 5,416 MiB process | matches | 994x1482 | |
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 544 | 3,406 MiB/4,336 MiB | – | 994x1482 |
| Kernels | fp16 | 484 | 3,628 MiB/4,598 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 175 | 3,406 MiB/4,336 MiB | – | 994x1482 |
| Kernels | fp16 | 152 | 3,628 MiB/4,598 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 461 | 3,406 MiB/4,336 MiB | – | 994x1482 |
| Kernels | fp16 | 432 | 3,636 MiB/4,838 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 156 | 3,406 MiB/4,336 MiB | – | 994x1482 |
| Kernels | fp16 | 145 | 3,636 MiB/4,838 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 89.5 | 3,406 MiB/4,336 MiB | – | 994x1482 |
| Kernels | fp16 | 76.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
-
- Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa) research-only, non-commercial
- 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 Drivefastforks 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
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 5.59 | 0.417 | reference | 27 | 157 |
| Original fp16 | fp16 | 99.92 | 13.132 | – | 27NaN / inf output | 125 |
| Portable fp32 | fp32 | 5.60 | 0.417 | −0.01 | 27 | 151 |
| Portable | fp16 | 5.59 | 0.417 | ±0.00 | 27 | 91.8 |
| Kernels | fp16 | 5.60 | 0.416 | −0.01 | 27 | 74.2 |
| Original .half() | fp16 | 99.92 | 13.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
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 21.31 | 6.445 | reference | 15 | 564 |
| Original fp16 | fp16 | 100.00 | 71.272 | – | 15NaN / inf output | 468 |
| Portable fp32 | fp32 | 21.32 | 6.447 | −0.01 | 15 | 650 |
| Portable | fp16 | 21.32 | 6.447 | −0.01 | 15 | 405 |
| Kernels | fp16 | 21.32 | 6.444 | −0.01 | 15 | 332 |
| Original .half() | fp16 | 100.00 | 71.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.
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 px | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.05 px | 0.00193 px |
| GPU default dtypes, p99 |diff| | ≤ 0.5 px | 0.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 gatescutlass_convCUTLASS convolutions with the recurrent update (GRU) fused incudnn_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.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
cfnet-sceneflow | Middlebury 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-sceneflow1988x2880 (8.2 GiB peak allocated, 11.5 reserved) cfnet-sceneflow994x1482, first call: portable + torch.compile 53 s (cold Inductor cache), TensorRT fp16 139 s (ONNX + engine).cfnet-scenefloworiginal 994x1482: torch.autocast(float16) around the callcfnet-sceneflowload / 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.
| variant | dataset | original fp32 | original fp16 | original half | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|---|
cfnet-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 5.59 / 0.417 | 99.92 / 13.132 (NaN / inf output) | 99.92 / 13.132 (NaN / inf output) | 5.59 / 0.417 | 5.60 / 0.417 | 5.60 / 0.416 | |
cfnet-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 21.31 / 6.445 | 100.00 / 71.272 (NaN / inf output) | 100.00 / 71.272 (NaN / inf output) | 21.32 / 6.447 | 21.32 / 6.447 | 21.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.
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
cfnet-sceneflow | 0.00193 / 0.0126 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_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).
Input: Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), Scharstein et al., Middlebury College (research dataset, no licence stated).