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
- Paper MoCha-Stereo: Motif Channel Attention Network for Stereo Matching CVPR 2024 · first released 10 Apr 2024
Paper 2024 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("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.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 2149 | 0.68× | 4,140 MiB/4,598 MiB | – | – |
| Original fp16 | fp16 | 1456 | – | 3,637 MiB/3,982 MiB | – | – |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 1057 | 1.4× | 1,632 MiB/1,770 MiB | 0.8 | 1.06 |
| Kernels | fp16 | 455 | 3.2× | 1,588 MiB/1,730 MiB | 0.5 | 0.45 |
| Portable + torch.compile | 735 | 2.0× | 1,129 MiB/1,268 MiB | 154 (build) | – | |
| TensorRT fp16 | fp16 | 447 | 3.3× | 1,162 MiBenginenot comparable | 371 (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
| 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 | 8561 | 8,058 MiB process | matches | 994x1482 |
| Portable | fp16 | 7967 | 5,765 MiB process | matches | 994x1482 | |
| Portable | fp32 | 9065 | 8,748 MiB process | matches | 994x1482 | |
| Kernels | fp16 | 6693 | 5,695 MiB process | matches | 994x1482 | |
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 1108 | 1,606 MiB/1,788 MiB | – | 994x1482 |
| Kernels | fp16 | 631 | 1,561 MiB/1,790 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 345 | 1,606 MiB/1,768 MiB | – | 994x1482 |
| Kernels | fp16 | 224 | 1,561 MiB/1,788 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 931 | 1,606 MiB/1,788 MiB | – | 994x1482 |
| Kernels | fp16 | 527 | 1,508 MiB/1,648 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 383 | 1,606 MiB/1,768 MiB | – | 994x1482 |
| Kernels | fp16 | 227 | 1,561 MiB/1,690 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 189 | 1,630 MiB/1,760 MiB | – | 994x1482 |
| Kernels | fp16 | 116 | 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
-
- 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
mocha-stereo.pth 391 MB· hosted on GitHubfastforks 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
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 4.35 | 1.087 | reference | 27 | 556 |
| Original fp16 | fp16 | 4.35 | 1.084 | ±0.00 | 27 | 415 |
| Portable fp32 | fp32 | 4.35 | 1.087 | ±0.00 | 27 | 471 |
| Portable | fp16 | 4.35 | 1.085 | ±0.00 | 27 | 281 |
| Kernels | fp16 | 4.35 | 1.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
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 9.56 | 2.584 | reference | 15 | 1837 |
| Original fp16 | fp16 | 9.57 | 2.582 | −0.01 | 15 | 1246 |
| Portable fp32 | fp32 | 9.57 | 2.586 | −0.01 | 15 | 1688 |
| Portable | fp16 | 9.57 | 2.588 | −0.01 | 15 | 900 |
| Kernels | fp16 | 9.56 | 2.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.
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 px | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.02 px | 0.00086 px |
| GPU default dtypes, p99 |diff| | ≤ 0.25 px | 0.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 gatesmochaMoCha-Stereo: fused LSTM gate updatecutlass_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 by Ziyang Chen et al. that adds motif channel attention to an IGEV-style volume.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
mocha-v1-sceneflow | Middlebury 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-sceneflow | Middlebury 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-sceneflow3000x4000 (12.2 GiB peak allocated, 15.2 reserved);mocha-v2-sceneflow3000x4000 (12.2 GiB peak allocated, 14.8 reserved) mocha-v1-sceneflow994x1482, first call: portable + torch.compile 154 s (cold Inductor cache), TensorRT fp16 371 s (ONNX + engine).mocha-v2-sceneflow994x1482, first call: portable + torch.compile 148 s (cold Inductor cache), TensorRT fp16 361 s (ONNX + engine).mocha-v1-sceneflowload / first call: original 1.95 s / 1.846 s (375x1242), portable 0.79 s / 1.057† s, kernels 0.48† s / 0.454† smocha-v2-sceneflowload / 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.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
mocha-v1-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 4.35 / 1.087 | 4.35 / 1.084 | 4.35 / 1.085 | 4.35 / 1.087 | 4.35 / 1.088 | |
mocha-v1-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 9.56 / 2.584 | 9.57 / 2.582 | 9.57 / 2.588 | 9.57 / 2.586 | 9.56 / 2.588 | |
mocha-v2-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 3.84 / 0.892 | 3.83 / 0.885 | 3.83 / 0.887 | 3.82 / 0.886 | 3.82 / 0.886 | |
mocha-v2-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 10.76 / 2.838 | 10.78 / 2.843 | 10.73 / 2.844 | 10.80 / 2.852 | 10.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.
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
mocha-v1-sceneflow | 0.00086 / 0.00467 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120, mocha@757b90f1dbe1:sm_120 |
mocha-v2-sceneflow | 0.00074 / 0.0025 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_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).
Input: Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), Scharstein et al., Middlebury College (research dataset, no licence stated).