Skip to content

perf: avoid full-frame promotion during alignment - #3

Open
EricSpencer00 wants to merge 1 commit into
mainfrom
luna/vitruve-alignment-performance
Open

EricSpencer00 wants to merge 1 commit into
mainfrom
luna/vitruve-alignment-performance

Conversation

@EricSpencer00

Copy link
Copy Markdown
Owner

What this changes

Fixes #2. Canonical alignment now promotes only the four sampled pixel neighborhoods to float64 instead of converting the entire source photograph before indexing. The existing interpolation, clamping, rounding, output dtype, and seeded measurement path are unchanged. An exact-output regression test compares the optimized sampler with the pre-change implementation at image edges and out-of-bounds coordinates.

Baseline and measured result

Baseline commit: f0ebfe39d9b2ef82e98343b3b24bcb794e9e5041 (the post-batching code before this change). On the same NUC runner, Python 3.12.3, NumPy 2.5.3, synthetic 1600x2000 RGB input, 512 crop, and 2048 samples, an alternating same-process A/B harness measured:

metric old new change
direct sampler median 121.365 ms 96.813 ms 20.2% faster
alignment stage median 151.686 ms 89.648 ms 40.9% faster
full analysis median 389.171 ms 324.476 ms 16.6% faster

Both paths returned 42 measured and 26 unavailable results with no failures.

Verification

  • Exact commit 86a7e5b: pytest -q -r s — 850 collected, 840 passed, 10 expected skips.
  • Changed-file Ruff: passed.
  • Changed-module mypy under Python 3.12: passed.
  • python -m build and twine check dist/*: passed.
  • Repository-wide Ruff still reports the pre-existing 83-error backlog; CI already treats that check as non-blocking.
  • Independent Luna review was requested twice at gpt-5.6-luna/max, but the review transport was unavailable; no substitute model was used.

Risk and rollback

The code path is limited to the canonical crop sampler. The regression oracle preserves the previous pixel output exactly for boundary cases. Revert commit 86a7e5b to roll back.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid full-frame float64 promotion in canonical alignment

1 participant