[WIP] values_version cache coherence for Jacobian/Hessian value caches - #113
Open
dance858 wants to merge 1 commit into
Open
[WIP] values_version cache coherence for Jacobian/Hessian value caches#113dance858 wants to merge 1 commit into
dance858 wants to merge 1 commit into
Conversation
Replace the caller-must-refresh temporal contracts and the per-atom jacobian_csc_filled flags with a monotone values_version counter on matrix: writers bump, consumers refresh iff their recorded version differs. Staleness becomes impossible by construction and shared-operand double-refreshes dedupe for free. - eval_jacobian/eval_wsum_hess free-function wrappers run the atom impl (slots renamed *_impl) and bump the output's version; the jacobian wrapper skips the bump for an affine node already evaluated this parameter epoch, preserving today's refresh counts. - sparse_matrix csc_cache and stacked_pd csr_cache are version-guarded (the latter skips its per-call block memcpy in to_csr). - spd vtable fill adapters and the raw hess_term2 write sites bump their outputs so version-guarded reads stay fresh. - expr_set_needs_refresh gains a set_needs_refresh_children hook so the parameter-refresh walk reaches hstack's args[] children; without it a parameter-dependent affine child under hstack/vstack served stale spd Jacobian values after a parameter update (also fixes the pre-existing stale-CSC-mirror bug for args[] children on main). - new tests lock the semantics: bump-per-eval, affine bump-skip and re-arm, CSC mirror dedup, spd to_csr freshness, spd hess-term staleness regression, and the hstack parameter-refresh regression. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Claude:
Replace the caller-must-refresh temporal contracts and the per-atom jacobian_csc_filled flags with a monotone values_version counter on matrix: writers bump, consumers refresh iff their recorded version differs. Staleness becomes impossible by construction and shared-operand double-refreshes dedupe for free.