Add oximo-autodiff crate#38
Conversation
I am sure this can be improved a lot
Most of these tests were added by GitHub Copilot. We can probably improve them in the future. Assisted-by: GitHub Copilot
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds the ChangesAutodiff implementation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Model
participant NlpEvaluator
participant Tape
participant Enzyme
Model->>NlpEvaluator: construct slots and sparsity structures
NlpEvaluator->>Tape: compile nonlinear expressions
NlpEvaluator->>Enzyme: evaluate gradient or compressed HVP seeds
Enzyme-->>NlpEvaluator: return derivative buffers
NlpEvaluator-->>Model: provide objective, Jacobian, and Hessian values
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/autodiff.yml:
- Line 22: Update the actions/checkout@v6 step in the workflow to disable
credential persistence by configuring its persist-credentials option to false,
ensuring the checkout token is unavailable to subsequent steps.
In `@crates/oximo-autodiff/src/evaluator.rs`:
- Around line 244-259: Reject parameter refreshes when any objective or
constraint slot changes its is_nonlinear() state, since cached lagrangian,
nl_sources, and seeds would otherwise become invalid. Update refresh_params and
the corresponding try_refresh path to compare each slot’s pre-refresh and
post-refresh nonlinear membership, returning the existing refresh error/result
type on mismatch; otherwise preserve the current reclassification and cache
rebuild behavior.
- Around line 273-283: Update Evaluator::try_refresh to include arena/model
identity in its refresh validation instead of relying only on ExprId values,
which are local to each arena. Reject refresh when the supplied model uses a
different arena, ensuring the stale nonlinear tape is not reused; retain the
existing variable, objective, and constraint checks for the same arena.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 528fbd19-be1d-4c22-ad93-194a98212665
📒 Files selected for processing (15)
.github/workflows/autodiff.ymlCargo.tomlcrates/oximo-autodiff/Cargo.tomlcrates/oximo-autodiff/README.mdcrates/oximo-autodiff/src/enzyme.rscrates/oximo-autodiff/src/error.rscrates/oximo-autodiff/src/evaluator.rscrates/oximo-autodiff/src/lib.rscrates/oximo-autodiff/src/linearize.rscrates/oximo-autodiff/src/slot.rscrates/oximo-autodiff/src/sparsity.rscrates/oximo-autodiff/src/tape.rscrates/oximo-autodiff/tests/derivatives.rscrates/oximo-autodiff/tests/sparsity.rscrates/oximo-autodiff/tests/tape.rs
Also add oximo-clarabel and oximo-macros
Description
This PR adds support for automatic differentiation of oximo models through
std::autodiff(nightly only).Checklist
cargo fmtandcargo clippyto ensure code qualitycargo test)cargo test --features gamspasses (requires GAMS)cargo test --features gurobipasses (requires Gurobi)cargo test --features baronpasses (requires BARON)Related Issues
Closes #12