Repository navigation
Build the growth Jacobian without hcat, so ReverseDiff can take it, and replay compiled tapes at a second point - #1006
seabbs-bot wants to merge 5 commits into
Conversation
…s a quantity fixed
growth found its root and Jacobian on tracked numbers under ReverseDiff,
as _primal_value had no method for them, and ReverseDiff's hcat of a
Matrix{TrackedReal} with a TrackedArray is ambiguous with SparseArrays
loaded. A ReverseDiff extension gives _primal_value and _fixed their
values, as for ForwardDiff's dual numbers. Fixes #1003.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwC7ixGWZNbRbSXXsSPbAs
|
For the owner, two questions from the coordinating session, measured on Julia 1.13.4 with ReverseDiff 1.18.11. (a) No stripping, with the Jacobian in
Each cell is the largest difference from the ForwardDiff gradient at that point over the largest entry of it, then the minimum time; the compiled tape is recorded at θ in both columns. (b) The docs page. Generated by Claude Code |
…age holds a quantity fixed" This reverts commit 4428bc2.
…piled tapes at a second point
The Jacobian was joined with hcat and vcat, and ReverseDiff's hcat of
a Matrix{TrackedReal} with a TrackedArray is ambiguous with SparseArrays
loaded. It is now filled block by block in an array like M, which takes
tracked numbers, and nothing is stripped for them: a compiled tape that
takes the root as a constant gives a wrong gradient at another point.
The compiled-tape check replays each registry scenario at a point about
1% from the one it was recorded at. Fixes #1003.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwC7ixGWZNbRbSXXsSPbAs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwC7ixGWZNbRbSXXsSPbAs
The coupling of "Growth rate and profile of strata that mix" is `K0` scaled entry by entry by the exponential of its parameters, so it mixes the strata at the zero vector too. A tape recorded near the point it replays at runs the same steps of a loop, so the second-point replay check is `@test` for every scenario and no longer reads the broken list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwC7ixGWZNbRbSXXsSPbAs
|
Merged through #1022, which carries this branch with main merged in and the compiled-tape entry. Generated by Claude Code |
Try this Pull Request!Option 1: Julia Package ManagerOpen Julia and type: import Pkg
Pkg.activate(temp=true)
Pkg.add(url="https://github.com/EpiAware/ComposableRecurrences.jl", rev="claude/reversediff-growth")
using ComposableRecurrencesOption 2: Local CheckoutIf you have the repo locally: git checkout claude/reversediff-growth
julia --project=. -e "using Pkg; Pkg.instantiate()" |
Fixes #1003.
What changes
growthbuilds the Jacobian of its root in_eigen_jacobianblock by block in an array likeM(similar(M, T, S + 1, S + 1)), in place ofvcat(hcat(...), hcat(...)).Under ReverseDiff the blocks are a
Matrix{TrackedReal}and aTrackedArray, and ReverseDiff'shcatof that pair is ambiguous once SparseArrays is loaded (ReverseDiff.jl: faults found #1007), so the two growth-of-mixing-strata scenarios failed on both ReverseDiff backends.The first version of this PR added a ReverseDiff extension that took their values, as
_primal_valuedoes for dual numbers; a compiled tape then held the root and the Jacobian as constants and gave a wrong gradient at any other point (see the comment below), so it was reverted.test/ad/checks.jl) also records each registry scenario at its parameters and replays it at a point about 1% away (0.01 where an entry is zero), against the ForwardDiff gradient there.The existing check records at zero and replays at the parameters, which gives no second point for the scenarios whose parameters are zero.
Checks run
Julia 1.13.4, ReverseDiff 1.18.11.
test/aditemReverseDiff (compiled) gradientswith the replay: 3120 passed, 13 failed. Every scenario passes the replay at a second point.The 13 failures are one scenario, "Growth rate and profile of strata that mix": the kit's check records the compiled tape at the zero vector, where the coupling matrix is zero and no growth rate exists, so the tape records the branch that returns NaN and replays it at the parameters (12 failures in the kit's correctness check and 1 in the entry-by-entry check).
Not run here
https://claude.ai/code/session_01WwC7ixGWZNbRbSXXsSPbAs
Generated by Claude Code