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
- Paper Cascade Cost Volume for High-Resolution Multi-View Stereo and Stereo Matching CVPR 2020 · first released 13 Dec 2019
Paper 2019 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("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.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 862 | 0.66× | 10,079 MiB/10.4 GiB | 1.0 | 0.86 |
| Original fp16torch.autocast(float16) around the call | fp16 | 567 | – | 8,317 MiB/8,730 MiB | 0.4 | 0.64 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 472 | 1.2× | 2,338 MiB/2,794 MiB | 1.0 | 0.47 |
| Kernels | fp16 | 358 | 1.6× | 2,272 MiB/2,514 MiB | 0.2 | 0.36 |
| Portable + torch.compile | 383 | 1.5× | 6,592 MiB/6,670 MiB | 64 (build) | – | |
| TensorRT fp16 | fp16 | 307 | 1.8× | 4,046 MiBenginenot comparable | 99 (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
| 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 | 2995 | 7,182 MiB process | matches | 994x1482 | |
| Portable | fp32 | 5490 | 11.6 GiB process | matches | 994x1482 | |
| Kernels | fp16 | not implemented | – | 994x1482 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 600 | 2,232 MiB/2,446 MiB | – | 994x1482 |
| Kernels | fp16 | 500 | 2,255 MiB/2,470 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 193 | 2,232 MiB/2,446 MiB | – | 994x1482 |
| Kernels | fp16 | 159 | 2,255 MiB/2,470 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 380 | 2,232 MiB/2,446 MiB | – | 994x1482 |
| Kernels | fp16 | 345 | 2,237 MiB/2,450 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 153 | 2,232 MiB/2,446 MiB | – | 994x1482 |
| Kernels | fp16 | 136 | 2,237 MiB/2,450 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 93.6 | 2,303 MiB/2,768 MiB | – | 994x1482 |
| Kernels | fp16 | 78.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
-
- 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
casgwcnet.ckpt 132 MB· hosted on Alibaba Cloud OSSfastforks 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
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 8.08 | 0.821 | reference | 27 | 202 |
| Original fp16 | fp16 | 99.90 | 13.127 | – | 27NaN / inf output | 132 |
| Portable fp32 | fp32 | 8.08 | 0.822 | ±0.00 | 27 | 189 |
| Portable | fp16 | 8.08 | 0.823 | ±0.00 | 27 | 112 |
| Kernels | fp16 | 8.09 | 0.823 | −0.01 | 27 | 85.2 |
| Original .half() | fp16 | 99.92 | 13.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
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 23.83 | 6.541 | reference | 15 | 727 |
| Original fp16 | fp16 | 99.80 | 70.838 | – | 15NaN / inf output | 479 |
| Portable fp32 | fp32 | 23.84 | 6.548 | −0.01 | 15 | 672 |
| Portable | fp16 | 23.84 | 6.547 | −0.01 | 15 | 398 |
| Kernels | fp16 | 23.83 | 6.541 | ±0.00 | 15 | 302 |
| Original .half() | fp16 | 99.99 | 71.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.
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 px | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.05 px | 0.00441 px |
| GPU default dtypes, p99 |diff| | ≤ 0.5 px | 0.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 gatescutlass_convCUTLASS convolutions with the recurrent update (GRU) fused incudnn_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.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
cas-gwcnet-gc-sceneflow | Middlebury 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-sceneflow | Middlebury 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 32cas-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-sceneflow1988x2880 (9.4 GiB peak allocated, 14.1 reserved);cas-gwcnet-c-sceneflow1988x2880 (8.2 GiB peak allocated, 9.2 reserved) cas-gwcnet-gc-sceneflow994x1482, first call: portable + torch.compile 64 s (cold Inductor cache), TensorRT fp16 99 s (ONNX + engine).cas-gwcnet-c-sceneflow994x1482, first call: portable + torch.compile 62 s (cold Inductor cache), TensorRT fp16 131 s (ONNX + engine).cas-gwcnet-gc-scenefloworiginal 994x1482: torch.autocast(float16) around the callcas-gwcnet-c-scenefloworiginal 994x1482: torch.autocast(fp16) around the forwardcas-gwcnet-gc-sceneflowload / first call: original 0.39 s / 0.636 s, portable 0.97 s / 0.472† s, kernels 0.17† s / 0.358† scas-gwcnet-c-sceneflowload / 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.
| variant | dataset | original fp32 | original fp16 | original half | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|---|
cas-gwcnet-gc-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 8.08 / 0.821 | 99.90 / 13.127 (NaN / inf output) | 99.92 / 13.131 (NaN / inf output) | 8.08 / 0.823 | 8.08 / 0.822 | 8.09 / 0.823 | |
cas-gwcnet-gc-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 23.83 / 6.541 | 99.80 / 70.838 (NaN / inf output) | 99.99 / 71.114 (NaN / inf output) | 23.84 / 6.547 | 23.84 / 6.548 | 23.83 / 6.541 | |
cas-gwcnet-c-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 7.85 / 0.512 | 7.83 / 0.513 | 7.84 / 0.514 | 7.84 / 0.512 | 7.85 / 0.512 | 7.85 / 0.513 | |
cas-gwcnet-c-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 30.07 / 8.568 | 29.90 / 8.490 | 29.95 / 8.520 | 30.07 / 8.569 | 30.07 / 8.568 | 30.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.
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
cas-gwcnet-gc-sceneflow | 0.00441 / 0.07446 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120 |
cas-gwcnet-c-sceneflow | 0.00354 / 0.02642 | 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).