-
Notifications
You must be signed in to change notification settings - Fork 874
BatchFactor #2306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
BatchFactor #2306
Conversation
…dentical factors into a single JacobianFactor
…TestProjectionFactor` wrapper.
…maps and automatically deduce factor constructor signatures using metaprogramming.
… several `BatchFactor` constructors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new BatchFactor class that aggregates multiple identical factors into a single container, optimizing memory allocation through single malloc operations and creating large single-malloc Jacobian factors during linearization. This is designed to improve performance for Structure-from-Motion and SLAM applications with many similar factors.
Key Changes
- New
BatchFactortemplate class that wraps collections of factors - Map-based constructors for convenient factor batching
- Optimized linearization that produces a single JacobianFactor
- Test suite demonstrating usage with ProjectionFactor and BetweenFactor
- Timing example in timeSFMBAL.cpp comparing regular and batched approaches
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| gtsam/nonlinear/BatchFactor.h | New header file defining the BatchFactor template class with constructors, linearization, and helper methods |
| gtsam/nonlinear/tests/testBatchFactor.cpp | New test file with three test cases covering different constructor patterns and factor types |
| timing/timeSFMBAL.cpp | Modified to add BatchFactor usage example alongside existing conventional factor graph approach |
|
@ProfFan FYI |
Compare with Metis Dramatically simplified Hessian path (and way faster!) Add linearize time Hessian! Kill "fast" path revert that More micro-optimization ScratchMatrix offsets_ added a Value cache feat: Optimize BatchFactor linearization by enabling zero-malloc Jacobian computation via OptionalJacobian stride support. refactor: optimize BatchFactor key and dimension indexing. refactor: cache factor-specific key indices in BatchFactor for improved linearization and enable LM sequential Cholesky solver with summary verbosity. refactor: Pre-calculate key dimensions and indices in BatchFactor, add vector constructors, and enable LM parameters in timeSFMBAL. Address comments
WIP: a new non-linear factor that collects many smaller factors but stores them with one malloc, and also creates a large single-malloc Jacobian factor.
Did some more work, including trying to linearize to hessian, and I ran on a larger problem. Verdict: whatever we gain in linearization dwarfs compared to slower elimination:

Raw Data