Skip to content

Keep narrowed metadata when remaking a concretized AutoDespecialize function - #1616

Merged
ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix/autodespecialize-remake-type
Sep 25, 2026
Merged

ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix/autodespecialize-remake-type

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

🚧 UNREVIEWED — awaiting review by @ChrisRackauckas. Filed by an AI agent running as @ChrisRackauckas; Chris has not seen this.

Harness: grok
Model: grok-4.7
Conversation: /home/crackauc/.grok/sessions/%2Fhome%2Fcrackauc%2Fsandbox%2Ffleet-master-jobs%2Fscimlbase-remake/01a0d4bd-2125-72d2-8b5b-a17915e7dfda

What changed and why

Re-concretizing an AutoDespecialize problem changed its type. DiffEqBase promote_f widens the bounded metadata parameters (initialization_data to Union{Nothing, OverrideInitData}, nlstep_data to Union{Nothing, ODENLStepData}) and, once the callable is already a FunctionWrappersWrapper, returns that widened function without the narrowing rebuild. remake then copied those non-concrete parameters onto the result.

That path is taken only because constructorof now keeps AutoDespecialize (#1606, b7076b57). The DiffEqBase assertion typeof(remade) === typeof(first_prob) in test/despecialized_p_test.jl:128 is the right expectation. The test was not changed.

remake restores type erasure from the original function, and from the replacement when get_concrete_problem passes f = promoted_f. It skips that restore only when both the original and the replacement are already-wrapped AutoDespecialize functions. That is a second concretization. A widened AutoSpecialize replacement, and a widened AutoDespecialize function that is not yet wrapped, still keep their erasure. A wrapped replacement of a function that is not yet wrapped also keeps its widened bounds: that is the first DAE concretization, and dropping it makes two models' DAEFunctions differ.

Relation to OrdinaryDiffEq#4599

This is a defensive guard. It is redundant with SciML/OrdinaryDiffEq.jl#4599 once that change is released.

#1606 named #4599 (make promote_f idempotent for an already concretized AutoDespecialize function) as the prerequisite, to be released first. #4599 alone also makes despecialized_p_test.jl pass, by not widening on the second concretization, so this remake branch is not reached from DiffEqBase. The two changes are compatible. This PR is not that root-cause fix, and it is not a reason to drop #4599.

SciMLBase still needs the guard. A release that contains #1606 has to stay safe for a DiffEqBase that does not yet have #4599, and SciMLBase cannot express that as a DiffEqBase lower bound: the downstream test runs against OrdinaryDiffEq master as it is today.

Verification

Julia 1.12.7 (julia +1.12). Downstream setup matches .github/workflows/Downstream.yml: OrdinaryDiffEq lib/DiffEqBase, with this SciMLBase checkout developed over it.

Before any of this PR, despecialized_p_test.jl:128 failed (14 passed, 1 failed). The only parameter difference was the ODEFunction tail: Union{Nothing, OverrideInitData}, Union{Nothing, ODENLStepData} versus Nothing, Nothing.

On b5811b44 (guard keyed only on the original function), the new scope testset failed:

only a wrapped AutoDespecialize replacement skips erasure: Test Failed
  Expression: metadata(remade_as) === (SciMLBase.AutoSpecialize, erased...)
   Evaluated: (SciMLBase.AutoSpecialize, Nothing, Nothing) ===
              (SciMLBase.AutoSpecialize, Union{Nothing, OverrideInitData}, Union{Nothing, ODENLStepData})
  Expression: typeof(remade_as) === typeof(widened_as)
  Expression: metadata(remade_plain) === (SciMLBase.AutoDespecialize, erased...)
   Evaluated: (SciMLBase.AutoDespecialize, Nothing, Nothing) ===
              (SciMLBase.AutoDespecialize, Union{Nothing, OverrideInitData}, Union{Nothing, ODENLStepData})
Test Summary:                                             | Pass  Fail  Total
only a wrapped AutoDespecialize replacement skips erasure |    2     3      5

remade_as is a widened AutoSpecialize replacement. remade_plain is a widened AutoDespecialize function that is not yet wrapped. Both originals were concretized AutoDespecialize functions.

After e3be16b2:

  • That testset: 6 passed, 0 failed (those two replacements, a concretized AutoSpecialize function, and a not-yet-wrapped original with a wrapped widened replacement).
  • concretized AutoDespecialize remake keeps narrowed metadata types: 7 passed.
  • despecialized_p_test.jl: 15, 3, 3, 26, and 3 passed. The DAE pair typeof(dae_concrete.f) === typeof(other_dae_concrete.f) is in the 26.
  • runic --check and typos on both edited files passed.

Keying the skip on the replacement alone was tried and rejected: despecialized_p_test.jl:178 then failed, because the first DAE concretization is itself a wrapped AutoDespecialize replacement and its widened initialization_data is what the two models share.

Earlier on b5811b44: DiffEqBase GROUP=Core passed (Despecialized-p Hook | 50) and SciMLBase GROUP=SII_Remake passed (4605). Those were not re-run after e3be16b2; the despecialized file and the function-building file were.

What I did not verify

Other SciMLBase downstream lanes, docs, and QA. Project.toml is still 3.56.0, the same version as the registered tag, which does not contain b7076b57. A release still needs a version bump; that is not in these commits.

Risk assessment

  • Risk: medium
  • Blast radius: remake(func; f = replacement) where both are already-wrapped AutoDespecialize functions and the replacement has non-concrete field parameters. Second concretization keeps the narrowed metadata types. A widened AutoSpecialize replacement, an unwrapped replacement, and a wrapped replacement of a function that is not yet wrapped still adopt erasure. No public name was added.
  • Evidence: the scope testset failed on b5811b44 (2 passed, 3 failed) and passed after e3be16b2 (6 passed). despecialized_p_test.jl passed after e3be16b2, including the ODE re-concretization and the DAE pair. It failed at line 128 before this PR.
  • Independent review: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium rated the previous commit CHANGES (B1, N1). This commit is the response. It has not been re-reviewed.
  • Merge: needs human review — the guard is the conjunction, not the replacement-only form, because the replacement-only form breaks the first DAE concretization.

Please ignore this draft until reviewed by @ChrisRackauckas.

🤖 Generated with grok (model: grok-4.7). Session: /home/crackauc/.grok/sessions/%2Fhome%2Fcrackauc%2Fsandbox%2Ffleet-master-jobs%2Fscimlbase-remake/01a0d4bd-2125-72d2-8b5b-a17915e7dfda


Independent review (Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium)

VERDICT: CHANGES

Risk assessment

  • Risk: low–medium. The change is a runtime guard in the erasure-restore tail of remake(::AbstractSciMLFunction; f=...). It only changes which type parameters the result gets, not field values. The worst outcome of a wrong guard is lost type erasure, meaning extra compilation, not wrong numbers.
  • Blast radius: every remake(func; f = g::AbstractSciMLFunction) where func is AutoDespecialize with func.f isa FunctionWrappersWrapper and g has erased params. That includes the problem-level remake(prob; f = ...) path, and so DiffEqBase get_concrete_problem. The guard is keyed on func, not on the replacement g, so it also fires for replacements that are not the intended "re-promoted concretized function" (see B1).
  • Evidence: local runs on Julia 1.12.7, listed under "What I ran". The downstream despecialized_p_test.jl:128 fails on SciMLBase master and passes with the PR. The new unit test fails on master and passes with the PR. SciMLBase GROUP=Core passes with the PR. A probe script shows the guard changes behavior in two cases outside the stated scope.
  • Independent review: this review.
  • Merge: needs review. It should also get an explicit decision on how it relates to Don't re-despecialize an already concretized AutoDespecialize function OrdinaryDiffEq.jl#4599 (see N1).
Full review

VERDICT: CHANGES

Review of #1616 (head b5811b44, base 4fa7f7f2), fixing the downstream DiffEqBase regression from #1606 (merge b7076b57).

Risk assessment

  • Risk: low–medium. The change is a runtime guard in the erasure-restore tail of remake(::AbstractSciMLFunction; f=...). It only changes which type parameters the result gets, not field values. The worst outcome of a wrong guard is lost type erasure, meaning extra compilation, not wrong numbers.
  • Blast radius: every remake(func; f = g::AbstractSciMLFunction) where func is AutoDespecialize with func.f isa FunctionWrappersWrapper and g has erased params. That includes the problem-level remake(prob; f = ...) path, and so DiffEqBase get_concrete_problem. The guard is keyed on func, not on the replacement g, so it also fires for replacements that are not the intended "re-promoted concretized function" (see B1).
  • Evidence: local runs on Julia 1.12.7, listed under "What I ran". The downstream despecialized_p_test.jl:128 fails on SciMLBase master and passes with the PR. The new unit test fails on master and passes with the PR. SciMLBase GROUP=Core passes with the PR. A probe script shows the guard changes behavior in two cases outside the stated scope.
  • Independent review: this review.
  • Merge: needs review. It should also get an explicit decision on how it relates to Don't re-despecialize an already concretized AutoDespecialize function OrdinaryDiffEq.jl#4599 (see N1).

Blocking findings

B1. The guard checks the wrong object, so it covers more than the intended case. The PR body's scope claim is also false.
_adopt_replacement_type_erasure(func) looks at the original function. The failing case is defined by the replacement: DiffEqBase promote_f returns an already-wrapped AutoDespecialize function whose bounded params were widened and never narrowed back. I ran probe.jl against master and the PR. It shows two out-of-scope behavior changes:

case master PR
3: func = concretized AutoDespecialize, f = widened AutoSpecialize function result === typeof(f) (erasure kept) AutoSpecialize, Nothing, Nothing: erasure dropped
4: func = concretized AutoDespecialize, f = widened not-yet-wrapped AutoDespecialize function erasure kept erasure dropped (result.f is not an FWW)

The PR body and code comment say "A function that is not yet wrapped still picks up erasure from the replacement". Case 4 contradicts that: when the replacement is the unwrapped one, it no longer does. Only an unwrapped func keeps the old behavior. Case 3 drops the compile-cache erasure that AutoSpecialize exists to provide.

Both cases are rare and only cost compilation, but the review criterion is "catches only the intended case", and this does not. The fix is small: key the helper on forig, since that is where the widened-but-wrapped signature lives. For example:

_adopt_replacement_type_erasure(g) = !(specialization(g) === AutoDespecialize &&
    hasfield(typeof(g), :f) && getfield(g, :f) isa FunctionWrappersWrappers.FunctionWrappersWrapper)

called as _adopt_replacement_type_erasure(forig). In the target case forig is promote_f(prob.f) of a concretized problem, so forig.f is the FWW, and cases 3 and 4 fall back to master behavior. Add probe cases 3 and 4, plus case 2 (concretized AutoSpecialize still adopts erasure), as assertions next to the new testset so the scope is actually pinned. Then fix the PR text and code comment to describe the condition that is actually implemented.

Non-blocking findings

N1. The relationship to SciML/OrdinaryDiffEq.jl#4599 is not mentioned. The merger needs it. #1606 itself named #4599 (make promote_f idempotent for concretized AutoDespecialize) as the prerequisite, to be released first. I ran all four combinations. #4599 alone also fixes the downstream test (SciMLBase master + ODE #4599: pass), and the two fixes are compatible (PR + #4599: pass, including #4599's idempotency testset). With #4599 merged, the PR's branch is unreachable from DiffEqBase.

There is still a legitimate case for this PR: it makes a SciMLBase release containing #1606 safe for users on a DiffEqBase without #4599, and SciMLBase cannot force a DiffEqBase lower bound. The PR body should say so explicitly ("defensive guard, redundant with OrdinaryDiffEq#4599 once that's released"), so that nobody later reads it as the root-cause fix and nobody drops #4599.

N2. A useful explanatory comment was deleted. The removed comment said why forig is checked (get_concrete_problem calls remake(prob; f = promoted_f), and the promoted function carries erasure the original does not). The replacement comment drops that. Keep one line of it. Also, the PR has 8 comment lines out of 47 added lines (~17%). The test comment "A second concretization widens…" and the helper's two-line comment largely repeat the code and the PR body.

N3. Test placement and fragility. The new testset is in test/function_building_error_messages.jl, a file about constructor error messages. It belongs with the remake tests. typeof(x).parameters[end - 1] / [end] hard-codes the position of initialization_data/nlstep_data in ODEFunction's parameter list. Adding a field would break the test silently or confusingly. fieldtype(typeof(x), :initialization_data) would be more robust. using FunctionWrappersWrappers inside the testset works (it is a direct dep, and CI Core passed), but SciMLBase.FunctionWrappersWrappers would avoid depending on it.

N4. #1606's intent is preserved. The PR does not touch constructorof. Probe cases 5–7 show specialization and the concretized type kept through remake(cA), remake(cA; f = rhs!), remake(prob; u0), and an already-widened func stays widened. #1606's own "rebuilding a function keeps its specialization" testset is in problem_building_test.jl, and it passed in the local GROUP=Core run. This is not a revert.

N5. No test weakening. The downstream test is unchanged. The only existing lines touched in src/ are the comment block and the added && clause. The new test's expected values are principled (the narrowed type equals the pre-remake type), not copied from output. It fails before the fix (6 pass / 1 fail) and passes after (7/7).

N6. SemVer. _adopt_replacement_type_erasure is a private helper, and no public API changes, so a patch bump fits. Project.toml is still 3.56.0, equal to the registered tag, so the release needs a bump in a separate commit or PR, as the author notes.

N7. PR CI.

  • OrdinaryDiffEq.jl/Core downstream passes on the PR and fails on master (b7076b57, 9cfd9e6d).
  • SciMLSensitivity Core1/6/7/8 fail on master too; Core8 has the same count on both (205 passed, 2 errored, 5 broken).
  • QA fails on the Base.Callable public-access check. That comes from the PR's base 4fa7f7f2, and master fixed it in Use the local Callable alias instead of non-public Base.Callable #1608, so a rebase should clear it.
  • SII lts/1 and ReleaseTest Catalyst/All/1 fail on master too.
  • SciMLSensitivity Core3 is new versus master. It is an LLVM segfault in Enzyme's post_optimize! (LoopUnroll/MemorySSA) at Core3/default_alg_diff.jl:21, on a default AutoSpecialize problem, where the new guard short-circuits on specialization(func) === AutoDespecialize. The same crash was reported on OrdinaryDiffEq#4599's CI. It looks flaky, but a re-run should confirm (unverified).

What I ran

All on Julia 1.12.7 (julia +1.12), in /Users/chrisrackauckas/sandbox/fleet-master/jobs/sb-1616.

SHAs:

  • SciMLBase master 9cfd9e6d, PR b5811b44
  • OrdinaryDiffEq master 418f7834, OrdinaryDiffEq#4599 head 0d1cfda1
  1. lib/DiffEqBase/test/despecialized_p_test.jl, with the SciMLBase worktree and the ODE tree's lib/DiffEqBase developed into one env (log_{A,B,C,D}.txt):
    • A, SB master + ODE master: Test Failed at .../despecialized_p_test.jl:128 Expression: typeof(remade) === typeof(first_prob), 14 passed, 1 failed
    • B, SB PR + ODE master: all pass (15, 3, 3, 26, 3)
    • C, SB PR + ODE #4599: all pass, plus concretizing a concretized problem is idempotent | 14
    • D, SB master + ODE #4599: all pass (same as C)
  2. The PR's new testset, extracted, against both SciMLBase versions (log_t2_{master,pr}.txt): master 6 pass, 1 fail at typeof(remake(concrete; f = widened)) === typeof(concrete); PR 7/7.
  3. My probe probe.jl (probe_{master,pr}.txt): results in the B1 table and N4.
  4. GROUP=Core julia +1.12 --project -e 'using Pkg; Pkg.test()' on the PR worktree (log_core_pr.txt): Testing SciMLBase tests passed, including Function Building Error Messages | 409.
  5. Read the PR CI logs: Core3 segfault, Core8 counts on PR vs master, QA Callable. Compared them with master IntegrationTest runs 35923456119 and 36085636423, Run Tests 36085636757, and ReleaseTest 36085635882.

What I did not verify

  • Whether the Core3 segfault reproduces or is flaky (not re-run; no Enzyme run locally).
  • Full DiffEqBase GROUP=Core with the PR (I ran only despecialized_p_test.jl; the author reports the full group passes).
  • SciMLSensitivity, ModelingToolkit, and NonlinearSolve lanes locally. I only compared CI.
  • Julia lts/1.10 behavior locally (CI Core lts passed).
  • The rewrite suggested in B1. I have not run it; it is a suggestion, not a tested patch.
  • SDE/DAE/Dynamical AutoDespecialize variants through the guard (only ODEFunction probed).

Links


Review by an AI agent (Devin CLI, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium). Local session, no URL published. Nothing was posted to GitHub.


🤖 Posted by an AI agent — orchestrator: Devin Sidekick on behalf of @ChrisRackauckas · reviewer: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local session; review transcript ~/sandbox/fleet-master/jobs/sb-1616/log.txt on Chris's Mac


Independent re-review at head e3be16b (Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium)

VERDICT: MERGE

Risk assessment

  • Risk: low. The change is one extra && clause in the erasure-restore tail of remake(::AbstractSciMLFunction; f = g). It only decides which type parameters the result gets; field values are unchanged. If the guard is wrong, the result is a narrower or wider type, which means extra compilation or a type mismatch, not wrong numbers.
  • Blast radius: remake(func; f = g) where func and g are both AutoDespecialize, both have .f isa FunctionWrappersWrapper, func is not type-erased, and g is. In practice that is DiffEqBase get_concrete_problem on an already-concretized AutoDespecialize ODE/SDE problem. It also covers the rare manual call where g is an unrelated wrapped AutoDespecialize function (N1 below).
  • Evidence: local runs on Julia 1.12.7, listed under "What I ran". The downstream check fails on master and passes with the PR, both against OrdinaryDiffEq master and against OrdinaryDiffEq#4599. The new scope testset fails on the round-1 head b5811b44 and passes on e3be16b2. The replacement-only alternative fails both the unit test and downstream :178/:179. SciMLBase GROUP=Core and DiffEqBase GROUP=Core pass with the PR.
  • Independent review: this review.
  • Merge: needs review. PR CI on e3be16b2 was still almost entirely pending when I checked. The QA lane will still fail on the stale base until the branch is rebased onto master (see N5).
Full review

VERDICT: MERGE

Re-review of #1616 at head e3be16b2 (base 4fa7f7f2). It fixes the downstream DiffEqBase regression from #1606 (merge b7076b57). The round-1 verdict was CHANGES, with blocker B1 and non-blocking N1.

Risk assessment

  • Risk: low. The change is one extra && clause in the erasure-restore tail of remake(::AbstractSciMLFunction; f = g). It only decides which type parameters the result gets; field values are unchanged. If the guard is wrong, the result is a narrower or wider type, which means extra compilation or a type mismatch, not wrong numbers.
  • Blast radius: remake(func; f = g) where func and g are both AutoDespecialize, both have .f isa FunctionWrappersWrapper, func is not type-erased, and g is. In practice that is DiffEqBase get_concrete_problem on an already-concretized AutoDespecialize ODE/SDE problem. It also covers the rare manual call where g is an unrelated wrapped AutoDespecialize function (N1 below).
  • Evidence: local runs on Julia 1.12.7, listed under "What I ran". The downstream check fails on master and passes with the PR, both against OrdinaryDiffEq master and against OrdinaryDiffEq#4599. The new scope testset fails on the round-1 head b5811b44 and passes on e3be16b2. The replacement-only alternative fails both the unit test and downstream :178/:179. SciMLBase GROUP=Core and DiffEqBase GROUP=Core pass with the PR.
  • Independent review: this review.
  • Merge: needs review. PR CI on e3be16b2 was still almost entirely pending when I checked. The QA lane will still fail on the stale base until the branch is rebased onto master (see N5).

Blocking findings

None.

Round-1 B1 is resolved. The guard is now !(_wrapped_autodespecialize(func) && _wrapped_autodespecialize(forig)), so it depends on the replacement as well as the original. Both round-1 out-of-scope cases now match master (probe_r2_{A2,B2}.txt):

probe case master b5811b44 e3be16b2
1: concretized AD, f = widened copy of itself (target case) widened (bug) Nothing, Nothing Nothing, Nothing
3: concretized AD, f = widened AutoSpecialize erasure kept erasure dropped erasure kept, === typeof(wS)
4: concretized AD, f = widened not-yet-wrapped AD erasure kept erasure dropped erasure kept
9: plain AD, f = widened wrapped AD (first-DAE shape) erasure kept erasure kept erasure kept
6: remake(prob; f = wA) === typeof(prob) false true true

The new testset only a wrapped AutoDespecialize replacement skips erasure separates the candidate guards:

  • On b5811b44 it fails 3 of 6 assertions (:65, :66, :69: remade_as and remade_plain lose their erasure).
  • On e3be16b2 it passes 6 of 6.
  • On a replacement-only variant of the guard (my suggestion in round 1, built as sb-alt) it fails 1 of 6 (:76, the first-DAE shape).

The same variant also fails downstream despecialized_p_test.jl:178 and :179 (typeof(dae_concrete.f) === typeof(other_dae_concrete.f)). So the author's reason for rejecting that form holds. The conjunction is needed, not a matter of style.

Non-blocking findings

N1. One out-of-scope case remains. Probe case 8: func is concretized AD for rhs!, and g is a widened, concretized AD function for a different rhs2!. Master adopts g's erasure (=== typeof(wA2)). The PR narrows the result to Nothing, Nothing. The guard asks "are both wrapped AD?", not "is g the re-promoted func?"

Only a manual call reaches this; DiffEqBase does not. The cost is lost erasure, not wrong results. A tighter key would pin the rule to the re-concretization identity: getfield(func, :f) === getfield(forig, :f). DiffEqBase _despecialize_auxiliary_functions never touches f.f, and probe case 10 shows widen_bounded_type_params(cA).f === cA.f. I have not run that variant. Optional.

N2. Round-1 N1 is answered in the body. The section "Relation to OrdinaryDiffEq#4599" calls the PR a defensive guard that becomes redundant once SciML/OrdinaryDiffEq.jl#4599 is released. It says #4599 alone also fixes the test, that the two changes are compatible, and that #4599 should not be dropped. It explains the guard is still needed because SciMLBase cannot require a DiffEqBase lower bound. All of this matches my runs: with #4599 plus this PR (C2), despecialized_p_test.jl passes fully, including #4599's concretizing a concretized problem is idempotent | 14.

N3. #1606's intent is preserved; this is not a revert. constructorof is untouched. On master and the PR, the specialization and concrete type survive the following remakes (probe cases 5 and 7):

  • remake(cA)
  • remake(cA; f = rhs!)
  • remake(prob; u0)
  • remaking an already-widened func, which stays widened

SciMLBase GROUP=Core passes with the PR. That group includes #1606's rebuild-keeps-specialization testset.

N4. No test weakening. The downstream test is unchanged. The expected values are principled:

  • remade type equals pre-remake type;
  • erased types equal widen_bounded_type_params output;
  • AutoSpecialize results equal the replacement's type.

None were copied from output. Testset 1 fails on master (:23, 6 pass / 1 fail) and passes on the PR.

N5. Housekeeping:

  • Comment lines are 17 of 89 added lines (19%), well above the ~10% guideline. The test comments restate the assertions under them, e.g. "Concretized AutoSpecialize still adopts erasure…" above the exact assertion that checks that. The code comment block is acceptable "why" text.
  • Round-1 N3 is only half addressed. The tests are still in test/function_building_error_messages.jl (a constructor error-message file) rather than the remake tests. Testset 1 still uses positional typeof(x).parameters[end - 1] / [end], even though testset 2 switched to fieldtype(..., :initialization_data).
  • The body's b5811b4 count ("2 passed, 3 failed", 5 total) is stale. Against the current 6-assertion testset it is 3 pass / 3 fail.
  • The body's banner puts the Harness: / Conversation: lines outside the blockquote.
  • The base is 4fa7f7f2, behind master 9cfd9e6d, which contains the QA Callable fix (Use the local Callable alias instead of non-public Base.Callable #1608). A rebase is needed for QA to go green.
  • Project.toml is still 3.56.0. The release needs a patch bump in a separate change. The helpers are private, so a patch bump fits SemVer.

What I ran

All on Julia 1.12.7 (julia +1.12), in /Users/chrisrackauckas/sandbox/fleet-master/jobs/sb-1616. Logs are in r2/.

SHAs:

  • SciMLBase master 9cfd9e6d; PR e3be16b2; round-1 head b5811b44
  • sb-alt = e3be16b2 with _adopt_replacement_type_erasure(func, r) = !_wrapped_autodespecialize(r) (r2/sb-alt.diff)
  • OrdinaryDiffEq master 7e9117f0; OrdinaryDiffEq#4599 head 0d1cfda1
  1. lib/DiffEqBase/test/despecialized_p_test.jl, with a SciMLBase tree developed over DiffEqBase (r2/deb_*.txt):
    • A2, master + ODE master: Test Failed at …despecialized_p_test.jl:128 Expression: typeof(remade) === typeof(first_prob), 14 pass, 1 fail
    • B2, PR + ODE master: all pass (15, 3, 3, 26, 3)
    • C2, PR + ODE #4599: all pass, plus concretizing a concretized problem is idempotent | 14
    • ALT + ODE master: fails at :178 and :179 (24 pass, 2 fail)
    • PR1, b5811b44 + ODE master: all pass
  2. The PR's two new testsets, extracted unchanged (r2/new_testsets.jl → r2/unit_*.txt):
    • master: 6/1 (:23)
    • b5811b44: 7/7 and 3/3 (:65, :66, :69)
    • e3be16b2: 7/7 and 6/6
    • ALT: 7/7 and 5/1 (:76)
  3. Probes:
    • r2/probe_r2.jl (round-1 probe plus cases 8–10), results in the tables above.
    • r2/probe_deb.jl: three chained get_concrete_problem calls for these cases, compared on master and the PR:
      • ODE AutoDespecialize: plain, with jac, and with initialization_data. On master c2 === c1 is false in all three; on the PR it is true in all three.
      • ODE AutoSpecialize, with and without initialization_data: stable, and identical on master and the PR.
      • DAE AutoDespecialize with initialization_data: stable on both, with erasure (Any, Union{Nothing, ODENLStepData}) kept; under ALT the erasure is lost.
  4. SciMLBase GROUP=Core on e3be16b2: Testing SciMLBase tests passed, Function Building Error Messages | 415 (r2/core_pr2.txt).
  5. DiffEqBase GROUP=Core with e3be16b2 developed over ODE master: Testing DiffEqBase tests passed, Despecialized-p Hook | 50 (r2/deb_core_pr2.txt).
  6. gh pr checks 1616 on e3be16b2: almost all lanes pending at review time.

What I did not verify

  • PR CI results on e3be16b2: pending when I checked. That includes SciMLSensitivity Core3, where round 1 saw an Enzyme segfault that looked flaky.
  • SDE through my probe_deb.jl. That row errored because of a bug in my script: it reads nlstep_data, which SDEFunction does not have. SDE re-concretization is covered by despecialized_p_test.jl:211–213, which passes on the PR.
  • The tighter identity-keyed guard suggested in N1 (not run).
  • The ModelingToolkit, SciMLSensitivity, and NonlinearSolve lanes locally, and Julia lts locally.
  • Runic and typos on the diff: the author reports them passing and the PR's Runic and Typos checks were green, but I did not re-run them.

Links


Review by an AI agent (Devin CLI, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium). Local session, no URL published. Nothing was posted to GitHub.


🤖 Posted by an AI agent — orchestrator: Devin Sidekick on behalf of @ChrisRackauckas · reviewer: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local session; review transcript ~/sandbox/fleet-master/jobs/sb-1616/log-r2.txt on Chris's Mac

ChrisRackauckas and others added 3 commits September 24, 2026 15:09
…unction

`remake` was copying non-concrete field types off the replacement function.
Re-concretizing an `AutoDespecialize` problem widens `initialization_data`
and `nlstep_data` and passes that widened function back into `remake`, so the
remade problem's type no longer matched. DiffEqBase
`test/despecialized_p_test.jl` requires `typeof(remade) === typeof(first_prob)`.

A concretized `AutoDespecialize` function already stores the narrowed field
types, and its callable is a `FunctionWrappersWrapper`. Do not adopt the
replacement's widened bounds in that case. A function that is not yet wrapped
still picks up erasure from the replacement.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Grok 4.7 <[email protected]>
Agent-Harness: grok
Agent-Model: grok-4.7
Agent-Session: /home/crackauc/.grok/sessions/%2Fhome%2Fcrackauc%2Fsandbox%2Ffleet-master-jobs%2Fscimlbase-remake/01a0d4bd-2125-72d2-8b5b-a17915e7dfda
…e function

The guard looked at the original function, so every erased replacement of a
concretized AutoDespecialize function lost its bounds. A widened
AutoSpecialize replacement and a widened function that is not yet wrapped
both came back narrowed.

The skip now requires both the original and the replacement to be
already-wrapped AutoDespecialize functions. That is the second
concretization. A wrapped replacement of a function that is not yet wrapped
still keeps its widened bounds, which is what the first DAE concretization
uses so two models share a type.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Grok 4.7 <[email protected]>
Agent-Harness: grok
Agent-Model: grok-4.7
Agent-Session: /home/crackauc/.grok/sessions/%2Fhome%2Fcrackauc%2Fsandbox%2Ffleet-master-jobs%2Fscimlbase-remake/01a0d4bd-2125-72d2-8b5b-a17915e7dfda
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 25, 2026 07:22
@ChrisRackauckas
ChrisRackauckas merged commit 83b4fc3 into SciML:master Sep 25, 2026
66 of 73 checks passed
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/SciMLBase.jl that referenced this pull request Sep 25, 2026
Pick up 83b4fc3 "Keep narrowed metadata when remaking a
concretized AutoDespecialize function (SciML#1616)" — touches
src/remake.jl and test/function_building_error_messages.jl,
which this branch does not modify; merges cleanly.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: Devin (SWE-2 Max)
Agent-Model: SWE-2 Max
Agent-Session: /home/crackauc/sandbox/fleet-master-jobs/nw-scimlbase-1092/log.txt
ChrisRackauckas referenced this pull request Sep 26, 2026
Agent-Harness: Claude Code
Agent-Model: claude-opus-5-5[1m]
Agent-Session: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 on Chris's Mac (session ID, no URL)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
SebastianM-C added a commit to SebastianM-C/OrdinaryDiffEq.jl that referenced this pull request Sep 26, 2026
SciMLBase 3.56.1 (SciML/SciMLBase.jl#1616) makes `remake` keep the narrowed
metadata types when a concretized `AutoDespecialize` function is replaced by a
re-widened one. That hides a non-idempotent `promote_f` from the problem-level
checks, so these now pass without the fix. Also compare the output of the
`promote_f` call of `get_concrete_problem` on an already concretized problem
directly, for the plain ODE and the SDE cases.

The `DynamicalODEFunction` case is left at the problem level: there
`promote_f` widens `ID` on every pass and `remake` narrows it back, so its
output never matches the concretized function.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ChrisRackauckas pushed a commit to SciML/OrdinaryDiffEq.jl that referenced this pull request Sep 27, 2026
#4599)

* Don't re-despecialize an already concretized AutoDespecialize function

`promote_f` widens the bounded type parameters of an `AutoDespecialize`
function (`_despecialize_auxiliary_functions`) and relies on the `@set`s of
the wrapping step to narrow them back. For a function that is already wrapped
the wrapping step is skipped, so concretizing a concretized problem returned
the widened type (`initialization_data::Union{Nothing, OverrideInitData}`).

This was masked because SciMLBase's `constructorof` reset the specialization
to the default on every `@set`, so a concretized problem was no longer
`AutoDespecialize`. Once the specialization survives (SciML/SciMLBase.jl#1606),
`despecialized_p_test.jl` catches it. Skip the auxiliary despecialization for
an `f` whose RHS is already wrapped; this works with either SciMLBase.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01JNAfKDURNdkubVjmftigPP

* Handle functions without an `f` field and SDEs in `_is_concretized`

`_is_concretized` read `f.f`, which `DynamicalODEFunction` (`f1`/`f2`) does not
have, so every `AutoDespecialize` `DynamicalODEProblem` threw a `FieldError`
when concretized. It also excluded `SDEFunction` outright, so an SDE wrapped by
the non-ForwardDiff path was despecialized again on a second concretization,
re-widening its `ID` parameter. Treat a function without an `f` field as not
wrapped, and an `SDEFunction` as wrapped when both drift and diffusion are,
matching the skip condition of the wrapping step.

Add an idempotency testset covering a plain `AutoDespecialize` ODE (no
jac/tgrad, which the existing test relies on), an SDE on the non-ForwardDiff
path and a `DynamicalODEProblem`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01JNAfKDURNdkubVjmftigPP

* Qualify `NoRecompileArgumentError` in the ForwardDiff extension

`wrapfun_oop` threw `NoRecompileArgumentError(IT)` unqualified, but the error
type lives in DiffEqBase, so the unsupported-signature path raised an
`UndefVarError` instead of the intended error.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01JNAfKDURNdkubVjmftigPP

* Test the unsupported-signature error of the ForwardDiff extension

An out-of-place `FunctionWrapperSpecialize` problem with argument types that
have no precompiled wrapper signature must raise `NoRecompileArgumentError`.
Before the previous commit it raised an `UndefVarError`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Check the idempotency of `promote_f` without `remake`

SciMLBase 3.56.1 (SciML/SciMLBase.jl#1616) makes `remake` keep the narrowed
metadata types when a concretized `AutoDespecialize` function is replaced by a
re-widened one. That hides a non-idempotent `promote_f` from the problem-level
checks, so these now pass without the fix. Also compare the output of the
`promote_f` call of `get_concrete_problem` on an already concretized problem
directly, for the plain ODE and the SDE cases.

The `DynamicalODEFunction` case is left at the problem level: there
`promote_f` widens `ID` on every pass and `remake` narrows it back, so its
output never matches the concretized function.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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