Repository navigation
Camera tracking: factor narrow camera systems within their band - #2342
Conversation
Detect narrow lower-triangle bandwidth and skip structural zeros while preserving dot-product lanes and signed-zero arithmetic. Keep a dense fallback for wide systems and compare factors and solutions against the original algorithm. Fixes storytold#2325
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Banded solve and dense equivalence tests crates/track/src/camtrack/linalg.rs |
cholesky_solve checks matrix and RHS dimensions before indexing. For finite RHS values, it detects bandwidth and falls back to full width when the bandwidth is at least n / 2. Factorization and triangular solves limit work to the band while preserving tested dense-reference bit patterns. Tests cover multiple sizes, bandwidths, scales, signed-zero cases, invalid dimensions, and the empty system. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Possibly related issues
storytold/effectcraft#2328concerns Schur-reduction cost in bundle adjustment; this PR optimizes the camera-system solve, not Schur reduction.
Possibly related PRs
- storytold/effectcraft#2341: Both PRs validate dimensions in the camera-solver path, at different layers.
Suggested reviewers: echelon
Merge Risk: 
Minimal · up to e5afb
-
The banded solve appears ready to merge after normal checks; no actionable merge-blocking risk is established.
Architecture risk: 
Low · up to e5afb
-
The change affects 1 system.
Changed systems:
cratesArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — crates (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
- observed — Modified behavior in crates/track/src/camtrack/linalg.rs:
cholesky_solvenow validates matrix and RHS lengths before indexing, derives a bandwidth when all RHS values are finite, and falls back to full bandwidth when the detected width is at leastn / 2. The factorization inner product now begins at the band boundary instead of always processing all preceding columns. - observed — Modified behavior in crates/track/src/camtrack/linalg.rs: Rows below each Cholesky pivot are limited to the next
bandrows, and their dot products begin at a four-element-aligned offset to preservedot_nlane ordering while skipping full groups of out-of-band zeros. - observed — Modified behavior in crates/track/src/camtrack/linalg.rs: The forward solve now processes only the preceding
bandentries. When the accumulator is zero, it first performs the omitted out-of-band subtractions to preserve signed-zero behavior. - observed — Modified behavior in crates/track/src/camtrack/linalg.rs: The backward solve now limits its main loop to
bandfollowing entries and performs the omitted tail subtractions only when the accumulator is zero, preserving the dense implementation’s signed-zero result.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
The changes satisfy the coding requirements in directly linked issue
#2325.cholesky_solvedetects lower-triangle bandwidth, limits Cholesky factorization and triangular solves to the band, preserves four-lanedot_nalignment, and selects the dense path for wide systems. The added tests compare factors and solutions bitwise across band widths and scales, and cover signed zero, underflow, invalid dimensions, and zero-sized systems.
Full details: Out of Scope Changes check
-
Explanation
The pull request changes only
crates/track/src/camtrack/linalg.rs. The dimension checks, signed-zero handling, dense fallback, and regression tests directly support thecholesky_solveobjective in#2325. No unrelated implementation or test changes are shown.
-
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Usage-based review receipt
- Mode: Continue automatically
- Reviewed files: 1
- Waived: $0.25 (charged $0.00)
- View usage details
Note
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
Comment @coderabbitai help to get the list of available commands.
|
This PR is one of 17 from a speed audit of
Notes:
|
|
Merged, thank you @vangel76! It landed on |
Summary
Bundle adjustment can produce a banded reduced camera system when feature tracks span only nearby frames.
cholesky_solvenow detects that band from the lower triangle and skips structural zeros in factorization and triangular solves. Wide systems fall back to the dense path early, including systems with shared global parameters.The four-lane dot-product alignment stays unchanged. Zero accumulators still perform the otherwise-skipped signed-zero subtractions, preserving
-0.0/+0.0behavior. Matrix dimensions are checked before indexing.Fixes #2325
Measurements
Release builds based on upstream/main
99190488, Ryzen 7 7800X3D.RAYON_NUM_THREADS=1, pinned to core 12,perf stat -e instructions:u,cycles:u; five alternating original/changed pairs, medians. Each BA call uses 120 cameras, 1,000 points, fixed focal length, two gauge-fixed cameras and up to three LM iterations. Matrices remain densely stored.Short tracks use 59.29% fewer instructions (2.46× instruction ratio); the dense control adds 0.15% instructions. All hashes match within each scenario. These are BA-kernel measurements, not a speedup measured for the complete camera tracker. Shared-focal/distortion parameters can widen the band; this does not implement a bordered sparse system or reduce matrix storage. Counters include process setup/input generation; timing includes identical input cloning.
Verification
cargo fmt --all --checkcargo clippy -p effectcraft-track --lib --tests -- -D warningscargo test --release -p effectcraft-track: 61 library tests passed, 3 ignored.to_bits()against the previous dense algorithm on 648 SPD cases: sizes 1–127, six bandwidth choices, three seeds and scales 1, 1e-100 and 1e100. Separate cases cover signed zeros, underflow, invalid dimensions and size overflow.Overlap
Only
camtrack/linalg.rschanges:cholesky_solveand its regression tests.umeyama, edited by open PR #1876, is byte-for-byte unchanged.bundle.rs,geometry.rs, and all other agents' files are untouched. This branch starts from fresh upstream/main and does not depend on #2338, #2340 or #2341.Generated with Codex
Summary by CodeRabbit