From edb39f5f8bd5bd4324d7d94ec807ab4cd3f0aa35 Mon Sep 17 00:00:00 2001 From: Johan Edstedt Date: Sat, 4 Apr 2026 18:47:47 +0200 Subject: [PATCH 1/5] Merge pull request #47 from Parskatt/je/fix-local-corr --- pyproject.toml | 6 ++---- src/romav2/refiner.py | 7 +++---- src/romav2/romav2.py | 5 +++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c17a9e8..a5ae85a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "romav2" -version = "2.0.0" +version = "2.0.1" description = "RoMa v2: Harder Better Faster Denser Feature Matching" readme = "README.md" authors = [ @@ -15,6 +15,7 @@ dependencies = [ "torch", "torchvision>=0.23.0", "tqdm>=4.67.1", + "fused-local-corr ; sys_platform == 'linux'", ] [build-system] @@ -22,9 +23,6 @@ requires = ["uv_build>=0.8.15,<0.9.0"] build-backend = "uv_build" [project.optional-dependencies] -fused-local-corr = [ - "fused-local-corr ; sys_platform == 'linux'", -] eval = [ "kornia>=0.8.2", "matplotlib>=3.10.7", diff --git a/src/romav2/refiner.py b/src/romav2/refiner.py index 8476685..0de7651 100644 --- a/src/romav2/refiner.py +++ b/src/romav2/refiner.py @@ -169,18 +169,17 @@ def forward( ) # Corr in other means take a kxk grid around the predicted coordinate in other image f_A_bdhw = f_A.permute(0, 3, 1, 2) - f_B_bdhw = f_BA.permute(0, 3, 1, 2) - d = torch.cat((f_A_bdhw, f_B_bdhw, emb_in_displacement), dim=1) + f_BA_bdhw = f_BA.permute(0, 3, 1, 2) + d = torch.cat((f_A_bdhw, f_BA_bdhw, emb_in_displacement), dim=1) if self.cfg.local_corr_radius is not None: local_corr = local_correlation( f_A_bdhw, - f_B_bdhw, + f_B.permute(0, 3, 1, 2), local_radius=self.cfg.local_corr_radius, warp=prev_warp, scale_factor=scale_factor, ) d = torch.cat((d, local_corr), dim=1) - # d = torch.cat((f_A_bdhw, f_B_bdhw, emb_in_displacement, local_corr), dim=1) if self.cfg.channels_last: d = d.to(memory_format=torch.channels_last) z = self.block1(d) diff --git a/src/romav2/romav2.py b/src/romav2/romav2.py index 06aa2cc..65a1a3c 100644 --- a/src/romav2/romav2.py +++ b/src/romav2/romav2.py @@ -77,7 +77,7 @@ class Cfg: anchor_width: int = 512 anchor_height: int = 512 setting: Setting = "precise" - compile: bool = True + compile: bool = False name: str = "RoMa v2" # settings @@ -96,7 +96,8 @@ def __init__(self, cfg: Cfg | None = None): cfg = RoMaV2.Cfg() weights = torch.hub.load_state_dict_from_url( - "https://github.com/Parskatt/RoMaV2/releases/download/weights/romav2.pt" + "https://github.com/Parskatt/RoMaV2/releases/download/v2.0.1/romav2.0.1.pt", + map_location=device ) self.f = Descriptor(cfg.descriptor) self.matcher = Matcher(cfg.matcher) From 95c9968145c8906b7b59383258e9f73b02853d89 Mon Sep 17 00:00:00 2001 From: tlancaster6 <53151548+tlancaster6@users.noreply.github.com> Date: Mon, 20 Apr 2026 14:17:22 -0400 Subject: [PATCH 2/5] Remove dataclasses dependency (#43) Removed dataclasses dependency from project. --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a5ae85a..baf33e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,6 @@ authors = [ ] requires-python = ">=3.10" dependencies = [ - "dataclasses>=0.8", "einops>=0.8.1", "pillow>=12.0.0", "rich>=14.2.0", From adeaac17f4861429c672a7f8eda4f59426005ca1 Mon Sep 17 00:00:00 2001 From: cDc Date: Thu, 18 Jun 2026 11:03:52 +0000 Subject: [PATCH 3/5] docs: update fused-local-corr section after upstream merge Upstream promoted fused-local-corr from an optional extra to a core Linux dependency (installed automatically by uv sync), so the '--extra fused-local-corr' / romav2[fused-local-corr] instructions are no longer valid. Document the new auto-install behavior instead. Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 24af0eb..8f1edd9 100644 --- a/README.md +++ b/README.md @@ -108,18 +108,10 @@ Running these gave me `ScanNet-1500: [34.0, 56.5, 73.9]`, and `Mega-1500: [62.8, ## Fused local correlation kernel -Include the `--extra fused-local-corr` flag as: -```bash -uv sync --extra fused-local-corr -``` -or -```bash -uv pip install romav2[fused-local-corr] -``` -or -```bash -uv add romav2[fused-local-corr] -``` +On Linux the `fused-local-corr` kernel is a core dependency and is installed +automatically by the Setup/Install step above (`uv sync` / `uv pip install -e .`) +— no extra flag is required. On non-Linux platforms it is skipped and RoMa falls +back to the pure-PyTorch local correlation. ## Settings By twiddling with some different settings you may reach better results on your task of interest. From ce6e966afa86cbff38578f18c69a34104b5d2ad0 Mon Sep 17 00:00:00 2001 From: cDc Date: Thu, 18 Jun 2026 11:10:15 +0000 Subject: [PATCH 4/5] batch_match: make torch.compile an explicit flag (default on) Upstream flipped the RoMaV2 Cfg.compile default from True to False, so the bare RoMaV2() in batch_match.py silently stopped compiling and the production throughput path regressed. match() always interpolates inputs to fixed (H_lr/W_lr, H_hr/W_hr) sizes, so torch.compile compiles once and reuses the graph across all pairs -- a real throughput win with no recompilation. Restore compiled behavior by default and expose --no-compile for profiling/tracing runs (torch.compile graph capture hides the record_function annotations). batch_match_min.py is left on compile=False intentionally: its cached path batches a variable number of images, which would force a recompile per unique batch size. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/batch_match.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/batch_match.py b/scripts/batch_match.py index a2f620f..72fd085 100644 --- a/scripts/batch_match.py +++ b/scripts/batch_match.py @@ -744,6 +744,17 @@ def main(): default=True, help='Disable bidirectional matching (only A->B; default is bidirectional)' ) + parser.add_argument( + '--no-compile', + dest='compile', + action='store_false', + default=True, + help='Disable torch.compile. Compiling is enabled by default for ' + 'throughput (match() runs at fixed resolution, so the graph is ' + 'compiled once and reused across all pairs). Disable it when ' + 'profiling/tracing, since torch.compile graph capture hides the ' + 'torch.profiler.record_function annotations.' + ) parser.add_argument( '--calibration-pairs', type=int, @@ -781,10 +792,10 @@ def main(): pairs = optimize_pair_order(pairs) # Initialize model - logger.info(f"Initializing RoMaV2 with setting: {args.setting}") - #Use compile=False for full tracing - #model = RoMaV2(RoMaV2.Cfg(compile=False)) - model = RoMaV2() + logger.info(f"Initializing RoMaV2 with setting: {args.setting} (compile={args.compile})") + # compile=True is the throughput path; pass --no-compile for full tracing + # (torch.compile hides the profiler record_function annotations). + model = RoMaV2(RoMaV2.Cfg(compile=args.compile)) model.apply_setting(args.setting) model.bidirectional = args.bidirectional model.eval() From 7ef50d1a502b295bb8db9fdeaa765aea8e52c2fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 19 Jun 2026 08:37:43 +0000 Subject: [PATCH 5/5] refactor: store f_B permute in local variable f_B_bdhw --- src/romav2/refiner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/romav2/refiner.py b/src/romav2/refiner.py index 0de7651..666683d 100644 --- a/src/romav2/refiner.py +++ b/src/romav2/refiner.py @@ -169,12 +169,13 @@ def forward( ) # Corr in other means take a kxk grid around the predicted coordinate in other image f_A_bdhw = f_A.permute(0, 3, 1, 2) + f_B_bdhw = f_B.permute(0, 3, 1, 2) f_BA_bdhw = f_BA.permute(0, 3, 1, 2) d = torch.cat((f_A_bdhw, f_BA_bdhw, emb_in_displacement), dim=1) if self.cfg.local_corr_radius is not None: local_corr = local_correlation( f_A_bdhw, - f_B.permute(0, 3, 1, 2), + f_B_bdhw, local_radius=self.cfg.local_corr_radius, warp=prev_warp, scale_factor=scale_factor,