Skip to content

Recognize copied symbolic missing bindings - #5073

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/fix-copied-missing-bindings-current
Closed

ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/fix-copied-missing-bindings-current

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

What changed

Recognize symbolic missing bindings by isequal, not object identity. Deep-copying a problem can copy the symbolic constant wrapping missing; initialization then incorrectly treats a solvable parameter as a bound parameter and omits it from the initialization unknowns. This breaks parameter remakes used by ensembles, including constant states eliminated to solvable parameters.

The regression exercises both the original problem and its deep copy with the same parameter remake. No new public API or dependencies.

Verification

Julia 1.11.9, local environments with identical dependency versions and only the ModelingToolkit/ModelingToolkitBase source paths changed:

GROUP=Initialization julia --project=EMA-deepcopy-main-env -e 'using Pkg; Pkg.test("ModelingToolkitBase")'

Unfixed production source at c4c04fe, with the new test added:

Remake with copied missing parameter bindings: Error During Test
ArgumentError: Symbol N is not present in the system.
InitializationSystem Test | 663 pass, 1 error, 12 existing broken
Remake with copied missing parameter bindings | 2 pass, 1 error

With the fix before rebasing:

Guess Propagation | 11/11
InitializationSystem Test | 665 pass, 12 existing broken
Initial Values Test | 65/65
Testing ModelingToolkitBase tests passed

GROUP=QA passed JET 54/54 and Aqua 21/21. Runic, git diff --check, and typos over the diff excluding Git index-hash metadata passed. No tests were skipped or weakened by this change.

After rebasing onto upstream 2b4f11a, the complete native Initialization group passed again:

Guess Propagation | 11/11
InitializationSystem Test | 667 pass, 12 existing broken
Initial Values Test | 65/65
Testing ModelingToolkitBase tests passed

The corresponding QA rerun passed JET 54/54 and Aqua 21/21, exit 0. Upstream subsequently advanced to e76112c; the refreshed branch is 2e20892.

Latest refresh verification at 2e20892, on upstream e76112c:

GROUP=Initialization julia --project=EMA-deepcopy-current-env -e 'using Pkg; Pkg.test("ModelingToolkitBase")'
GROUP=QA julia --project=EMA-deepcopy-current-env -e 'using Pkg; Pkg.test("ModelingToolkitBase")'
Guess Propagation | 11/11
InitializationSystem Test | 667 pass, 12 existing broken
Initial Values Test | 65/65
Testing ModelingToolkitBase tests passed

JET Tests | 54/54
Aqua Tests | 21/21
Testing ModelingToolkitBase tests passed

Both commands exited 0 (Initialization 1747.0s, QA 785.9s, excluding environment setup). The focused original/copied-problem remake check also exited 0. Runic, diff spelling, and git diff --check passed on the refreshed branch. Validation-only absolute paths generated by QA were restored and are not part of the change.

Historical reduction

The explicit missing-binding failure reproduces across the MTK 11 main-branch merge boundary: the equivalent pre-merge defaults model passes 2/2; the post-merge binding model errors only on the deep-copied problem. The constant-state manifestation has a narrower verified boundary: the same standalone constant-state model passes 2/2 immediately before 0b01708 and fails 1 pass/1 error immediately after it, with N#0(t) ... is not an unknown. Those adjacent runs use identical dependencies and ModelingToolkitBase source; only ModelingToolkit root source differs. Zero-variable elimination exposes the existing missing-binding identity bug.

Not verified

Full ModelingToolkit root suite and GPU paths were not run for this patch. Full downstream EMA docs remain in progress and are not claimed successful. The Carcione reduction also uncovered a separate SBML assignment-rule initialization failure, fixed at SciML/SBMLToolkit.jl#240 . Combining that fix with the SBML parameter-default fix at SciML/SBMLToolkit.jl#239 and this MTK fix passes two explicit solver-return-code checks (default and changed mu), both reaching the requested final time. This patch changes no documentation, docstrings, or public API, so the MTK documentation was not built.

Please ignore this draft until reviewed by @ChrisRackauckas.

🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; session: local transcript /home/crackauc/.codex/sessions/2026/09/05/rollout-2026-09-05T05-08-31-01a070d3-9e50-71c2-98f5-129385e50fb7.jsonl).

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

The downgraded QA failure now reproduces on the unchanged base as well as this branch; the copied-missing patch is not required for it.

I ran the CI action at 30b83cf94e89744fcbd7ea5496be4967d6fbe540 on two separate clean production checkouts: base e76112cc0c9f83f8e17f2485f1627572ff0aabac and patch 2e20892791e27e88bce578cbeff33395d3faff04, using Julia 1.10.12 and the workflow's exact downgrade skip list. Then, from lib/ModelingToolkitBase, I ran:

using Pkg
Pkg.build(; verbose=true)
Pkg.test(; coverage=true,
    julia_args=["--check-bounds=yes", "--compiled-modules=yes", "--depwarn=yes"],
    force_latest_compatible_version=false, allow_reresolve=false)

with GROUP=QA. Both processes exited 1:

unchanged base: JET Tests 54/54; Aqua Tests 17 passed, 2 failed
patched code:  JET Tests 54/54; Aqua Tests 17 passed, 2 failed
failed groups: Stale dependencies; Persistent tasks

The two actual Pkg.test sandbox manifests contain 306 entries and are identical except for local checkout paths. All 283 package versions printed in the failing CI sandbox match the local sandbox versions.

The action promotes 34 old-style test dependencies into runtime [deps]. Aqua reports those as stale; the added runtime dependency on ModelingToolkitStandardLibrary also introduces a cycle. A separate no-SciML reproduction establishes the adjacent action-commit boundary: parent 2c401f8 passes Aqua but loses the selected test-package floor (DataStructures 0.18.22 instead of 0.17.0); 30b83cf preserves 0.17.0 but fails Aqua because DataStructures and Aqua became runtime dependencies. Each run has one passing and one failing assertion. An action-level candidate preserving dependency classification and selected versions passes the small reproducer, but its full suite and the full ModelingToolkit QA rerun are still in progress. No QA check was disabled or ignored.

The separate Julia 1.12 QA/JET failure is also being investigated against the unchanged base; this comment does not claim that investigation is complete.

Links:

🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; session: local transcript /home/crackauc/.codex/sessions/2026/09/05/rollout-2026-09-05T05-08-31-01a070d3-9e50-71c2-98f5-129385e50fb7.jsonl).

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

The separate Julia 1.12 QA failure is reproduced on this PR's clean base, independently of the copied-binding change. Native QA on e76112cc0c9f83f8e17f2485f1627572ff0aabac with Julia 1.12.7 / JET 0.12.1 passes the dedicated JET tests (54/54), then fails Aqua (20 passed, 1 failed) with the same 234 Moshi-generated-variable reports.

The existing Moshi fix at ChrisRackauckas-Claude/Moshi.jl@7b5ef92 makes the full native QA run pass: JET 54/54 and Aqua 21/21. All other dependency versions/source hashes match, including all 311 other names in the actual Pkg.test sandbox; no ModelingToolkit source/tests or JET mode were changed.

Exact commands, terminal output, versions, and comparison details: #5065 (comment) . This diagnoses the non-downgrade QA lane; it does not change the downgrade investigation or publish the Moshi fix upstream.

AI involvement: Codex CLI 0.153.4; model: gpt-6-astra; local session ID: 01a071a0-abb2-7eb2-8e39-9cab28110384 (parent local session: 01a0598f-11b9-72d1-91d9-b2fbb186557d).

Compare symbolic missing values semantically so deepcopied solvable parameter
bindings remain solvable during problem initialization and remake.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]>
Agent-Harness: Codex CLI 0.153.4
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/05/rollout-2026-09-05T05-08-31-01a070d3-9e50-71c2-98f5-129385e50fb7.jsonl
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the codex/fix-copied-missing-bindings-current branch from 2e20892 to 6999ea9 Compare September 6, 2026 06:52
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Current registered-dependency downstream confirmation: the copied-problem failure remains reproducible after both SBMLToolkit fixes were released. This is additional failure evidence, not a fresh validation of this PR's patch.

I ran the first three actual Carcione tutorial blocks with only the existing API migrations convert(ODESystem, rs) → ODESystem(mdl) and Rodas5() → Rodas5P(), retaining structural_simplify. Then I checked the base solution and attempted the parameter remakes used by the sensitivity calculation:

@test successful_retcode(sol)
@test last(sol.t) == last(prob.tspan)
@test all(isfinite, Array(sol))
for value in (0.012048, 0.015)
    remade = remake(deepcopy(prob); p = [sys.mu => value], tspan = (0.0, 100.0))
    solution = solve(remade, Rodas5P())
    @test successful_retcode(solution)
    @test last(solution.t) == 100.0
    @test all(isfinite, Array(solution))
end

Julia 1.11.9; ModelingToolkit 11.42.0, ModelingToolkitBase 1.69.0, Catalyst 16.4.0, SBMLToolkit 0.1.42, SymbolicUtils 4.46.1, SciMLBase 3.53.1. All dependencies are registered; only the EasyModelAnalysis host checkout is developed locally. Project/Manifest were unchanged throughout the run.

CARCIONE_BLOCK_END 3
INITIAL retcode=Success final_time=1.0
Registered Carcione initial solve | 3 passed / 3 total
Registered Carcione parameter override solves: Error During Test
ArgumentError: var"Total_population#0"(t) is present in the system but var"Total_population#0"(t) is not an unknown.
Registered Carcione parameter override solves | 1 error / 1 total
exit 1

The first remake fails before its solve; the second parameter case is not reached. No 2,000-sample run was launched after this failed numerical prerequisite. Existing deprecation and QMC warnings were retained. The prior local combined-fix success is not being represented as registered-stack success.

Links:

🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; session: local session ID 01a0598f-11b9-72d1-91d9-b2fbb186557d).

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