Skip to content
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

Fix extra allocations in get_gradient!'s jacobian #300

Closed
wants to merge 2 commits into from

Conversation

Affie
Copy link
Contributor

@Affie Affie commented Oct 6, 2023

I'm not sure of the correct way to fix this, but here is the cause of the extra allocations in my example from: JuliaRobotics/IncrementalInference.jl#1546 (comment)

With this fix it shaves off 15 seconds of a 30-second solve.

)
basis_p = _maybe_get_basis(M, p, nlso.jacobian_tangent_basis)
Jval = zeros(nlso.num_components, manifold_dimension(M))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where all the allocations come from, in my case, I give a sparse jacobian as input.

@mateuszbaran
Copy link
Member

That's a neat solution 👍

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #300 (c552eb3) into master (48f5ab0) will decrease coverage by 0.25%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #300      +/-   ##
==========================================
- Coverage   99.88%   99.64%   -0.25%     
==========================================
  Files          77       77              
  Lines        7083     7083              
==========================================
- Hits         7075     7058      -17     
- Misses          8       25      +17     
Files Coverage Δ
src/plans/nonlinear_least_squares_plan.jl 85.71% <ø> (-14.29%) ⬇️
src/solvers/LevenbergMarquardt.jl 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Affie Affie marked this pull request as ready for review October 6, 2023 14:19
@kellertuer
Copy link
Member

kellertuer commented Oct 6, 2023

To summarise a lengthy chat.

The idea proposed here breaks with one central design idea, that the problem (manifold, cost function , gradient,...) is stored in one struct and the state (everything the solver needs between iterates) in another.
It also abstracts accessors to the problem from implementation details.

With these ideas the current (though short) PR breaks – quite a bit.
I do not yet see a good way to resolve this, sadly, but I acknowledge, that “passing state memory to the problem/objective” might be something useful to have.
Since this summarizes/conclucdes my code remarks above, I marked them resolved (though they are technically not).

@mateuszbaran
Copy link
Member

I've submitted an alternative fix that doesn't break Manopt's design: #301 -- it should also fix this issue.

@kellertuer
Copy link
Member

Superseeded by #301

@kellertuer kellertuer closed this Oct 6, 2023
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.

3 participants