Repository navigation
Fix Zygote gradients for mutable surrogates - #632
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
Read fitted fields before the reductions and comprehensions so Zygote does not accumulate a MutableTangent from ChainRules against its own named-tuple tangent for the same surrogate. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.171.0 Agent-Model: gpt-6.2-sol Agent-Job: 628-codex Agent-Session: local session 01a21836-a14f-7210-a6ca-1e0f89d2ea7f (no session URL)
PR: #632 Reviewed head: d2e7806 Risk assessment
Review reportVERDICT: MERGE Riskmedium-low (ML11) — Before/after benchmarks show lower Zygote allocation on common prediction paths, with matching prediction and query-gradient results and passing downstream tests. Surrogates.jl users calling Blocking findingsNone. Nonblocking findings
What I ran
What I did not verify
Head link: d2e7806 🤖 Posted by an AI agent — harness: codex-cli 0.172.0 · model: gpt-6.2-sol |
Inverse-distance, Lobachevsky, Kriging, and GEK prediction closures now capture their fitted fields directly. This keeps a mutable surrogate out of the differentiated reductions and comprehensions where Zygote 0.7.20 tried to add a ChainRules
MutableTangentto Zygote’s named-tuple tangent.Verification
Julia 1.13.4 with ChainRulesCore 1.26.8. Each command uses an isolated project selected by
AD_ENV, with Surrogates developed at either the base revision or the PR revision.Before the patch, Zygote 0.7.20 (exit 1). The direct include stopped at the failing Zygote testset.
Output excerpt from the failing test summary.
After the patch, the same test file ran with Zygote 0.7.20 and 0.7.21.
Zygote 0.7.21 output tail.
Zygote 0.7.20 output tail.
Review
Please check whether moving the fitted field reads outside the closures is enough for downstream callers that differentiate through model parameters as well as through query points. Local verification covered the complete AD compatibility file on the two versions above. The rest of the repository test suite, other Julia versions, and gradients with respect to fitted model parameters were outside that verification.
Closes #628
🤖 Posted by an AI agent — harness: Codex CLI 0.171.0 · model: gpt-6.2-sol
Conversation: local session 01a21836-a14f-7210-a6ca-1e0f89d2ea7f (no session URL)