LightGlue
LightGlue (ETH Zurich, Microsoft; ICCV 2023) with ALIKED or DISK keypoints: sparse matching of two photos of one scene, as keypoints plus index pairs (the form COLMAP takes). Apache-2.0 (LightGlue, DISK) and BSD-3-Clause (ALIKED) code and weights.
experimental Fork of cvg/LightGlue@5a650c4 · backends: portable, kernels
- Paper LightGlue: Local Feature Matching at Light Speed ICCV 2023 · first released 23 Jun 2023
Paper 2023 Added in 0.2.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 matching
model = matching.load("aliked-lightglue") # kernels on a supported GPU, else portable PyTorch
result = model(image_a, image_b)
result.keypoints1 # also: keypoints2, pairs, scores
result.backend # what ran: mode, device, dtype, kernels
points1, points2 = result.matches(5000) # matched pixels, sampled where the model is certain
pose = matching.estimate_pose(points1, points2, K1, K2) # relative pose on the GPU (RANSAC); K = intrinsics [3, 3]
pose.R, pose.t, pose.inliers # rotation, unit translation, inlier mask fastforks bench aliked-lightglue 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 fp32 on CUDA.
Input: synthetic, 768x1024 (the task’s standard size)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original fp16the authors' mixed-precision option (float16); upstream match_pair aliked + LightGlue, resize 1024 | fp16 | 41.8 | – | 1,305 MiB/1,364 MiB | 0.2 | 0.17 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp32 | 40.6 | 1.0× | 1,300 MiB/1,404 MiB | 0.2 | 0.79 |
| Kernels | fp16 | 35.1 | 1.2× | 1,238 MiB/1,324 MiB | 1.5 | 0.90 |
| Portable + torch.compile | 29.5 | 1.4× | 1,653 MiB/1,680 MiB | 31 (build) | – | |
| TensorRTplanned for 0.2.1 | fails | – | – | – | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-12 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
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-17 | Original | fp32 | 214 | 2,720 MiB process | – | 768x1024 |
| Portable | fp32 | 206 | 2,586 MiB process | matches | 768x1024 | |
| Kernels | fp16 | not implemented | – | 768x1024 | ||
| Kernels | fp32 | not implemented | – | 768x1024 | ||
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 AND BSD-3-Clause LICENSELICENSE-ALIKED
- Weights
- Apache-2.0 AND BSD-3-Clause source
- Training data
Our reading of the licences, not legal advice.
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.
MegaDepth-1500
relative pose AUC@5 / @10 / @20 degrees
| Run | dtype | AUC@5° ↑ | AUC@10° ↑ | AUC@20° ↑ | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | not measured | |||||
| Original fp16 | not measured | |||||
| Portable fp32 | fp32 | 50.7 | 67.6 | 80.0 | 1500 | 121 |
| Portable | fp32 | 50.7 | 67.6 | 80.0 | 1500 | 121 |
| Kernels | not measured | |||||
The original code was not run on this dataset, so the table cannot show the distance to it.
Dense matchers: 5000 matches per pair sampled from the warp by certainty (upstream's balanced KDE sampling); sparse matchers: all their matches of one call (LightGlue, XFeat: LightGlue's MegaDepth-1500 setting; LoFTR, DeDoDe: their card defaults). OpenCV essential-matrix RANSAC (0.5 px threshold, normalised by the mean focal length); AUC of the larger of the rotation and translation-direction errors. Measured on RTX 5060 Ti, torch 2.14.1+cu130, fastforks ec7b1307+por, 2026-11-12.
MegaDepth-1500
every 5th pair, relative pose AUC@5 / @10 / @20 degrees
| Run | dtype | AUC@5° ↑ | AUC@10° ↑ | AUC@20° ↑ | Δ AUC@5° vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 51.7 | 68.2 | 81.0 | reference | 300 | 102 |
| Original fp16 | fp16 | 51.4 | 68.8 | 80.8 | −0.3 | 300 | 103 |
| Portable fp32 | fp32 | 52.1 | 69.2 | 81.4 | +0.4 | 300 | 122 |
| Portable | fp32 | 52.1 | 69.2 | 81.4 | +0.4 | 300 | 122 |
| Kernels | fp16 | 51.0 | 68.3 | 80.9 | −0.7 | 300 | 80.1 |
Dense matchers: 5000 matches per pair sampled from the warp by certainty (upstream's balanced KDE sampling); sparse matchers: all their matches of one call (LightGlue, XFeat: LightGlue's MegaDepth-1500 setting; LoFTR, DeDoDe: their card defaults). OpenCV essential-matrix RANSAC (0.5 px threshold, normalised by the mean focal length); AUC of the larger of the rotation and translation-direction errors. The same 300 pairs for all modes, so float32 and bfloat16 compare pair for pair. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-12; portable fp32, portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks ec7b1307+por, 2026-11-12; kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks ecac19a2-dir, 2026-11-15.
Relative pose on the GPU
A dense matcher is usually followed by RANSAC on its matches to get the camera motion. fastforks does that step on the
GPU too: result.matches(n) samples matched points where the model is certain, and matching.estimate_pose runs essential-matrix RANSAC on them, many image pairs per call, with no copy to
the CPU. Like the models it has a portable (plain PyTorch) and a kernels (CUDA) backend.
| Solver | Runs on | Threshold (px) | Pose AUC@5 / @10 / @20 | Pairs per second |
|---|---|---|---|---|
| fastforks estimate_pose, kernels | GPU, batches of 500 pairs | 1.0 | 69.9 / 81.5 / 89.3 | 18,446 |
| fastforks estimate_pose, portable | GPU, batches of 500 pairs | 1.0 | 69.6 / 81.2 / 89.1 | 418 |
| PoseLib 2.0.5 | CPU, 16 processes | 1.0 | 70.0 / 81.6 / 89.5 | 325 |
| OpenCV USAC (MAGSAC++) | CPU, 16 processes | 0.5 | 65.7 / 78.6 / 87.3 | 271 |
| OpenCV RANSAC | CPU, 16 processes | 0.5 | 62.9 / 76.9 / 86.4 | 323 |
MegaDepth-1500, RoMa v2 matches (5000 per pair), 5 samplings, the same matches for every solver, on one machine: RTX 5060 Ti and a Ryzen 7 5800X (16 threads). Each solver runs at the inlier threshold where it is most accurate. Pairs per second is wall-clock throughput over all 7500 poses: the CPU solvers run one pair per call in 16 single-threaded processes, the GPU solver takes 500 pairs per call. One pair alone takes about 1.7 ms with the kernels, 29 ms with PoseLib and 24 ms with OpenCV RANSAC on one core. The accuracy table above stays on OpenCV RANSAC, as in the papers, so it is comparable with published numbers; this table is the only place the GPU solver is used.
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| <= 3e-05 vs the original. GPU, portable float32 and kernels float16 (the defaults): mean |diff| <= 0.0052 and p99 <= 0.012 (absolute error of the output keypoints1).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.00003 | not recorded |
| cpu_min_recall | ≤ 0.99 | not recorded |
| cpu_min_match | ≤ 0.99 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.0052 | 0.00297 |
| GPU default dtypes, p99 |diff| | ≤ 0.012 | 0.00889 |
| gpu_min_recall | ≤ 0.9971 | not recorded |
| gpu_min_match | ≤ 0.9913 | not recorded |
| gpu_min_recall_kernels | ≤ 0.985 | not recorded |
| gpu_min_match_kernels | ≤ 0.97 | not recorded |
| gpu_mean_kernels | ≤ 0.02 | not recorded |
| gpu_p99_kernels | ≤ 0.6 | not recorded |
Recorded for aliked-lightglue on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-15, with these kernels: cudnn_hacccutlass_convigev
Details
LightGlue (Lindenberger, Sarlin and Pollefeys 2023): sparse feature matching. A keypoint detector-descriptor (ALIKED or DISK) finds up to 2048 keypoints per image at a 1024-pixel long side, and a transformer with self- and cross-attention, adaptive depth and point pruning matches them. Returns both keypoint sets, the index pairs of the matches and their confidence.
- Input / output
- Input: two RGB images of one scene. Output: for every pixel of the first image its position in the second (x, y in pixels) and a certainty that the pixel is visible in both.
What the numbers mean, and which models need the camera focal length
Sparse matchers (LightGlue) return the keypoints of both images and the index pairs of the matched ones instead. To reconstruct camera poses from an image folder with these matchers, see [structure from motion](../sfm.md).
- Input size
- any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (1,560 MiB allocated)
- Options
max_keypoints=2048>= 1· changes the outputlong_side=1024>= 0· changes the output
- Outputs
keypoints1,keypoints2,pairs,scores- Checkpoint
extractor="aliked",detection_threshold=0.2- 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
Limitations
- Sparse output: no dense warp. `result.matches()` gives the matched points for `estimate_pose`; `pairs` are the index pairs pycolmap / COLMAP databases take.
- One image pair per call internally (batches run pair by pair); the keypoint counts differ per image.
- No exportable module: the keypoint counts are data-dependent (`torch.compile` runs with graph breaks; ONNX / TensorRT export fails).
Full reference, generated from the repository
LightGlue (ETH Zurich, Microsoft; ICCV 2023) with ALIKED or DISK keypoints: sparse matching of two photos of one scene, as keypoints plus index pairs (the form COLMAP takes). Apache-2.0 (LightGlue, DISK) and BSD-3-Clause (ALIKED) code and weights.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
aliked-lightglue | synthetic (768x1024) | original portable kernels portable + torch.compile TensorRT fp16 | 41.8 40.6 35.1 29.5 planned for 0.2.1 | 1305 / 1364 1300 / 1404 1238 / 1324 1653 / 1680 – |
disk-lightglue | synthetic (768x1024) | original portable kernels portable + torch.compile TensorRT fp16 | 117 116 52.1 113 planned for 0.2.1 | 1955 / 2412 1950 / 2398 736 / 778 1375 / 1502 – |
Details
- Original code: https://github.com/cvg/LightGlue at
5a650c444718 - Code licence: Apache-2.0 AND BSD-3-Clause (permissive); files:
LICENSE,LICENSE-ALIKED - Weights licence: Apache-2.0 AND BSD-3-Clause
- Licence evidence: https://github.com/cvg/LightGlue/blob/5a650c444718caffc2669dc0094cde908f42dd73/README.md#license ; https://github.com/Shiaoming/ALIKED/blob/683d7c65197395c0b3f01ebe76e1084a27e73a65/LICENSE ; https://github.com/cvlab-epfl/disk/blob/8dc6d4d65b47210f629e21ad1fbfb56944b11696/LICENSE.txt
- Training data: MegaDepth (Internet photo collections with SfM / MVS depth) (LightGlue: pretrained on synthetic homographies of the Oxford-Paris 1M distractor images (Flickr; no dataset entry here), fine-tuned on MegaDepth. ALIKED and DISK: trained on MegaDepth.)
- Options:
max_keypoints= 2048 (>= 1),long_side= 1024 (>= 0) - Kernel libraries:
igev,cutlass_conv,cudnn_hacc - Variants:
aliked-lightglue,disk-lightglue - Not in this release (planned for 0.2.1):
aliked-lightglueONNX / TensorRT export: torch.export stops at a data-dependent branch (masks.sum() == 0);disk-lightglueONNX / TensorRT export: torch.export fails (TorchExportError, step 1/3 of the ONNX export) - Outputs: keypoints1, keypoints2, pairs, scores
- Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
aliked-lightglue3000x4000 (1.5 GiB peak allocated, 2.0 reserved);disk-lightglue3000x4000 (2.2 GiB peak allocated, 2.9 reserved) aliked-lightglue768x1024, first call: portable + torch.compile 31 s (cold Inductor cache).disk-lightglue768x1024, first call: portable + torch.compile 21 s (cold Inductor cache).aliked-lightglueoriginal 768x1024: the authors' mixed-precision option (float16); upstream match_pair aliked + LightGlue, resize 1024disk-lightglueoriginal 768x1024: the authors' mixed-precision option (float16); upstream match_pair disk + LightGlue, resize 1024aliked-lightglueload / first call: original 1.49 s / 0.732 s, portable 0.17 s / 0.79 s, kernels 1.46 s / 0.902 sdisk-lightglueload / first call: original 1.43 s / 0.642 s, portable 0.2 s / 0.633 s, kernels 0.57 s / 0.301 s- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Measured
Dense matchers: 5000 matches per pair sampled from the warp by certainty (upstream's balanced KDE sampling); sparse matchers: all their matches of one call (LightGlue, XFeat: LightGlue's MegaDepth-1500 setting; LoFTR, DeDoDe: their card defaults). OpenCV essential-matrix RANSAC (0.5 px threshold, normalised by the mean focal length); AUC of the larger of the rotation and translation-direction errors. The same 300 pairs for all modes, so float32 and bfloat16 compare pair for pair. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
aliked-lightglue | MegaDepth-1500, relative pose AUC@5 / @10 / @20 degrees | 50.7 / 67.6 / 80.0 | ||||
aliked-lightglue | MegaDepth-1500, every 5th pair, relative pose AUC@5 / @10 / @20 degrees | 51.7 / 68.2 / 81.0 | 51.4 / 68.8 / 80.8 | 52.1 / 69.2 / 81.4 | 51.0 / 68.3 / 80.9 | |
disk-lightglue | MegaDepth-1500, every 5th pair, relative pose AUC@5 / @10 / @20 degrees | 45.6 / 63.3 / 77.3 | 44.9 / 63.4 / 77.0 | 45.6 / 63.3 / 77.3 | 45.0 / 62.9 / 76.6 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks ec7b1307+port/p1-match, 2026-11-12; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks ecac19a2-dirty, 2026-11-15.
Parity
CPU, float32: max |diff| <= 3e-05 vs the original. GPU, portable float32 and kernels float16 (the defaults): mean |diff| <= 0.0052 and p99 <= 0.012 (absolute error of the output keypoints1).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
aliked-lightglue | 0.00297 / 0.00889 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120 |
disk-lightglue | 0.00909 / 0.5 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400, cutlass_conv@988138e042cb:sm_120, igev@f075827d68c6:sm_120 |
Limitations
- Sparse output: no dense warp.
result.matches()gives the matched points forestimate_pose;pairsare the index pairs pycolmap / COLMAP databases take. - One image pair per call internally (batches run pair by pair); the keypoint counts differ per image.
- No exportable module: the keypoint counts are data-dependent (
torch.compileruns with graph breaks; ONNX / TensorRT export fails).
Example output
No example rendered for this checkpoint yet.