LightGlue (fastforks)
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.
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/cvg/LightGlue at 5a650c444718.
Task: matching. Tier: experimental. Outputs: keypoints1, keypoints2, pairs, scores. Backends: portable, kernels.
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. 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.
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
aliked-lightglue@1 |
aliked_lightglue.pth aliked-n16.pth |
d975e965b1055be8704840ed |
Apache-2.0 AND BSD-3-Clause | yes |
disk-lightglue@1 |
disk_lightglue.pth depth-save.pth |
b5b21d47ea249c2ee4ded238 |
Apache-2.0 AND BSD-3-Clause | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0 AND BSD-3-Clause. Licence files: LICENSE, LICENSE-ALIKED.
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.).
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
Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): aliked-lightglue 3000x4000 (1.5 GiB peak allocated, 2.0 reserved); disk-lightglue 3000x4000 (2.2 GiB peak allocated, 2.9 reserved)
Speed and memory
Matching, synthetic, 768x1024
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|
aliked-lightglue |
β | 41.8 | 40.6 | 35.1 | 1.2x | 1.2x | 1305 / 1364 | 1300 / 1404 | 1238 / 1324 |
disk-lightglue |
β | 117 | 116 | 52.1 | 2.2x | 2.2x | 1955 / 2412 | 1950 / 2398 | 736 / 778 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
aliked-lightglue |
1.49 | 0.17 | 1.46 | 0.73 | 0.79 | 0.90 |
disk-lightglue |
1.43 | 0.20 | 0.57 | 0.64 | 0.63 | 0.30 |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|---|---|---|---|---|---|---|---|---|---|---|---|
aliked-lightglue |
768x1024 | 40.6 ms | 29.5 ms | planned for 0.2.1 | 35.1 ms | 30.8 s | β | 1300 / 1404 | 1653 / 1680 | 1238 / 1324 | β |
disk-lightglue |
768x1024 | 116 ms | 113 ms | planned for 0.2.1 | 52.1 ms | 21.4 s | β | 1950 / 2398 | 1375 / 1502 | 736 / 778 | β |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
Accuracy
On public datasets
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 with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. 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).
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).
Usage
from fastforks import matching
model = matching.load("aliked-lightglue") # mode="auto": the preferred backend from recorded measurements
result = model("view1.jpg", "view2.jpg")
result.keypoints1, result.keypoints2, result.pairs # [N, 2], [M, 2] pixels; [K, 2] int64 index pairs
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: aliked-lightglue, disk-lightglue.
Kernels backend
matching.load("aliked-lightglue", mode="kernels") runs our CUDA kernels (igev, cutlass_conv, cudnn_hacc). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.