feat(gpr): explicitly mark GlobalPlaceRecognition as AnyLoc-VLAD-DINOv2 baseline

GlobalPlaceRecognition already implements AnyLoc-VLAD-DINOv2 (existing code).
This change makes the sprint 1 GPR technology selection explicit:

- Expand class docstring with selection rationale vs NetVLAD / SP+LG
- Document INT8 quantization as known-broken for ViT on Jetson
- Reference design doc §2.3 and stage2 backlog
- Add two marker tests asserting 4096-d descriptor + DINOv2 engine name

No behavioral change — existing Mock/TRT path unchanged.
Ref: docs/superpowers/specs/2026-04-18-oss-stack-tech-audit-design.md §2.3

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yuzviak
2026-04-18 16:22:55 +03:00
parent b62bd48b00
commit e4ba7bced3
2 changed files with 44 additions and 2 deletions
+33
View File
@@ -110,3 +110,36 @@ def test_descriptor_is_l2_normalised(gpr):
img = np.random.randint(0, 255, (200, 200, 3), dtype=np.uint8)
desc = gpr.compute_location_descriptor(img)
assert np.isclose(np.linalg.norm(desc), 1.0, atol=1e-5)
# ---------------------------------------------------------------------------
# AnyLoc baseline markers — document sprint 1 GPR technology selection.
# GlobalPlaceRecognition IS the AnyLoc-VLAD-DINOv2 baseline (see class docstring).
# Ref: docs/superpowers/specs/2026-04-18-oss-stack-tech-audit-design.md §2.3
# ---------------------------------------------------------------------------
def test_anyloc_baseline_descriptor_dim_is_4096(gpr):
"""AnyLoc-VLAD-DINOv2 baseline produces 4096-d descriptors (ViT-base + VLAD)."""
img = np.random.randint(0, 255, (224, 224, 3), dtype=np.uint8)
desc = gpr.compute_location_descriptor(img)
assert desc.shape == (4096,), (
f"AnyLoc-VLAD-DINOv2 expects 4096-d descriptor, got {desc.shape}. "
"If you changed this, update the baseline reference in "
"docs/superpowers/specs/2026-04-18-oss-stack-tech-audit-design.md §2.3"
)
def test_anyloc_baseline_uses_dinov2_engine():
"""Sprint 1 GPR baseline must call DINOv2 via ModelManager."""
from unittest.mock import MagicMock
from gps_denied.core.gpr import GlobalPlaceRecognition
mm = MagicMock()
mm.get_inference_engine.return_value.infer.return_value = np.ones(4096, dtype=np.float32)
gpr_local = GlobalPlaceRecognition(mm)
gpr_local.compute_location_descriptor(np.zeros((224, 224, 3), dtype=np.uint8))
# AnyLoc == DINOv2 + VLAD. Engine name must be "DINOv2".
mm.get_inference_engine.assert_called_with("DINOv2")