Models · Stereo matching

Cas-GwcNet

Alibaba's cascade version of GwcNet: two cost-volume stages, the second narrowed around the first disparity. Trained on synthetic data.

stable Fork of alibaba/cascade-stereo@2ae7da6 · backends: portable, kernels

Checkpoint

Paper 2019 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 358 ms 994x1482, fp16
vs the faster original 1.6× original fp16: 567 ms
Peak memory 2,272 MiB original: 8,317 MiB
Accuracy vs original fp32 −0.01 kernels bad px %, ETH3D two-view train (8.08 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("cas-gwcnet-gc-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 cas-gwcnet-gc-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 8620.66×10,079 MiB/10.4 GiB1.00.86
Original fp16torch.autocast(float16) around the callfp16 567–8,317 MiB/8,730 MiB0.40.64
Portable fp32fp32not measured ––––
Portablefp16 4721.2×2,338 MiB/2,794 MiB1.00.47
Kernelsfp16 3581.6×2,272 MiB/2,514 MiB0.20.36
Portable + torch.compile 3831.5×6,592 MiB/6,670 MiB64 (build)–
TensorRT fp16fp16 3071.8×4,046 MiBenginenot comparable99 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-06. 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-12Originalfp32out of memory–994x1482
Portablefp162995 7,182 MiB processmatches994x1482
Portablefp325490 11.6 GiB processmatches994x1482
Kernelsfp16not implemented–994x1482
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16600 2,232 MiB/2,446 MiB–994x1482
Kernelsfp16500 2,255 MiB/2,470 MiB–994x1482
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16193 2,232 MiB/2,446 MiB–994x1482
Kernelsfp16159 2,255 MiB/2,470 MiB–994x1482
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16380 2,232 MiB/2,446 MiB–994x1482
Kernelsfp16345 2,237 MiB/2,450 MiB–994x1482
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16153 2,232 MiB/2,446 MiB–994x1482
Kernelsfp16136 2,237 MiB/2,450 MiB–994x1482
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1693.6 2,303 MiB/2,768 MiB–994x1482
Kernelsfp1678.8 2,237 MiB/2,452 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

casgwcnet.ckpt 132 MB· hosted on Alibaba Cloud OSS

fastforks downloads and checks these files on first use (fastforks download cas-gwcnet-gc-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 fp32fp328.080.821 reference 27 202
Original fp16fp1699.9013.127 – 27NaN / inf output 132
Portable fp32fp328.080.822 ±0.00 27 189
Portablefp168.080.823 ±0.00 27 112
Kernelsfp168.090.823 −0.01 27 85.2
Original .half()fp1699.9213.131 – 27NaN / inf output 118

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 fp32fp3223.836.541 reference 15 727
Original fp16fp1699.8070.838 – 15NaN / inf output 479
Portable fp32fp3223.846.548 −0.01 15 672
Portablefp1623.846.547 −0.01 15 398
Kernelsfp1623.836.541 ±0.00 15 302
Original .half()fp1699.9971.114 – 15NaN / inf output 431

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.00441 px
GPU default dtypes, p99 |diff|≤ 0.5 px0.07446 px

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

Details

Cas-GwcNet (cascade stereo, Gu et al. 2020): two-stage cascade cost volume (48 then 24 disparity hypotheses, the second narrowed around the first result) on GwcNet-style 3-D hourglasses; group-wise correlation + concatenation (gc) or concatenation (c) volumes.

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 1988x2880 (9,664 MiB allocated)
Outputs
disparity
Checkpoint
arch="gc"
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)
fp32, fp16
Full reference, generated from the repository

Alibaba's cascade version of GwcNet: two cost-volume stages, the second narrowed around the first disparity. Trained on synthetic data.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
cas-gwcnet-gc-sceneflowMiddlebury 2014 half (994x1482)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
862
567
472
358
383
307
10079 / 10652
8317 / 8730
2338 / 2794
2272 / 2514
6592 / 6670
4142 / 4194
cas-gwcnet-c-sceneflowMiddlebury 2014 half (994x1482)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
656
389
327
225
295
220
4816 / 5534
2791 / 2970
2006 / 2474
1725 / 1930
2098 / 2448
1533 / 1548
Details
  • Original code: https://github.com/alibaba/cascade-stereo at 2ae7da65515c
  • Code licence: MIT (permissive); files: LICENSE
  • Weights licence: MIT (assumed from code)
  • Licence evidence: https://github.com/alibaba/cascade-stereo/blob/2ae7da65515c82025383a0fbee8d6fe063dc7101/CasStereoNet/README.md#L17-L19
  • Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa)
  • Kernel libraries: igev, cutlass_conv, cudnn_hacc
  • Variants: cas-gwcnet-gc-sceneflow, cas-gwcnet-c-sceneflow
  • Outputs: disparity
  • Input size:
    • cas-gwcnet-gc-sceneflow: any H x W >= 32, padded to a multiple of 32
    • cas-gwcnet-c-sceneflow: any H x W >= 225, padded to a multiple of 32
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): cas-gwcnet-gc-sceneflow 1988x2880 (9.4 GiB peak allocated, 14.1 reserved); cas-gwcnet-c-sceneflow 1988x2880 (8.2 GiB peak allocated, 9.2 reserved)
  • cas-gwcnet-gc-sceneflow 994x1482, first call: portable + torch.compile 64 s (cold Inductor cache), TensorRT fp16 99 s (ONNX + engine).
  • cas-gwcnet-c-sceneflow 994x1482, first call: portable + torch.compile 62 s (cold Inductor cache), TensorRT fp16 131 s (ONNX + engine).
  • cas-gwcnet-gc-sceneflow original 994x1482: torch.autocast(float16) around the call
  • cas-gwcnet-c-sceneflow original 994x1482: torch.autocast(fp16) around the forward
  • cas-gwcnet-gc-sceneflow load / first call: original 0.39 s / 0.636 s, portable 0.97 s / 0.472† s, kernels 0.17† s / 0.358† s
  • cas-gwcnet-c-sceneflow load / first call: original 0.48 s / 0.415 s (375x1242), portable 1.29 s / 0.327† s, kernels 0.18† s / 0.226† 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
cas-gwcnet-gc-sceneflowETH3D two-view train, bad > 1 px % / EPE8.08 / 0.82199.90 / 13.127 (NaN / inf output)99.92 / 13.131 (NaN / inf output)8.08 / 0.8238.08 / 0.8228.09 / 0.823
cas-gwcnet-gc-sceneflowMiddlebury 2014 trainingH, bad > 2 px % / EPE23.83 / 6.54199.80 / 70.838 (NaN / inf output)99.99 / 71.114 (NaN / inf output)23.84 / 6.54723.84 / 6.54823.83 / 6.541
cas-gwcnet-c-sceneflowETH3D two-view train, bad > 1 px % / EPE7.85 / 0.5127.83 / 0.5137.84 / 0.5147.84 / 0.5127.85 / 0.5127.85 / 0.513
cas-gwcnet-c-sceneflowMiddlebury 2014 trainingH, bad > 2 px % / EPE30.07 / 8.56829.90 / 8.49029.95 / 8.52030.07 / 8.56930.07 / 8.56830.07 / 8.574

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
cas-gwcnet-gc-sceneflow0.00441 / 0.07446RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120
cas-gwcnet-c-sceneflow0.00354 / 0.02642RTX 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).