Skip to content

Use Enzyme in ipopt rather than FiniteDiff#20

Merged
rafaqz merged 5 commits into
IPOPT-implementationfrom
autodiff-ipopt
May 11, 2026
Merged

Use Enzyme in ipopt rather than FiniteDiff#20
rafaqz merged 5 commits into
IPOPT-implementationfrom
autodiff-ipopt

Conversation

@rafaqz
Copy link
Copy Markdown
Member

@rafaqz rafaqz commented May 10, 2026

Still has a few hacky approaches skipping around DifferentiationInterface because of units.

We need to extract the unit stripping code from debtool into a shared package to clean this up.

rafaqz added 4 commits May 10, 2026 19:01
# Conflicts:
#	Project.toml
#	examples/budgerigar.jl
#	src/endotherm/thermoregulation/ipopt.jl
#	src/endotherm/thermoregulation/rulebased.jl
Caller-side updates for upstream renames: generated_heat_flow → metabolic_heat_flow,
per-side insulation_depth/conductivity moved under .dorsal/.ventral, shape_b → axis_ratio_b,
respiration_mass → respiration_mass_flow. Adds `smoothing` field on IPOPTControl
(default SmoothBound(1e-5)) threaded into nlp_pack so AD sees differentiable kinks.
@rafaqz rafaqz requested a review from mrke May 10, 2026 10:06
generated_heat_flow_ipopt, skin_temperature_ipopt, insulation_temperature_ipopt)

generated_heat_flow_ipopt = out.energy_flows.generated_heat_flow
generated_heat_flow_ipopt = out.energy_flows.metabolic_heat_flow
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

metabolic_heat_flow_ipopt

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

how come? why would it change?

called at runtime when L-BFGS is active.
**Differentiation strategy.** Gradients and constraint Jacobians are computed via
[`Enzyme.jl`](https://github.com/EnzymeAD/Enzyme.jl): reverse-mode for the scalar objective
gradient and forward-mode for the constraint Jacobian. The `hess` and `cons_h` callbacks
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can delete this last caveat - it's repeated below in the limitations

# of `p` doesn't compose with Unitful values.
# hess! and cons_h! are registered (required by IpoptOptimizer) but not
# called at runtime when hessian_approximation="limited-memory" is set.
function grad_fn!(g, x, _)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should go for expressive names in this IPOPT code too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, all of these functions likely need to be deleted later on

@mrke
Copy link
Copy Markdown
Contributor

mrke commented May 11, 2026

Would be good to keep finite diff as an option, at least initially to compare performance

@gdalle
Copy link
Copy Markdown

gdalle commented May 11, 2026

@rafaqz anything I can do for better unit support in DI?

Comment thread docs/ipopt_endotherm_thermoregulation.md Outdated
@rafaqz rafaqz merged commit 154c641 into IPOPT-implementation May 11, 2026
2 checks passed
@rafaqz rafaqz deleted the autodiff-ipopt branch May 11, 2026 23:26
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