Repository navigation
Fix tmp field typing in remaining symplectic caches for unitful state - #4603
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
LeapfrogDriftKickDriftCache, VerletLeapfrogCache, and SymplecticGenericCache have the same defect as VelocityVerletCache (SciML#1397): tmp was declared uType but holds the rate-typed kdu/ku buffers used by alloc_symp_state, and the alg_cache constructor calls passed k/tmp swapped relative to the field order. VerletLeapfrogCache and SymplecticGenericCache additionally built tmp from zero(u) instead of zero(rate_prototype). With Unitful initial conditions uType != rateType, so the inner constructors had no matching method and solve() threw a MethodError for the in-place path of every affected algorithm (the out-of-place constant caches are unaffected). Fields are now typed rateType, tmp is built from zero(rate_prototype), and constructor arguments are passed in field order. Unitful is added as a test-only dependency for a regression test covering LeapfrogDriftKickDrift, VerletLeapfrog, and McAte2 in both in-place and out-of-place modes. Part of SciML#1397 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI Agent-Model: swe-2-high Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-OrdinaryDiffEq.jl-1397/log.txt on amdci2.julia.csail.mit.edu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4602 for the same defect in the sibling caches:
LeapfrogDriftKickDriftCache,VerletLeapfrogCache, andSymplecticGenericCacheall declaretmp::uTypewhile the field holds the rate-typedkdu/kubuffers used byalloc_symp_state, and theiralg_cachecalls passk/tmpswapped relative to the field order.VerletLeapfrogCacheandSymplecticGenericCacheadditionally buildtmpfromzero(u)instead ofzero(rate_prototype). With Unitful initial conditionsuType != rateType, so the in-place path throws the sameMethodErroras #1397 forLeapfrogDriftKickDrift,VerletLeapfrog, and every generic-tableau algorithm (McAte2,Ruth3,SofSpa10, ...). The out-of-place constant caches (*ConstantCache/ tableaus) hold onlyhalf/coefficients and are unaffected. Unitful is added as a test-only dependency for the regression test (same as #4602, DelayDiffEq precedent).Verification
New testset in
lib/OrdinaryDiffEqSymplecticRK/test/symplectic_tests.jl("symplectic $alg with units iip=true/false", alg ∈ {LeapfrogDriftKickDrift, VerletLeapfrog, McAte2}), same Unitful SecondOrderODEProblem setup as #4602 with a constant-acceleration case checked against the analyticx(t) = x0 + v0*t + g*t^2/2(exact for these order-2 methods).Failing on unfixed code (src change stashed; per-algorithm probe):
Passing with the fix:
Test group run:
cd lib/OrdinaryDiffEqSymplecticRK && GROUP=Core julia --project=. -e 'using Pkg; Pkg.test()'— tail:(The 4 broken are the pre-existing
@test_brokenMcAte42 cases; the 184 includes the 24 new units tests — 3 algorithms × 2 iip modes × 4 assertions.) Runic: no changes needed on the touched files.typos: clean.NOT verified
GROUP=QAdied onEMFILE— file-descriptor exhaustion on the shared CI host, not a code issue): JETtest_package(..., mode=:typo)1/1 pass; SciMLTestingrun_qa(Aqua/ExplicitImports) 20/20 pass. The AllocCheck lane passed on Fix VelocityVerletCache tmp field typing for unitful state #4602's near-identical diff and is unchanged by this branch (same file, same pattern —perform_step!untouched).get_tmp_cachereturnscache.tmpfor every mutable cache and is used to build continuous-callback condition signatures (OrdinaryDiffEqCore/src/solve.jl:170). With this change the returned scratch is now rate-typed rather than state-typed; it already was rate-typed at runtime before (thekargument landed in thetmpslot), but a reviewer may want a dedicated continuous-callback test on a unitful symplectic problem.What a reviewer should push back on
SymplecticEulerCachekeepstmp::uType/zero(u)— itsperform_step!never usestmpas a rate buffer, so it is consistent; double-check no other code path expects a rate buffer there.Part of #1397. See also #4602.
Please ignore this draft until reviewed by @ChrisRackauckas.
Risk assessment
LeapfrogDriftKickDriftCache,VerletLeapfrogCacheandSymplecticGenericCachein OrdinaryDiffEqSymplecticRK. The fix is the sametmp::rateType/zero(rate_prototype)/ field-order change as Fix VelocityVerletCache tmp field typing for unitful state #4602. It covers every generic symplectic tableau method. No public API change.🤖 Generated with Devin CLI (model: swe-2-high), transcript /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-OrdinaryDiffEq.jl-1397/log.txt on amdci2.julia.csail.mit.edu
Risk assessment and review coordination by 🤖 Claude Code (model: claude-opus-5-5[1m]), https://claude.ai/code/session_01NdFVhANTF4nepTbqYxjfRP
Independent review (Claude Code cloud / claude-opus-5-5)
VERDICT: MERGE
(no risk section)
Full review
VERDICT: MERGE
Risk assessment
VerletLeapfrog and the 14 SymplecticGenericAlgorithm methods in
lib/OrdinaryDiffEqSymplecticRK. The out-of-place constant caches are
untouched. Unitful is added only as a test dependency. No public API change,
so a patch release fits SemVer.
(https://github.com/SciML/OrdinaryDiffEq.jl/blob/418f7834c143dbb95db9d45c40a
d83ed52cedafe/lib/OrdinaryDiffEqSymplecticRK/src/symplectic_caches.jl),
symplectic_perform_step.jl (https://github.com/SciML/OrdinaryDiffEq.jl/blob/
418f783/lib/OrdinaryDiffEqSymplecticRK/src/
symplectic_perform_step.jl)).
into the field tmp::uType. For the generic and VerletLeapfrog caches it
also put zero(u) into the field k::rateType. So the constructor only
worked when typeof(zero(u)) == typeof(zero(rate_prototype)).
constructed before, the objects are the same type with the same contents.
perform_step! reaches cache.tmp only through alloc_symp_state
(perform_step.jl:121), where it destructures into the rate buffers kdu,
ku. It never uses cache.k by name.
It only unblocks the paths that previously threw a MethodError.
and CI sublibrary-ci / OrdinaryDiffEqSymplecticRK Core (1, lts, pre) plus
QA are green.
Blocking findings
None.
Non-blocking findings
VelocityVerletCache still has tmp::uType and the swapped call
(symplectic_caches.jl:36,56), so Fix VelocityVerletCache tmp field typing for unitful state #4602 has not landed and this diff does
not include it. Both PRs add Unitful to the same [extras], [compat] and
[targets] lines, and both append a units testset at the end of
symplectic_tests.jl. If Fix VelocityVerletCache tmp field typing for unitful state #4602 defines helpers with the same names
(accel_units! etc.; the body says it uses the "same setup"), whichever PR
merges second needs a rebase and should reuse or deduplicate those helpers.
I have not seen Fix VelocityVerletCache tmp field typing for unitful state #4602's diff, so the name clash is unconfirmed.
acceleration.
rtol (√eps).
tableau methods get the constructor fix, though they are not tested
individually. That is acceptable.
At runtime it already returned a rate-typed buffer before the fix, so
nothing changes. A continuous-callback test on a unitful problem would be a
follow-up, not a merge requirement.
SciMLSensitivity.jl/Core1/1 failed after 1h2m, and so did Core3. Both
downgrade jobs that failed, lib/DiffEqBase and
lib/OrdinaryDiffEqDifferentiation, cover sublibraries that this PR does not
touch and that do not depend on SymplecticRK. They are almost certainly
pre-existing.
SciMLSensitivity Core3 (and Core1): probably not caused by this PR.
the fix builds the same cache objects afterwards. For this PR to cause a
failure, a test would have to hit a path that previously threw a
MethodError, which would have made the test fail before as well.
as are the SymplecticRK sublibrary, AD, Integrators, Downstream and GPU
groups.
To settle it:
iffEq.jl/actions/runs/35874247391/job/107225931220)) and find the failing
testset and stack trace. If no frame is in OrdinaryDiffEqSymplecticRK and no
symplectic algorithm appears, the PR is cleared.
day. The resolved SciMLSensitivity version must match, because a newly
released SciMLSensitivity or dependency is the usual cause.
What I checked
order now matches the positional arguments in all three caches.
destructuring into kdu, ku, which are rate buffers.
consistent and correctly left alone.
dropped. The Unitful dependency is test-only and has a compat bound.
What I did not verify
relied on the author's paste plus green CI.
master's status for those jobs.
Links
5874247391/job/107225931220
5874247391/job/107225931116
https://github.com/SciML/OrdinaryDiffEq.jl/blob/418f7834c143dbb95db9d45c40ad
83ed52cedafe/lib/OrdinaryDiffEqSymplecticRK/src/symplectic_caches.jl
🤖 Posted by an AI agent — orchestrator: Devin Sidekick on behalf of @ChrisRackauckas · reviewer: Claude Code cloud / claude-opus-5-5
Conversation: cloud review session; transcript ~/sandbox/fleet-master/jobs/carry/cloud-out-4603.txt on Chris's Mac