S2M2
A transformer-based stereo family in four sizes (S, M, L, XL). Non-commercial licence.
Commercial use: no (code: CC-BY-NC-4.0 (noncommercial); weights: CC-BY-NC-4.0).
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
s2m2-s | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 582 350 348 113 186 137 | 2775 / 3008 1759 / 1986 1733 / 1930 686 / 820 1579 / 1710 980 (engine) |
s2m2-m | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels | 1242 666 670 248 | 3399 / 3704 2371 / 2920 2300 / 2786 876 / 1162 |
s2m2-l | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels | 1934 1005 1015 376 | 4333 / 5252 3248 / 4090 3245 / 3838 1249 / 1568 |
s2m2-xl | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels | 3510 1796 1815 682 | 6940 / 8254 5606 / 6080 5228 / 6016 2092 / 2274 |
Details
- Original code: https://github.com/junhong-3dv/s2m2 at
8f3bd785df59 - Code licence: CC-BY-NC-4.0 (noncommercial); files:
LICENSE.md - Weights licence: CC-BY-NC-4.0
- Licence evidence: https://github.com/junhong-3dv/s2m2/blob/8f3bd785df593619d955203c6f2c741bef6e31df/README.md#L24
- Training data: README: extended training data incl. transparent objects
- Kernel libraries:
s2m2,s2m2_cutlass,cudnn_hacc - Variants:
s2m2-s,s2m2-m,s2m2-l,s2m2-xl - Outputs: disparity, confidence, occlusion (in
extras) - Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
s2m2-s1988x2880 (7.4 GiB peak allocated, 10.6 reserved);s2m2-m1988x2880 (8.9 GiB peak allocated, 11.5 reserved);s2m2-l1988x2880 (11.4 GiB peak allocated, 14.2 reserved);s2m2-xl1024x2048 (7.3 GiB peak allocated, 8.5 reserved) s2m2-s994x1482, first call: portable + torch.compile 96 s (cold Inductor cache), TensorRT fp16 363 s (ONNX + engine).s2m2-soriginal 994x1482: torch.autocast(fp16) around the forwards2m2-moriginal 994x1482: torch.autocast(fp16) around the forwards2m2-loriginal 994x1482: torch.autocast(float16) around the calls2m2-xloriginal 994x1482: torch.autocast(fp16) around the forwards2m2-sload / first call: original 0.22 s / 0.143 s (375x1242), portable 0.22 s / 0.352† s, kernels 0.2† s / 0.114† ss2m2-mload / first call: original 3.95 s / 0.268 s (375x1242), portable 0.5 s / 0.675† s, kernels 0.31† s / 0.249† ss2m2-lload / first call: original 1.38 s / 1.007 s, portable 0.99 s / 1.015† s, kernels 0.58† s / 0.374† ss2m2-xlload / first call: original 4.5 s / 0.529 s (375x1242), portable 2.73 s / 1.814† s, kernels 0.9† s / 0.681† 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 | portable | kernels | note |
|---|---|---|---|---|---|---|
s2m2-s | ETH3D two-view train, bad > 1 px % / EPE | 1.10 / 0.193 | 1.07 / 0.198 | 1.12 / 0.193 | 1.10 / 0.193 | possibly in the training data |
s2m2-s | Middlebury 2014 trainingH, bad > 2 px % / EPE | 3.23 / 0.652 | 3.23 / 0.657 | 3.24 / 0.652 | 3.24 / 0.652 | possibly in the training data |
s2m2-m | ETH3D two-view train, bad > 1 px % / EPE | 0.94 / 0.178 | 0.94 / 0.188 | 0.95 / 0.178 | 0.95 / 0.178 | possibly in the training data |
s2m2-m | Middlebury 2014 trainingH, bad > 2 px % / EPE | 3.28 / 0.651 | 3.28 / 0.656 | 3.29 / 0.651 | 3.28 / 0.651 | possibly in the training data |
s2m2-l | ETH3D two-view train, bad > 1 px % / EPE | 0.84 / 0.169 | 0.85 / 0.182 | 0.84 / 0.169 | 0.82 / 0.169 | possibly in the training data |
s2m2-l | Middlebury 2014 trainingH, bad > 2 px % / EPE | 2.88 / 0.542 | 2.84 / 0.551 | 2.84 / 0.542 | 2.85 / 0.542 | possibly in the training data |
s2m2-xl | ETH3D two-view train, bad > 1 px % / EPE | 0.53 / 0.147 | 0.52 / 0.157 | 0.53 / 0.147 | 0.52 / 0.149 | possibly in the training data |
s2m2-xl | Middlebury 2014 trainingH, bad > 2 px % / EPE | 2.34 / 0.498 | 2.33 / 0.504 | 2.33 / 0.498 | 2.33 / 0.499 | possibly in the training data |
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 |
|---|---|---|---|
s2m2-s | 0.00973 / 0.03415 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, s2m2@73d0d3fa70d2:sm_120, s2m2_cutlass@3aec99821257:sm_120 |
s2m2-m | 0.00618 / 0.02223 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, s2m2@73d0d3fa70d2:sm_120, s2m2_cutlass@3aec99821257:sm_120 |
s2m2-l | 0.01523 / 0.05073 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, s2m2@73d0d3fa70d2:sm_120, s2m2_cutlass@3aec99821257:sm_120 |
s2m2-xl | 0.01853 / 0.0624 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, s2m2@73d0d3fa70d2:sm_120, s2m2_cutlass@3aec99821257:sm_120 |
Limitations
- At 994x1482 portable S2M2-S is about as fast as the original code and allocates slightly more memory; use kernels for speed and memory.