Fix restructure pullback source projection - #507
Conversation
Project the reconstructed cotangent into the differentiated source's tangent space so sources and targets with different shapes have a valid pullback. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: OpenAI Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.151.0 Agent-Model: gpt-5.6-sol Agent-Session: local session ID 01a0598f-11b9-72d1-91d9-b2fbb186557d
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #507 +/- ##
=======================================
Coverage 61.35% 61.35%
=======================================
Files 16 16
Lines 634 634
=======================================
Hits 389 389
Misses 245 245 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
CI triage: the failed Julia 1.10 all-dependencies downgrade job is an unchanged base-branch failure, not a failure of this pullback change. The current run fails while resolving the minimum dependency set: The normal current-Julia Linux/macOS/Windows Core jobs pass on this PR. I have queued the pre-existing downgrade defect for a separate root-cause investigation so it is not mixed into this focused ChainRules pullback fix. Links:
|
Summary
Project
restructurepullback cotangents into the differentiated source's tangent space instead of the target's. The existing rule fails whenevertargetandsrchave different array shapes, including SciMLSensitivity's mixed GPU/CPU adjoint test with matrix parameters.Root cause
restructure(target, src)returns values fromsrcarranged liketarget. Its pullback reconstructs the output cotangent intosrc's layout, but then appliesProjectTo(target). A flat source and matrix target therefore produce a flat cotangent that the matrix projector rejects.The rule must project with
ProjectTo(src): the third pullback result is the cotangent of the third argument.Failing before
The added ChainRules test uses a
2×2matrix target and length-4 vector source. On cleanmasterat97b9fe8, the full Core group reached the new test and failed:Passing after
The same full group passes with the source projector:
The exact CPU analogue of SciMLSensitivity's failing matrix-parameter
BacksolveAdjoint(autojacvec = ZygoteVJP())path also passes against this checkout and agrees with ForwardDiff:Additional verification
The repository has no QA test group. An additional direct
Aqua.test_all(ArrayInterface)run failed only its stale-dependency check forAdapt. Independent audit showed that this is an extension-awareness false positive: the base load intentionally omitsAdapt, while loadingGPUArraysCoreactivatesArrayInterfaceGPUArraysCoreExt, which imports and uses it. The CUDA job was not run locally because this host has no NVIDIA device. ArrayInterface's existing downstream CI covers SciMLSensitivity Core1–Core5.Links
🤖 Generated with Codex CLI 0.151.0 (model: gpt-5.6-sol; session: local session ID 01a0598f-11b9-72d1-91d9-b2fbb186557d).