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

Full hessian (c++) #2174

Open
a-jp opened this issue Nov 24, 2024 · 6 comments
Open

Full hessian (c++) #2174

a-jp opened this issue Nov 24, 2024 · 6 comments

Comments

@a-jp
Copy link

a-jp commented Nov 24, 2024

I'd like to consider this library to support my interaction with ipopt. For that to work I need the gradient, Jacobian, and hessian of functions with respect to the optimisation variable or variables. To that end I also need to provide to ipopt sparsity patterns for the jacobian and hessian. I need the hessian, not the HVP etc. My code is c++ and interfaces to ipopt using c++.

Taking all of the above into account would I be able to use enzyme now? If not, what is missing?

Thanks

@jedbrown
Copy link
Collaborator

Is your Hessian sparse or dense? If dense, the Hessian can be computed efficiently using the HVP (ideally combined with batching). If sparse and you know the sparsity pattern, you can compute a coloring and efficiently obtain an assembled sparse Hessian using the HVP (some libraries, such as PETSc, will automate this for you). If you want Enzyme to figure out the sparsity pattern and put the matrix in a CSR format, I think that would be a new feature (don't know if Enzyme maintainers would consider it "patches welcome" or out of scope).

@a-jp
Copy link
Author

a-jp commented Nov 25, 2024

The hessian and jacobian are sparse. I do not know the sparsity pattern and need to obtain this from the library. CSR is ideal for both jacobian and hessian. I do not know the HvP nor does the library I'm coupling to require it. I had naively assumed that on computing derivatives for the jacobian and hessian the library knows it's a zero entry and the sparsity would "come for free"?

@wsmoses
Copy link
Member

wsmoses commented Nov 25, 2024

there is some work in Enzyme to automatically automate the sparsity detection x/ref https://c.wsmoses.com/presentations/weuroad23.pdf cc @martinjm97 @kmu @shoaibkamil

@wsmoses
Copy link
Member

wsmoses commented Nov 25, 2024

though that said patches/features generally always welcome (but if it's a more significant thing, probably worth a github discussion, or discussion at the weekly enzyme meeting

@a-jp
Copy link
Author

a-jp commented Nov 26, 2024

Thank you. Can you confirm at present dense (without sparsity calcs) hessian computations are possible? Is there an example of that?

@a-jp
Copy link
Author

a-jp commented Dec 17, 2024

Hi, just following this up. Could you confirm pure hessian computations are possible, dense or otherwise? Could you provide an example?

Thanks

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

No branches or pull requests

3 participants