Models · Multi-view depth

PatchmatchNet

PatchmatchNet by Fangjinhua Wang et al.: learned PatchMatch multi-view stereo, depth from posed images.

stable Fork of FangjinhuaWang/PatchmatchNet@8dc6cb4 · backends: portable, kernels

Checkpoint patchmatchnet

Paper 2020 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 29.5 ms 1536x1024, fp16
vs the faster original 7.4× original fp16: 220 ms
Peak memory 648 MiB original: 1,228 MiB
Accuracy vs original fp32 ±0.0000 kernels AbsRel, DTU scans 1 (0.0087 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import multiview

model = multiview.load("patchmatchnet")  # kernels on a supported GPU, else portable PyTorch
result = model(images)
result.depth  # also: confidence
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench patchmatchnet

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.

Input: synthetic, 1536x1024

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 2480.89×1,330 MiB/1,412 MiB0.00.39
Original fp16torch.autocast(fp16) around the forwardfp16 220–1,228 MiB/1,272 MiB0.00.92
Portable fp32fp32not measured ––––
Portablefp16 2011.1×1,039 MiB/1,212 MiB0.20.86
Kernelsfp16 29.57.4×648 MiB/772 MiB0.20.56
Portable + torch.compile 1751.3×1,798 MiB/1,888 MiB29 (build)–
TensorRT fp16fp16 51.04.3×844 MiBenginenot comparable82 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-15. 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

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp32875 3,724 MiB processmatches1536x1024
Portablefp161574 6,591 MiB processmatches1536x1024
Portablefp321010 7,593 MiB processmatches1536x1024
Kernelsfp16not implemented–1536x1024
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16273 1,690 MiB/1,892 MiB–1536x1024
Kernelsfp1634.2 624 MiB/752 MiB–1536x1024
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1682.5 1,690 MiB/1,892 MiB–1536x1024
Kernelsfp1611.5 624 MiB/752 MiB–1536x1024
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16260 1,690 MiB/1,892 MiB–1536x1024
Kernelsfp1630.1 624 MiB/752 MiB–1536x1024
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1687.9 1,690 MiB/1,892 MiB–1536x1024
Kernelsfp1621.9 624 MiB/752 MiB–1536x1024
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1639.6 1,714 MiB/1,892 MiB–1536x1024
Kernelsfp167.95 648 MiB/772 MiB–1536x1024

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
  • The code is MIT; the checkpoint ships in the repository without a licence of its own (MIT assumed) and is trained on DTU, whose terms of use are not stated.

Our reading of the licences, not legal advice.

Weights

params_000007.ckpt 2.8 MB· hosted on GitHub

fastforks downloads and checks these files on first use (fastforks download patchmatchnet).

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.

DTU scans 1

9, 24, 33, 75, view 24 + 7 sources, AbsRel / delta1 %

RundtypeAbsRel ↓δ1.25 % ↑MAE mm ↓Δ AbsRel vs fp32 originalscansms / scan
Original fp32fp320.008799.527.03 reference 5 72.4
Original fp16fp16fails: _LinAlgError: linalg.inv
Portable fp32fp320.008799.527.08 ±0.0000 5 54.6
Portablefp160.008799.527.08 ±0.0000 5 48.0
Kernelsfp160.008799.527.08 ±0.0000 5 10.3

640x512 crops, the 7 most co-visible views as sources; GT = depth rendered from the structured-light points. AbsRel / delta1 over GT pixels, after per-image median scaling unless the model takes the cameras (calibrated MVS: cameras, error in mm; PatchMatchNet also the depth range 425-935 mm, MVSAnywhere its own range from the camera baselines). Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 30c7a8e9, 2026-11-17.

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.5 % and p99 <= 3 % of the reference's median |value| (absolute error of the output depth).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 (relative)not recorded
GPU default dtypes, mean |diff|≤ 0.005 (relative)0.00006 (relative)
GPU default dtypes, p99 |diff|≤ 0.03 (relative)0.00021 (relative)

Recorded for patchmatchnet on RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-31, with these kernels: patchmatchnet

Details

PatchmatchNet (Wang et al. 2021): learned PatchMatch multi-view stereo, the depth of a reference view from posed, calibrated source views and a depth search range. Three coarse-to-fine PatchMatch stages (random initialisation, adaptive propagation, group-wise correlation with pixel-wise view weights, adaptive spatial cost aggregation) on FPN features, then a depth refinement net at full resolution.

Input / output
Input: several images of one scene (posed and calibrated for multi-view stereo, unposed otherwise). Output: depth maps and, where the model predicts them, cameras and 3-D points.
Input size
any H x W >= 5, resized or padded inside the model; tested up to 1988x2880 (8,046 MiB allocated)
Outputs
depth, confidence
CUDA kernels
  • patchmatchnetPatchmatchNet: fused cost, weights and aggregation
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

PatchmatchNet by Fangjinhua Wang et al.: learned PatchMatch multi-view stereo, depth from posed images.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
patchmatchnetsynthetic (1536x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
248
220
201
29.5
175
51.0
1330 / 1412
1228 / 1272
1039 / 1212
648 / 772
1798 / 1888
1073 / 1106
Details
  • Original code: https://github.com/FangjinhuaWang/PatchmatchNet at 8dc6cb4
  • Code licence: MIT (permissive); files: LICENSE
  • Weights licence: MIT (assumed from code)
  • Licence evidence: https://github.com/FangjinhuaWang/PatchmatchNet/blob/8dc6cb4/LICENSE and README.md (the checkpoint ships in the repository)
  • Training data: DTU Robot Image Data Sets (MVS 2014) (The released checkpoint (checkpoints/params_000007.ckpt) is trained on DTU (README); the paper evaluates it zero-shot on Tanks and Temples and ETH3D)
  • Licence note: The code is MIT; the checkpoint ships in the repository without a licence of its own (MIT assumed) and is trained on DTU, whose terms of use are not stated.
  • Kernel libraries: patchmatchnet
  • Variants: patchmatchnet
  • Outputs: depth, confidence; kind: metric
  • Input size: any H x W >= 5, resized or padded inside the model
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): patchmatchnet 1988x2880 (7.9 GiB peak allocated, 9.4 reserved)
  • patchmatchnet 1536x1024, first call: portable + torch.compile 29 s (cold Inductor cache), TensorRT fp16 82 s (ONNX + engine).
  • patchmatchnet original 1536x1024: torch.autocast(fp16) around the forward
  • patchmatchnet load / first call: original 0.04 s / 0.917 s (1536x1024), portable 0.16 s / 0.861 s (1536x1024), kernels 0.17 s / 0.562 s (1536x1024)
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

640x512 crops, the 7 most co-visible views as sources; GT = depth rendered from the structured-light points. AbsRel / delta1 over GT pixels, after per-image median scaling unless the model takes the cameras (calibrated MVS: cameras, error in mm; PatchMatchNet also the depth range 425-935 mm, MVSAnywhere its own range from the camera baselines). Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
patchmatchnetDTU scans 1, 9, 24, 33, 75, view 24 + 7 sources, AbsRel / delta1 % / MAE mm0.0087 / 99.52 / 7.03fails (LinAlgError: linalg.inv)0.0087 / 99.52 / 7.080.0087 / 99.52 / 7.080.0087 / 99.52 / 7.08

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 30c7a8e9, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06.

Parity

CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.5 % and p99 <= 3 % of the reference's median |value| (absolute error of the output depth).

variantkernels error vs original, mean / p99GPU, torchkernels used
patchmatchnet6e-05 / 0.00021RTX 5060 Ti, torch 2.14.1+cu130patchmatchnet@e73cbaa02d34: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).

View 1
View 2
Output
Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), view 1
View 1 · 100%

Input: Motorcycle, Middlebury 2014 stereo (left and right view, downscaled 4x), Scharstein et al., Middlebury College (research dataset, no licence stated).