Skip to content

Conversation

@SebastianM-C
Copy link
Member

@SebastianM-C SebastianM-C commented Oct 16, 2025

This fixes several bugs

  • method ambiguity in the Zygote extension when a ReInitCache is used
  • wrong size for Hessian of the Lagrangian
  • typo for allowconsvjp

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Splits off bugfixes from #1061

SebastianM-C and others added 4 commits October 16, 2025 14:37
The Lagrangian Hessian prototype was incorrectly sized as (num_constraints × num_variables)
instead of (num_variables × num_variables). This caused a `BoundsError` when computing the
Lagrangian Hessian with more variables than constraints, as the prototype was used as a
buffer for the n×n Hessian matrix.

Changes:
  - Fix lag_hess_prototype initialization to use zeros(Bool, length(x), length(x))
  - Add comprehensive tests to verify prototype dimensions and usability as a buffer

This ensures the Lagrangian Hessian is always correctly sized as n×n regardless of the
number of constraints, matching the mathematical definition of the Lagrangian Hessian
as the second derivative with respect to the decision variables.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
The Lagrangian Hessian prototype was incorrectly sized as (num_constraints × num_variables)
instead of (num_variables × num_variables). This caused a `BoundsError` when computing the
Lagrangian Hessian with more variables than constraints, as the prototype was used as a
buffer for the n×n Hessian matrix.

Changes:
- Fix lag_hess_prototype initialization to use zeros(Bool, length(x), length(x))
  in both in-place and out-of-place function instantiation
- Add tests to verify prototype dimensions

This ensures the Lagrangian Hessian is always correctly sized as n×n regardless of the
number of constraints, matching the mathematical definition of the Lagrangian Hessian
as the second derivative with respect to the decision variables.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Corrected function name to properly spell VJP (Vector-Jacobian Product).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@SebastianM-C SebastianM-C mentioned this pull request Oct 16, 2025
6 tasks
@ChrisRackauckas ChrisRackauckas merged commit d7ef835 into SciML:master Oct 16, 2025
39 of 77 checks passed
@SebastianM-C SebastianM-C deleted the bugfix branch October 16, 2025 12:35
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.

2 participants