Skip to content

Promote despecialized parameter tangents - #5000

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/despecialized-parameter-tangent
Draft

Promote despecialized parameter tangents#5000
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/despecialized-parameter-tangent

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Ignore this PR until it has been reviewed by @ChrisRackauckas.

What changed and why

Teach ModelingToolkitBase's ChainRules extension to promote a Tangent{SciMLBase.DespecializedParameters} by unthunking its wrapped parameter cotangent and delegating to the existing promotion path. This preserves the documented AutoDespecialize wrapper boundary during observed-value pullbacks.

The extension test covers promoted type, values, and element type. ModelingToolkitBase is bumped from 1.67.0 to 1.67.1. No new public name or dependency is added.

Root cause

ModelingToolkit's AutoDespecialize default introduced by 5585668 causes observed-value AD to return a structural tangent for DespecializedParameters. ModelingToolkitBase's promotion helper only handled the underlying primal parameter values.

Failing before

The official SciMLBase LTS remake_autodiff.jl path fails deterministically before this extension method:

MethodError: no method matching
promote_type_with_nothing(
    ::Type{Float64},
    ::ChainRulesCore.Tangent{SciMLBase.DespecializedParameters,
        @NamedTuple{params::Vector{Float64}}}
)

The matching downstream job is https://github.com/SciML/SciMLBase.jl/actions/runs/32353474895/job/96378948536.

The focused extension regression fails on the same unhandled tangent before the patch.

Passing after

The native owning gate on Julia LTS passes:

GROUP=Extensions --project=lib/ModelingToolkitBase
HomotopyContinuation | 76/76
LabelledArrays        | 18/18
BifurcationKit        | 7/7
despecialized AD      | 5/5
Testing ModelingToolkitBase tests passed

With this patch plus the separate SciMLBase ODESolution-container fix, the identical official downstream file passes:

split=false | 7/7 | 4m34.3s

Runic over the changed Julia files, typos over the four-file diff, and git diff --check pass on the rebased branch.

QA baseline

The required native QA command was run on both the feature work and exact clean current master. The targeted JET fixtures pass 54/54 and all 20 non-package-JET checks pass. The sole clean-master failure is the package-wide JET assertion with 263 reports spanning generated Moshi/JET false positives and multiple independent source areas.

That aggregate master failure was independently audited and is already tracked; it was not changed or silenced here:

The hard package-JET boundary is 92c27bb. The same 263 reports reproduce across older and current JET/SciMLTesting versions.

Not verified

The docs build was not run because this adds no public declaration, signature, docstring, or documentation entry. Root ModelingToolkit functional groups, Julia prerelease, and GPU paths were not run locally.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>

Copy link
Copy Markdown
Member Author

The downstream SciMLBase reconstruction half is now the separate draft SciML/SciMLBase.jl#1544. The two PRs are independently scoped and the official LTS remake_autodiff.jl test passes 7/7 on the combined local stack.

Copy link
Copy Markdown
Member Author

Baseline CI audit for the unrelated Spell Check and docs build failures:

  • Spell Check reproduces unchanged on clean master with five findings in docs/src/internals/mtkcompile.md. Formal bisect: aae673d from docs: add internal docs page for mtkcompile #4993. A mechanical-only local fix has exact fail-before/pass-after, root QA 52/52, and whole-repo Runic green. It is being held until the independent docs prerequisite lands so its first CI revision is not knowingly red.
  • The docs build reproduces on clean master because the public @docs block still names ModelingToolkitBase.hessian_sparsity after that stale binding was removed in 63f684c. The focused fix is draft Remove stale non-public sparsity bindings from docs #5002; its identical full LTS docs command fails before and passes after.

Neither failure is caused by this PR's focused diff.

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