-
Notifications
You must be signed in to change notification settings - Fork 864
[WIP] New FastNoiseModelFactor with more efficient linearization #2275
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?
Conversation
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 FastNoiseModelFactorN
class as an optimized alternative to the existing NoiseModelFactorN
for more efficient linearization in GTSAM. The implementation aims to achieve approximately 10% performance improvement in linearization operations.
- Complete implementation of
FastNoiseModelFactorN
with optimized linearization usingVerticalBlockMatrix
- Migration of
PriorFactor
to use the new fast factor implementation - API adjustments to support Eigen::Ref-based Jacobian handling for better memory management
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
gtsam/nonlinear/FastNoiseModelFactorN.h | New optimized factor implementation with direct VerticalBlockMatrix linearization |
gtsam/nonlinear/PriorFactor.h | Migration from NoiseModelFactorN to FastNoiseModelFactorN base class |
gtsam/slam/tests/testPriorFactor.cpp | Updated test to use new evaluateError signature with nullptr parameter |
gtsam/linear/NoiseModel.h | API changes to support Eigen::Block instead of Eigen::Block |
gtsam/linear/JacobianFactor.h | Simplified constructor template for better move semantics |
gtsam/linear/JacobianFactor-inl.h | Unified constructor implementation with perfect forwarding |
gtsam/linear/GaussianConditional.cpp | Optimization to use std::move for VerticalBlockMatrix |
gtsam/navigation/ImuBias.cpp | Added .eval() calls to fix potential Eigen expression template issues |
gtsam/base/OptionalJacobian.h | New constructor overload for Eigen::Ref support |
namespace gtsam { | ||
/* ************************************************************************* */ | ||
/** | ||
* A convenient base class for creating your own NoiseModelFactor |
Copilot
AI
Oct 7, 2025
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.
Documentation should be updated to reflect that this is a FastNoiseModelFactor, not NoiseModelFactor.
* A convenient base class for creating your own NoiseModelFactor | |
* A convenient base class for creating your own FastNoiseModelFactor |
Copilot uses AI. Check for mistakes.
* between a Pose3 and Point3 could be implemented like so: | ||
* | ||
* ~~~~~~~~~~~~~~~~~~~~{.cpp} | ||
* class MyFactor : public FastNoiseModelFactorN<Pose3, Point3> { |
Copilot
AI
Oct 7, 2025
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.
[nitpick] The example class name should follow the naming convention with a more descriptive name than 'MyFactor'.
Copilot uses AI. Check for mistakes.
template <typename T = void> | ||
using OptionalMatrixTypeT = Matrix*; | ||
|
||
/* Like std::void_t, except produces `Eigen::Ref<Matrix>` instead of `void`. |
Copilot
AI
Oct 7, 2025
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.
The comment is misleading - this template produces Eigen::Ref<Matrix>*
(pointer), not Eigen::Ref<Matrix>
.
/* Like std::void_t, except produces `Eigen::Ref<Matrix>` instead of `void`. | |
/* Like std::void_t, except produces `Eigen::Ref<Matrix>*` (pointer) instead of `void`. |
Copilot uses AI. Check for mistakes.
Fan, I hope you saw that the CI fails. This could be due to unrelated changes you made. Maybe those should be a separate PR :-) i’m wondering whether it is necessary to have a completely new class or whether we can just have a different method to overload. Then we can deprecate the old method and publicize the new method. And this PR would also have much smaller change and be easier to review. |
b6908be
to
775ce42
Compare
775ce42
to
374632c
Compare
@ProfFan Let's talk Monday about my comment and whether that's a good or a bad idea, and why... |
About 10% faster in linearization with my microbenchmarks. I think there is still a large margin for optimization, but we should focus more on the linear solver...