AANet
A stereo network that aggregates matching costs with sparse deformable sampling across scales, trained on synthetic SceneFlow data.
stable Fork of haofeixu/aanet@8d0d747 · backends: portable, kernels
- Paper AANet: Adaptive Aggregation Network for Efficient Stereo Matching CVPR 2020 · first released 20 Apr 2020
Paper 2020 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("aanet-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 aanet-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 fp32deformable conv via torchvision.ops.deform_conv2d (original CUDA extension not built) | fp32 | 289 | 0.62× | 1,785 MiB/1,962 MiB | – | – |
| Original fp16torch.autocast(fp16) around the forward; deformable conv via torchvision.ops.deform_conv2d (original CUDA extension not built) | fp16 | 178 | – | 1,000 MiB/1,126 MiB | – | – |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 140 | 1.3× | 845 MiB/986 MiB | 0.2 | 0.14 |
| Kernels | fp16 | 101 | 1.8× | 536 MiB/644 MiB | 0.3 | 0.10 |
| Portable + torch.compile | 91.8 | 1.9× | 754 MiB/928 MiB | 80 (build) | – | |
| TensorRT fp16 | fp16 | 91.2 | 2.0× | 482 MiBenginenot comparable | 211 (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-14 | Original | fp32 | 813 | 3,710 MiB process | matches | 994x1482 |
| Portable | fp16 | 1141 | 3,626 MiB process | matches | 994x1482 | |
| Portable | fp32 | 912 | 3,604 MiB process | matches | 994x1482 | |
| Kernels | fp16 | 631 | 2,606 MiB process | matches | 994x1482 | |
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 192 | 819 MiB/922 MiB | – | 994x1482 |
| Kernels | fp16 | 140 | 502 MiB/620 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 62.7 | 819 MiB/922 MiB | – | 994x1482 |
| Kernels | fp16 | 44.7 | 502 MiB/620 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 148 | 819 MiB/922 MiB | – | 994x1482 |
| Kernels | fp16 | 105 | 502 MiB/620 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 82.0 | 819 MiB/922 MiB | – | 994x1482 |
| Kernels | fp16 | 49.6 | 502 MiB/620 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 36.8 | 843 MiB/982 MiB | – | 994x1482 |
| Kernels | fp16 | 20.9 | 502 MiB/620 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
- Apache-2.0 LICENSE
- Weights
- Apache-2.0 (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
aanet_sceneflow.pth 16.3 MB· hosted on Google Drivefastforks downloads and checks these files on first use (fastforks download aanet-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 | 14.64 | 0.697 | reference | 27 | 66.1 |
| Original fp16 | fp16 | 14.63 | 0.697 | +0.01 | 27 | 77.2 |
| Portable fp32 | fp32 | 14.64 | 0.698 | ±0.00 | 27 | 87.8 |
| Portable | fp16 | 14.63 | 0.697 | +0.01 | 27 | 48.8 |
| Kernels | fp16 | 14.64 | 0.698 | ±0.00 | 27 | 31.1 |
| Original .half() | fp16 | 14.61 | 0.698 | +0.03 | 27 | 54.4 |
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 | 32.15 | 6.305 | reference | 15 | 257 |
| Original fp16 | fp16 | 32.15 | 6.301 | ±0.00 | 15 | 169 |
| Portable fp32 | fp32 | 32.15 | 6.306 | ±0.00 | 15 | 260 |
| Portable | fp16 | 32.16 | 6.301 | −0.01 | 15 | 126 |
| Kernels | fp16 | 32.16 | 6.303 | −0.01 | 15 | 90.0 |
| Original .half() | fp16 | 32.13 | 6.301 | +0.02 | 15 | 136 |
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.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.00403 px |
| GPU default dtypes, p99 |diff| | ≤ 0.25 px | 0.04845 px |
Recorded for aanet-sceneflow on RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-31, with these kernels: cudnn_hacccutlass_convdeform_convigev
Details
AANet (Xu and Zhang 2020): sparse deformable-sampling cost aggregation within and across scales on a 2-D correlation pyramid, without 3-D convolutions.
- Input / output
- Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
- Input size
- any H x W >= 48, padded to a multiple of 48; tested up to 3000x4000 (9,603 MiB allocated)
- Outputs
disparity- Checkpoint
plus=false- CUDA kernels
deform_convdeformable convolution fused into one kerneligevIGEV stereo: convolution epilogues, correlation lookups, GRU gatescutlass_convCUTLASS convolutions with the recurrent update (GRU) fused incudnn_haccconvolutions with fp16 accumulation (cuDNN)
- Apple (MPS)
stereo_metalMetal: stereo kernels. fp32, fp16
Limitations
- Only the SceneFlow checkpoints of AANet and AANet+ are included; the original code's KITTI fine-tunes are not.
- At 375x1242 AANet is launch-bound: portable is about as fast as the original code. At 994x1482 portable is faster but allocates more memory.
Full reference, generated from the repository
A stereo network that aggregates matching costs with sparse deformable sampling across scales, trained on synthetic SceneFlow data.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
aanet-sceneflow | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 289 178 140 101 91.8 91.2 | 1785 / 1962 1000 / 1126 845 / 986 536 / 644 754 / 928 602 / 620 |
aanet-plus-sceneflow | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 263 194 159 88.9 143 202 | 3618 / 3896 3652 / 3784 1142 / 1278 813 / 920 3020 / 3716 1786 / 1834 |
Details
- Original code: https://github.com/haofeixu/aanet at
8d0d747e69bb - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0 (assumed from code)
- Licence evidence: https://github.com/haofeixu/aanet/blob/8d0d747e69bbdba43e2578b60ad7df63ba7fdac2/LICENSE
- Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa)
- Kernel libraries:
deform_conv,igev,cutlass_conv,cudnn_hacc - Variants:
aanet-sceneflow,aanet-plus-sceneflow - Outputs: disparity
- Input size:
aanet-sceneflow: any H x W >= 48, padded to a multiple of 48aanet-plus-sceneflow: any H x W >= 96, padded to a multiple of 96
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
aanet-sceneflow3000x4000 (9.4 GiB peak allocated, 12.5 reserved);aanet-plus-sceneflow1024x2048 (7.1 GiB peak allocated, 8.1 reserved) aanet-sceneflow994x1482, first call: portable + torch.compile 80 s (cold Inductor cache), TensorRT fp16 211 s (ONNX + engine).aanet-plus-sceneflow994x1482, first call: portable + torch.compile 89 s (cold Inductor cache), TensorRT fp16 145 s (ONNX + engine).aanet-scenefloworiginal (fp32) 994x1482: deformable conv via torchvision.ops.deform_conv2d (original CUDA extension not built)aanet-scenefloworiginal 994x1482: torch.autocast(fp16) around the forward; deformable conv via torchvision.ops.deform_conv2d (original CUDA extension not built)aanet-plus-scenefloworiginal (fp32) 994x1482: deformable conv via torchvision.ops.deform_conv2d (original CUDA extension not built)aanet-plus-scenefloworiginal 994x1482: torch.autocast(fp16) around the forward; deformable conv via torchvision.ops.deform_conv2d (original CUDA extension not built)aanet-sceneflowload / first call: original 0.12 s / 0.067 s (375x1242), portable 0.19 s / 0.143† s, kernels 0.27† s / 0.101† saanet-plus-sceneflowload / first call: original 0.15 s / 0.701 s (375x1242), portable 0.16 s / 0.166† s, kernels 0.2† s / 0.09† 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 |
|---|---|---|---|---|---|---|---|---|
aanet-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 14.64 / 0.697 | 14.63 / 0.697 | 14.61 / 0.698 | 14.63 / 0.697 | 14.64 / 0.698 | 14.64 / 0.698 | |
aanet-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 32.15 / 6.305 | 32.15 / 6.301 | 32.13 / 6.301 | 32.16 / 6.301 | 32.15 / 6.306 | 32.16 / 6.303 | |
aanet-plus-sceneflow | ETH3D two-view train, bad > 1 px % / EPE | 18.48 / 0.811 | 18.50 / 0.812 | 18.71 / 0.820 | 18.50 / 0.811 | 18.48 / 0.811 | 18.50 / 0.812 | |
aanet-plus-sceneflow | Middlebury 2014 trainingH, bad > 2 px % / EPE | 29.84 / 6.237 | 29.85 / 6.236 | 29.86 / 6.297 | 29.86 / 6.237 | 29.84 / 6.237 | 29.86 / 6.232 |
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 |
|---|---|---|---|
aanet-sceneflow | 0.00403 / 0.04845 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, deform_conv@a38662ea1bfc:sm_120, igev@f075827d68c6:sm_120 |
aanet-plus-sceneflow | 0.00295 / 0.02185 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, deform_conv@a38662ea1bfc:sm_120, igev@f075827d68c6:sm_120 |
Limitations
- Only the SceneFlow checkpoints of AANet and AANet+ are included; the original code's KITTI fine-tunes are not.
- At 375x1242 AANet is launch-bound: portable is about as fast as the original code. At 994x1482 portable is faster but allocates more memory.
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).