Models · Stereo matching

MoCha-Stereo

A stereo network by Ziyang Chen et al. that adds motif channel attention to an IGEV-style volume.

stable Fork of ZYangChen/MoCha-Stereo@78c5889 · backends: portable, kernels

Checkpoint

Paper 2024 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 455 ms 994x1482, fp16
vs the faster original 3.2× original fp16: 1456 ms
Peak memory 1,588 MiB original: 3,637 MiB
Accuracy vs original fp32 ±0.00 kernels bad px %, ETH3D two-view train (4.35 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("mocha-v1-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 mocha-v1-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 21490.68×4,140 MiB/4,598 MiB––
Original fp16fp16 1456–3,637 MiB/3,982 MiB––
Portable fp32fp32not measured ––––
Portablefp16 10571.4×1,632 MiB/1,770 MiB0.81.06
Kernelsfp16 4553.2×1,588 MiB/1,730 MiB0.50.45
Portable + torch.compile 7352.0×1,129 MiB/1,268 MiB154 (build)–
TensorRT fp16fp16 4473.3×1,162 MiBenginenot comparable371 (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-12Originalfp328561 8,058 MiB processmatches994x1482
Portablefp167967 5,765 MiB processmatches994x1482
Portablefp329065 8,748 MiB processmatches994x1482
Kernelsfp166693 5,695 MiB processmatches994x1482
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp161108 1,606 MiB/1,788 MiB–994x1482
Kernelsfp16631 1,561 MiB/1,790 MiB–994x1482
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16345 1,606 MiB/1,768 MiB–994x1482
Kernelsfp16224 1,561 MiB/1,788 MiB–994x1482
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16931 1,606 MiB/1,788 MiB–994x1482
Kernelsfp16527 1,508 MiB/1,648 MiB–994x1482
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16383 1,606 MiB/1,768 MiB–994x1482
Kernelsfp16227 1,561 MiB/1,690 MiB–994x1482
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp16189 1,630 MiB/1,760 MiB–994x1482
Kernelsfp16116 1,585 MiB/1,688 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

mocha-stereo.pth 391 MB· hosted on GitHub

fastforks downloads and checks these files on first use (fastforks download mocha-v1-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 fp32fp324.351.087 reference 27 556
Original fp16fp164.351.084 ±0.00 27 415
Portable fp32fp324.351.087 ±0.00 27 471
Portablefp164.351.085 ±0.00 27 281
Kernelsfp164.351.088 ±0.00 27 151

Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: 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 fp32fp329.562.584 reference 15 1837
Original fp16fp169.572.582 −0.01 15 1246
Portable fp32fp329.572.586 −0.01 15 1688
Portablefp169.572.588 −0.01 15 900
Kernelsfp169.562.588 ±0.00 15 388

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

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 pxnot recorded
GPU default dtypes, mean |diff|≤ 0.02 px0.00086 px
GPU default dtypes, p99 |diff|≤ 0.25 px0.00467 px

Recorded for mocha-v1-sceneflow on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-02, with these kernels: cudnn_hacccutlass_convigevmocha

Details

MoCha-Stereo (Chen et al. 2024): EfficientNetV2-L features, a motif channel correlation volume next to an IGEV-style geometry volume, 3-level Mogrifier LSTM updates and a refinement step, 32 iterations. mocha-v2-sceneflow is an unofficial reconstruction (the authors released no V2 code).

Input / output
Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
Input size
any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (12.2 GiB allocated)
Options
  • iters=32>= 1· changes the output
Outputs
disparity
Checkpoint
mccv=true
CUDA kernels
  • igevIGEV stereo: convolution epilogues, correlation lookups, GRU gates
  • mochaMoCha-Stereo: fused LSTM gate update
  • 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 by Ziyang Chen et al. that adds motif channel attention to an IGEV-style volume.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
mocha-v1-sceneflowMiddlebury 2014 half (994x1482)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
2148
1456
1057
455
735
447
4140 / 4598
3637 / 3982
1632 / 1770
1588 / 1730
1129 / 1268
1466 / 1590
mocha-v2-sceneflowMiddlebury 2014 half (994x1482)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
2054
1295
1033
448
713
437
4017 / 4418
3576 / 3982
1632 / 1770
1587 / 1790
1122 / 1308
1400 / 1486
Details
  • Original code: https://github.com/ZYangChen/MoCha-Stereo at 78c5889c467f
  • Code licence: MIT (permissive); files: LICENSE
  • Weights licence: MIT (assumed from code)
  • Licence evidence: https://github.com/ZYangChen/MoCha-Stereo/blob/78c5889c467fe31414c9425f1280afc0a8f6c1a0/README.md#L69
  • Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa)
  • Options: iters = 32 (>= 1)
  • Kernel libraries: igev, mocha, cutlass_conv, cudnn_hacc
  • Variants: mocha-v1-sceneflow, mocha-v2-sceneflow
  • Outputs: disparity
  • Input size: any H x W >= 32, padded to a multiple of 32
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): mocha-v1-sceneflow 3000x4000 (12.2 GiB peak allocated, 15.2 reserved); mocha-v2-sceneflow 3000x4000 (12.2 GiB peak allocated, 14.8 reserved)
  • mocha-v1-sceneflow 994x1482, first call: portable + torch.compile 154 s (cold Inductor cache), TensorRT fp16 371 s (ONNX + engine).
  • mocha-v2-sceneflow 994x1482, first call: portable + torch.compile 148 s (cold Inductor cache), TensorRT fp16 361 s (ONNX + engine).
  • mocha-v1-sceneflow load / first call: original 1.95 s / 1.846 s (375x1242), portable 0.79 s / 1.057† s, kernels 0.48† s / 0.454† s
  • mocha-v2-sceneflow load / first call: original 2.37 s / 0.399 s (375x1242), portable 1.3 s / 1.033† s, kernels 0.45† s / 0.447† 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 fp16portableportable fp32kernelsnote
mocha-v1-sceneflowETH3D two-view train, bad > 1 px % / EPE4.35 / 1.0874.35 / 1.0844.35 / 1.0854.35 / 1.0874.35 / 1.088
mocha-v1-sceneflowMiddlebury 2014 trainingH, bad > 2 px % / EPE9.56 / 2.5849.57 / 2.5829.57 / 2.5889.57 / 2.5869.56 / 2.588
mocha-v2-sceneflowETH3D two-view train, bad > 1 px % / EPE3.84 / 0.8923.83 / 0.8853.83 / 0.8873.82 / 0.8863.82 / 0.886
mocha-v2-sceneflowMiddlebury 2014 trainingH, bad > 2 px % / EPE10.76 / 2.83810.78 / 2.84310.73 / 2.84410.80 / 2.85210.77 / 2.833

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.02 px and p99 <= 0.25 px.

variantkernels error vs original, mean / p99GPU, torchkernels used
mocha-v1-sceneflow0.00086 / 0.00467RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120, mocha@757b90f1dbe1:sm_120
mocha-v2-sceneflow0.00074 / 0.0025RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120, mocha@757b90f1dbe1: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).