Repository navigation
[CMake 6/7] Initialize CVODES adjoint quadrature derivative buffers - #3508
Open
SteveBronder wants to merge 2 commits into
Open
SteveBronder wants to merge 2 commits into
SteveBronder wants to merge 2 commits into
Conversation
This was referenced Nov 4, 2026
SteveBronder
force-pushed
the
fix/cvodes-adjoint-quadrature-output
branch
from
November 5, 2026 14:39
bab8171 to
1c3b5cc
Compare
WardBrian
force-pushed
the
fix/cvodes-adjoint-quadrature-output
branch
from
November 6, 2026 10:47
1c3b5cc to
005153a
Compare
Clear the quadrature derivative output before accumulating adjoints. Cover analytic values and gradients across repeated solves and reverse passes.
WardBrian
force-pushed
the
fix/cvodes-adjoint-quadrature-output
branch
from
November 6, 2026 20:06
005153a to
77455ad
Compare
This branch has not been deployed
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
The adjoint cosine ODE tests fail on Windows x64 with incorrect gradients and on Windows ARM64 with CVodeB error -3 in the CMake CI run. CVODES reuses its quadrature derivative output buffer, but
accumulate_adjointsadds to that buffer with+=, retaining stale or uninitialized values between callbacks.Clear the output before accumulating derivatives. Add an analytic value/gradient regression covering scalar and vector parameters, repeated solves, and repeated reverse passes. This is a solver correctness fix reviewed separately from the CMake infrastructure; existing tolerances stay unchanged.
Tests
MALLOC_PERTURB_).-Wall -Werror; native Windows runtime validation remains for CI.git diff --checkpass.Side Effects
Adjoint quadrature derivatives no longer depend on previous output-buffer contents. Public APIs and solver tolerances are unchanged.
Release notes
Fix incorrect adjoint ODE parameter gradients and intermittent CVODES backward-integration failures caused by stale quadrature output.
Checklist
Related PRs
Native stack: https://github.com/stan-dev/math/stack/3509