HITNet
Google Research's tile-based stereo model; the authors' ETH3D and Middlebury versions, ported to PyTorch.
stable Fork of google-research/google-research@f200f2b · backends: portable, kernels
- Paper HITNet: Hierarchical Iterative Tile Refinement Network for Real-time Stereo Matching CVPR 2021 · first released 23 Jul 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("hitnet-eth3d") # kernels on a supported GPU, else portable PyTorch
result = model(left, right)
result.disparity
result.backend # what ran: mode, device, dtype, kernels fastforks bench hitnet-eth3d 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 fp32TensorFlow 2.21.0 frozen graph eth3d.pb, float32 | fp32 | 234 | 0.78× | 2,961 MiB | 2.6 | 2.44 |
| Original fp16TensorFlow 2.21.0 frozen graph eth3d.pb, auto_mixed_precision graph rewrite (float16) | fp16 | 182 | – | 2,433 MiB | 0.3 | 2.06 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 67.6 | 2.7× | 848 MiB/1,068 MiB | 0.2 | 0.07 |
| Kernels | fp16 | 23.2 | 7.9× | 623 MiB/770 MiB | 0.3 | 0.03 |
| Portable + torch.compile | 27.7 | 6.6× | 719 MiB/728 MiB | 39 (build) | – | |
| TensorRT fp16 | fp16 | 31.1 | 5.9× | 836 MiBenginenot comparable | 136 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-06 to 2026-11-16. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. 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-13 | Original | fp32 | cannot run here | – | 994x1482 | |
| Portable | fp16 | 501 | 5,510 MiB process | matches | 994x1482 | |
| Portable | fp32 | 484 | 5,503 MiB process | matches | 994x1482 | |
| Kernels | fp16 | 136 | 2,486 MiB process | matches | 994x1482 | |
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 94.1 | 857 MiB/1,088 MiB | – | 994x1482 |
| Kernels | fp16 | 31.4 | 632 MiB/770 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 31.2 | 857 MiB/1,088 MiB | – | 994x1482 |
| Kernels | fp16 | 11.0 | 632 MiB/770 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 65.4 | 857 MiB/1,088 MiB | – | 994x1482 |
| Kernels | fp16 | 28.3 | 632 MiB/770 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 32.2 | 857 MiB/1,088 MiB | – | 994x1482 |
| Kernels | fp16 | 16.9 | 632 MiB/770 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 14.4 | 857 MiB/1,068 MiB | – | 994x1482 |
| Kernels | fp16 | 6.22 | 632 MiB/770 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
-
- ETH3D two-view stereo CC-BY-NC-SA-4.0, non-commercial
- weights licence not stated by the original authors; assumed to be the code licence
- The authors state no weights licence; the checkpoints are fetched from the PINTO model-zoo mirror (a third-party host), not from Google, and the code licence is assumed to cover them.
Our reading of the licences, not legal advice.
Weights
eth3d.pb 3.4 MB· inside a 440 MB archive· hosted on s3.ap-northeast-2.wasabisys.comfastforks downloads and checks these files on first use (fastforks download hitnet-eth3d).
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 % / EPEtrained on this dataset’s public images: not zero-shot
| Run | dtype | bad px % ↓ | EPE ↓ | Δ bad px % vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 0.94 | 0.164 | reference | 27 | 101 |
| Original fp16 | fp16 | 0.93 | 0.165 | +0.01 | 27 | 88.5 |
| Portable fp32 | fp32 | 0.93 | 0.164 | +0.01 | 27 | 27.4 |
| Portable | fp16 | 0.93 | 0.164 | +0.01 | 27 | 21.2 |
| Kernels | fp16 | 0.93 | 0.164 | +0.01 | 27 | 9.55 |
Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch null, 2026-11-06; 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 | 17.26 | 8.332 | reference | 15 | 1078 |
| Original fp16 | fp16 | 17.30 | 8.356 | −0.04 | 15 | 946 |
| Portable fp32 | fp32 | 17.28 | 8.348 | −0.02 | 15 | 98.8 |
| Portable | fp16 | 17.25 | 8.340 | +0.01 | 15 | 65.0 |
| Kernels | fp16 | 17.27 | 8.297 | −0.01 | 15 | 21.9 |
Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch null, 2026-11-06; 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.02 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.15 px and p99 <= 1.0 px.
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.02 px | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.15 px | 0.00343 px |
| GPU default dtypes, p99 |diff| | ≤ 1 px | 0.02548 px |
| real_gpu_mean | ≤ 0.3 px | not recorded |
| real_gpu_p99 | ≤ 6 px | not recorded |
Recorded for hitnet-eth3d on RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-31, with these kernels: hitnethitnet_conv
Details
HITNet (Tankovich et al. 2021): slanted tile hypotheses propagated and refined from coarse to fine; the authors' ETH3D (gray, max disparity 128) and Middlebury (half resolution, max disparity 400) graphs.
- Input / output
- Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
- Input size
- any H x W >= 8, resized or padded inside the model; tested up to 3000x4000 (6,558 MiB allocated)
- Options
cuda_graphs=true
- Outputs
disparity- Checkpoint
in_ch=1,channels=[16,16,24,24,32],disparities=[8,16,32,64,128],refine_channels=[32,32,16],refine_dilations=[[1,3,1,1],[1,3,1,1],[1,1]],refine_sad_scale=[0,0,0],pad_multiple=64,pad_value=0,pad_value_right=0- CUDA kernels
hitnetHITNet: cost initialisation, tile and warp matchinghitnet_convHITNet: fused convolutions
- Apple (MPS)
stereo_metalMetal: stereo kernels. fp32, fp16
Limitations
- CUDA output (float16, kernels, float32 with PyTorch's default TF32 convolutions) differs from the CPU by ~0.2 px mean / 4 px p99 at 720x1280: the argmin flips on near-equal tile costs. Full float32 (`torch.backends.cudnn.allow_tf32 = False`) matches the CPU to 0.00002 px.
- The weights are the authors' frozen TensorFlow graphs read without TensorFlow; the FlyingThings and Middlebury d160 / d288 graphs are not included.
- The original code is TensorFlow (frozen graph run with TensorFlow 2.21 on the GPU); its time is the upstream row, its memory is the TensorFlow peak (TensorFlow has no reserved-memory counter).
Full reference, generated from the repository
Google Research's tile-based stereo model; the authors' ETH3D and Middlebury versions, ported to PyTorch.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
hitnet-eth3d | synthetic (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 234 182 67.6 23.2 27.7 31.1 | 2961 / – 2433 / – 848 / 1068 623 / 770 719 / 728 912 / 920 |
hitnet-middlebury-d400 | synthetic (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 637 483 176 53.1 71.5 74.9 | 7157 / – 6831 / – 1701 / 2154 1207 / 1514 1296 / 1332 1985 / 2014 |
Details
- Original code: https://github.com/google-research/google-research at
f200f2b89d29 - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0 (assumed from code)
- Licence evidence: https://github.com/google-research/google-research/blob/f200f2b89d29484bf0dd0fef0c3979ac8bed9af4/LICENSE
- Training data: not stated by the authors
hitnet-eth3d: ETH3D two-view stereo (fine-tuned on the ETH3D training pairs (paper); any pre-training data is not stated by the authors)hitnet-middlebury-d400: Middlebury stereo (2014) (trained for half-resolution Middlebury images (README); any pre-training data is not stated by the authors)
- Licence note: The authors state no weights licence; the checkpoints are fetched from the PINTO model-zoo mirror (a third-party host), not from Google, and the code licence is assumed to cover them.
- Options:
cuda_graphs= True (speed only) - Kernel libraries:
hitnet,hitnet_conv - Variants:
hitnet-eth3d,hitnet-middlebury-d400 - Outputs: disparity
- Input size: any H x W >= 8, resized or padded inside the model
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
hitnet-eth3d3000x4000 (6.4 GiB peak allocated, 10.8 reserved);hitnet-middlebury-d4001988x2880 (6.4 GiB peak allocated, 10.1 reserved) hitnet-eth3d994x1482, first call: portable + torch.compile 39 s (cold Inductor cache), TensorRT fp16 136 s (ONNX + engine).hitnet-middlebury-d400994x1482, first call: portable + torch.compile 55 s (cold Inductor cache), TensorRT fp16 166 s (ONNX + engine).hitnet-eth3doriginal (fp32) 994x1482: TensorFlow 2.21.0 frozen graph eth3d.pb, float32hitnet-eth3doriginal 994x1482: TensorFlow 2.21.0 frozen graph eth3d.pb, auto_mixed_precision graph rewrite (float16)hitnet-middlebury-d400original (fp32) 994x1482: TensorFlow 2.21.0 frozen graph middlebury_d400.pb, float32hitnet-middlebury-d400original 994x1482: TensorFlow 2.21.0 frozen graph middlebury_d400.pb, auto_mixed_precision graph rewrite (float16)hitnet-eth3dload / first call: original 0.31 s / 2.061 s, portable 0.18 s / 0.45 s (375x1242), kernels 0.27 s / 0.283 s (375x1242)hitnet-middlebury-d400load / first call: original 0.57 s / 3.512 s, portable 0.18 s / 0.484 s (375x1242), kernels 0.36 s / 0.227 s (375x1242)- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Measured
Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
hitnet-eth3d | ETH3D two-view train, bad > 1 px % / EPE | 0.94 / 0.164 | 0.93 / 0.165 | 0.93 / 0.164 | 0.93 / 0.164 | 0.93 / 0.164 | trained on this dataset's public images; not a zero-shot result |
hitnet-eth3d | Middlebury 2014 trainingH, bad > 2 px % / EPE | 17.26 / 8.332 | 17.30 / 8.356 | 17.25 / 8.340 | 17.28 / 8.348 | 17.27 / 8.297 | |
hitnet-middlebury-d400 | ETH3D two-view train, bad > 1 px % / EPE | 7.02 / 0.885 | 7.00 / 0.880 | 7.01 / 0.899 | 7.03 / 0.882 | 7.07 / 0.875 | |
hitnet-middlebury-d400 | Middlebury 2014 trainingH, bad > 2 px % / EPE | 7.50 / 1.180 | 7.51 / 1.185 | 7.54 / 1.187 | 7.50 / 1.186 | 7.51 / 1.168 | trained on this dataset's public images; not a zero-shot result |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 468fba10, 2026-11-05.
Parity
CPU, float32: max |diff| <= 0.02 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.15 px and p99 <= 1.0 px. On real pairs up to 720x1280 the limits are mean 0.3 / p99 6.0 (precision-sensitive there, see Limitations).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
hitnet-eth3d | 0.00343 / 0.02548 | RTX 5060 Ti, torch 2.14.1+cu130 | hitnet@45145b49dcb1:sm_120, hitnet_conv@e5637e8a93cf:sm_120 |
hitnet-middlebury-d400 | 0.1139 / 0.74705 | RTX 5060 Ti, torch 2.14.1+cu130 | hitnet@45145b49dcb1:sm_120, hitnet_conv@e5637e8a93cf:sm_120 |
Limitations
- CUDA output (float16, kernels, float32 with PyTorch's default TF32 convolutions) differs from the CPU by ~0.2 px mean / 4 px p99 at 720x1280: the argmin flips on near-equal tile costs. Full float32 (
torch.backends.cudnn.allow_tf32 = False) matches the CPU to 0.00002 px. - The weights are the authors' frozen TensorFlow graphs read without TensorFlow; the FlyingThings and Middlebury d160 / d288 graphs are not included.
- The original code is TensorFlow (frozen graph run with TensorFlow 2.21 on the GPU); its time is the upstream row, its memory is the TensorFlow peak (TensorFlow has no reserved-memory counter).
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).