Repository navigation
Handle raw Array cotangents into FlatComponentArray fdata - #421
Merged
ChrisRackauckas merged 2 commits intoSep 11, 2026
Merged
ChrisRackauckas merged 2 commits into
ChrisRackauckas merged 2 commits into
Conversation
increment_and_get_rdata! only had a method for a cotangent matching fdata's own FlatComponentArray type. A ChainRulesCore rrule unaware of ComponentArrays (e.g. SciMLSensitivity's InterpolatingAdjoint / BacksolveAdjoint) instead returns a bare Array cotangent for a ComponentVector/ComponentMatrix parameter, which had no matching method and fell through to the generic error.
AstitvaAggarwal
marked this pull request as draft
September 10, 2026 17:12
Array cotangents into FlatComponentArray fdata
…e-mismatch tests increment_and_get_rdata! for a bare Array cotangent left N unconstrained, so a dimensionality mismatch (e.g. a Vector cotangent for a ComponentMatrix fdata) could dispatch and silently broadcast against the wrong shape instead of erroring. N is now pinned to match between fdata and cotangent. Also adds a genuine ComponentMatrix (N=2) regression test -- the earlier test only exercised ComponentVector, since ComponentArray(a=<matrix>, ...) actually produces a ComponentVector with matrix-shaped fields, not a real ComponentMatrix -- and a test confirming a shape mismatch now errors instead of silently computing a wrong gradient.
AstitvaAggarwal
marked this pull request as ready for review
September 10, 2026 18:04
AstitvaAggarwal
marked this pull request as draft
September 10, 2026 18:06
ChrisRackauckas
marked this pull request as ready for review
September 11, 2026 15:34
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 11, 2026
- Add 32-bit Core CI lane via test_groups.toml (#415) - Make 32-bit Core lane non-blocking (BFloat16s LLVM) (#416) - Keep 32-bit Core lane hard-failing. (#418) - Drop Tracker from Core tests; keep it in Autodiff (#419) - Fix Core i686 tests: BLAS axpby ULP and Int width (#420) - Handle raw `Array` cotangents into `FlatComponentArray` `fdata` (#421) - Add AirspeedVelocity benchmarking CI (#422) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
Summary
increment_and_get_rdata!only had a method for a cotangent matching fdata's ownFlatComponentArraytype. AChainRulesCorerrule unaware of ComponentArrays returns a bareArraycotangent instead — this had no matching method and fell through to Mooncake's generic error:Hit in practice via SciMLSensitivity's
InterpolatingAdjoint/BacksolveAdjoint(SciML/SciMLSensitivity.jl#1427), whose pullback returns a plain gradient vector for aComponentVectorparameter.GaussAdjoint/QuadratureAdjointdon't hit this since their pullback already returns a compatible cotangent shape.Adds one
increment_and_get_rdata!method mirroring the existing raw-Array case for the old FData shape, generalized to the new nativeFlatComponentArrayfdata.Nis pinned to match between fdata and cotangent, so a dimensionality mismatch (e.g. aVectorcotangent for aComponentMatrixfdata) fails to dispatch and errors loudly instead of silently broadcasting against the wrong shape.Verified against ForwardDiff for a real neural-ODE gradient across
GaussAdjoint/InterpolatingAdjoint/QuadratureAdjoint/BacksolveAdjoint(all four now agree to ~1e-8 relative error), and separately confirmed (viais_primitiveplus a deliberately-wrong pullback value) that a genuineComponentMatrix(N=2, constructed withComponentMatrix(data, Axis(...), Axis(...))) hits this exact code path and computes the correct gradient.Test plan
Array-cotangent@from_rruleround-trip forComponentVectorComponentMatrix(N=2), confirmed viais_primitivethat it actually exercises this method (not silently bypassed by native differentiation)InterpolatingAdjoint/BacksolveAdjoint) vs ForwardDiff ground truth