Models · Stereo matching

NMRF

A stereo network from the CUHK T-Stone Robotics Institute that treats matching as Markov random field inference.

stable Fork of aeolusguan/NMRF@a50bd8f · backends: portable, kernels

Checkpoint nmrf-sceneflow

Paper 2024 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 196 ms 994x1482, fp16
vs the faster original 1.6× original fp16: 313 ms
Peak memory 1,022 MiB original: 1,656 MiB
Accuracy vs original fp32 −0.03 kernels bad px %, ETH3D two-view train (3.78 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("nmrf-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 nmrf-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 4450.70×2,300 MiB/2,426 MiB––
Original fp16torch.autocast(fp16) around the forwardfp16 313–1,656 MiB/2,054 MiB––
Portable fp32fp32not measured ––––
Portablefp16 2161.4×1,510 MiB/1,552 MiB0.10.22
Kernelsfp16 1961.6×1,022 MiB/1,112 MiB0.10.20
Portable + torch.compile 1611.9×854 MiB/1,104 MiB85 (build)–
TensorRT fp16fp16 1841.7×826 MiBenginenot comparable143 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-01 to 2026-11-03. 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. 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-14Originalfp321736 7,232 MiB processmatches994x1482
Portablefp161469 4,747 MiB processmatches994x1482
Portablefp321560 5,749 MiB processmatches994x1482
Kernelsfp161204 3,806 MiB processmatches994x1482
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16282 1,457 MiB/1,630 MiB–994x1482
Kernelsfp16239 969 MiB/1,090 MiB–994x1482
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1679.4 1,457 MiB/1,630 MiB–994x1482
Kernelsfp1664.6 969 MiB/1,090 MiB–994x1482
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16196 1,457 MiB/1,630 MiB–994x1482
Kernelsfp16173 969 MiB/1,090 MiB–994x1482
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1693.6 1,457 MiB/1,630 MiB–994x1482
Kernelsfp1684.4 969 MiB/1,090 MiB–994x1482
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1643.1 1,481 MiB/1,630 MiB–994x1482
Kernelsfp1637.7 993 MiB/1,110 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.pth 24.6 MB· hosted on Google Drive

fastforks downloads and checks these files on first use (fastforks download nmrf-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 fp32fp323.780.311 reference 27 95.9
Original fp16fp163.810.313 −0.03 27 61.9
Portable fp32fp323.780.311 ±0.00 27 90.0
Portablefp163.810.311 −0.03 27 50.1
Kernelsfp163.810.311 −0.03 27 41.2
Original .half()fp16fails: RuntimeError: expected scalar type Float but found Half

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 fp32fp3213.362.920 reference 15 380
Original fp16fp1613.352.914 +0.01 15 264
Portable fp32fp3213.362.921 ±0.00 15 345
Portablefp1613.352.915 +0.01 15 189
Kernelsfp1613.352.915 +0.01 15 168
Original .half()fp16fails: RuntimeError: expected scalar type Float but found Half

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.05 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.05 pxnot recorded
GPU default dtypes, mean |diff|≤ 0.05 px0.00236 px
GPU default dtypes, p99 |diff|≤ 0.5 px0.03745 px
real_gpu_mean≤ 0.1 pxnot recorded
real_gpu_p99≤ 1.5 pxnot recorded

Recorded for nmrf-sceneflow on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-01, with these kernels: fastbb

Details

NMRF (Guan et al. 2024): neural Markov random field with disparity proposals from a group-wise cost volume, CSWin label-seed propagation and window-attention inference at 1/8 resolution plus a 1/4 refinement.

Input / output
Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
Input size
any H x W >= 9, padded to a multiple of 8; tested up to 3000x4000 (11.0 GiB allocated)
Outputs
disparity
CUDA kernels
  • fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbones
Apple (MPS)
stereo_metalMetal: stereo kernels. fp32, fp16

Limitations

  • ONNX Runtime resolves top-k ties differently from PyTorch on noise pairs: nmrf-sceneflow differs by up to 0.56 px (mean 0.006) on a synthetic textured pair.
Full reference, generated from the repository

A stereo network from the CUHK T-Stone Robotics Institute that treats matching as Markov random field inference.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
nmrf-sceneflowMiddlebury 2014 half (994x1482)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
445
313
216
196
161
184
2300 / 2426
1656 / 2054
1510 / 1552
1022 / 1112
854 / 1104
1027 / 1134
Details
  • Original code: https://github.com/aeolusguan/NMRF at a50bd8f407ae
  • Code licence: MIT (permissive); files: LICENSE
  • Weights licence: MIT (assumed from code)
  • Licence evidence: https://github.com/aeolusguan/NMRF/blob/a50bd8f407ae481c38f95cf141e1b5256e962cb7/README.md#L103
  • Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa)
  • Kernel libraries: fastbb
  • Variants: nmrf-sceneflow
  • Outputs: disparity
  • Input size: any H x W >= 9, padded to a multiple of 8
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): nmrf-sceneflow 3000x4000 (11.0 GiB peak allocated, 13.3 reserved)
  • nmrf-sceneflow 994x1482, first call: portable + torch.compile 85 s (cold Inductor cache), TensorRT fp16 142 s (ONNX + engine).
  • nmrf-sceneflow original 994x1482: torch.autocast(fp16) around the forward
  • nmrf-sceneflow load / first call: original 0.21 s / 0.766 s (375x1242), portable 0.1 s / 0.218† s, kernels 0.07† s / 0.197† s
  • † 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.

variantdatasetoriginal fp32original fp16original halfportableportable fp32kernelsnote
nmrf-sceneflowETH3D two-view train, bad > 1 px % / EPE3.78 / 0.3113.81 / 0.312fails (RuntimeError: expected scalar type Float but found Half)3.81 / 0.3113.78 / 0.3113.81 / 0.311
nmrf-sceneflowMiddlebury 2014 trainingH, bad > 2 px % / EPE13.36 / 2.92013.35 / 2.914fails (RuntimeError: expected scalar type Float but found Half)13.35 / 2.91513.36 / 2.92113.35 / 2.915

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 468fba10, 2026-11-05.

Parity

CPU, float32: max |diff| <= 0.05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 px and p99 <= 0.5 px. On real pairs up to 720x1280 the limits are mean 0.1 / p99 1.5 (precision-sensitive there, see Limitations).

variantkernels error vs original, mean / p99GPU, torchkernels used
nmrf-sceneflow0.00236 / 0.03745RTX 5060 Ti, torch 2.14.1+cu130fastbb@7d058322634d:sm_120

Limitations

  • ONNX Runtime resolves top-k ties differently from PyTorch on noise pairs: nmrf-sceneflow differs by up to 0.56 px (mean 0.006) on a synthetic textured pair.

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).