Skip to content

Restore uncached version of moi_function#4189

Merged
odow merged 4 commits into
masterfrom
od/restore-moi-function
Jul 7, 2026
Merged

Restore uncached version of moi_function#4189
odow merged 4 commits into
masterfrom
od/restore-moi-function

Conversation

@odow

@odow odow commented Jul 1, 2026

Copy link
Copy Markdown
Member

#4032 broke Plasmo because Plasmo calls moi_function(f::GenericNonlinearExpr).

We could have fixed this with moi_function(f) = moi_function(owner_model(f), f), but this is still breaking if owner_model(f) isn't a JuMP.GenericModel.

It seems safest just to restore the old function. The subexpression caching is opt-in for now.

https://github.com/jump-dev/JuMP.jl/actions/runs/28488003220

@odow odow mentioned this pull request Jul 1, 2026
14 tasks
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.93%. Comparing base (d60d2c6) to head (9e33fcd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4189   +/-   ##
=======================================
  Coverage   99.93%   99.93%           
=======================================
  Files          42       42           
  Lines        6258     6277   +19     
=======================================
+ Hits         6254     6273   +19     
  Misses          4        4           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@blegat

blegat commented Jul 1, 2026

Copy link
Copy Markdown
Member

We should document precisely that moi_function(::GenericNonlinearExpr) is the version instantiating aliases and moi_function(::GenericModel, ::GenericNonlinearExpr) keeps JuMP aliases as MOI aliases.
Option 2 is to try falling back to moi_function(::GenericModel, ::GenericNonlinearExpr) and if owner_model is nothing (constant expression ? Must be pretty rare) or it is not GenericModel then we don't do the cache, otherwise we do.

Having this very subtle behavior with aliases just be undocumented could be quite confusing. Especially since now agents will like tweaking with JuMP internals directly so they will probably like just calling moi_function directly so we should be crystal clear.

@blegat

blegat commented Jul 1, 2026

Copy link
Copy Markdown
Member

One thing that worries me with option 1 is that we might forget to call moi_function with the model as first argument and this kind of but might be tricky to catch. I removed this method on purpose to easily catch all cases where this was needed. Now that we add this method, we might in the future just call moi_function in the JuMP call and forget about moi_function(::GenericModel, ..). In thing Option 2 is probably safer.
We could also add a function that should return the cache and we make it default to return nothing for JuMP.AbstractModel.

@odow

odow commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

See also #4190

Agree that we need to think about this in a lot more detail.

@odow

odow commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Merging this since it fixes a breaking change. We can think more about it in #4190

@odow
odow merged commit b0fc1a7 into master Jul 7, 2026
12 checks passed
@odow
odow deleted the od/restore-moi-function branch July 7, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants