Repository navigation
quad_over_lin: form the composition Jacobian through the dispatchers - #151
Merged
Merged
Conversation
For an affine child x = f(u) the Jacobian row is (2 f(u)/y)^T J_f plus one entry, -value/y, at y's column. It was built with count_nonzero_cols, insert_idx and yTA_fill_values on the engine's CSC mirror of J_f, with a hand-maintained version stamp. Form it like quad_form instead: d = 2 f(u)/y held as an n x 1 permuted_dense is the dispatcher's transposed operand, so BTA_matrices_* gives d^T J_f with the column pattern derived from J_f, a one-entry sparse row carries the y derivative, and sum_matrices_* combines them into the node's Jacobian. A new quad_over_lin_expr holds the three handles. The leaf case and the Hessian are unchanged. The branch now calls jacobian_init / eval_jacobian on the child (no-ops for a linear operator with a preset Jacobian), so any affine child works. Co-Authored-By: Claude Fable 5.1 <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.
For an affine child
x = f(u)the Jacobian row is(2 f(u)/y)^T J_fplus one entry,-value/y, at y's column. It was built withcount_nonzero_cols,insert_idxandyTA_fill_valueson the engine's CSC mirror ofJ_f, with a hand-maintained version stamp.This forms it the way quad_form does:
d = 2 f(u)/yheld as an n x 1permuted_denseis the dispatcher's transposed operand, soBTA_matrices_*(J_f, d)givesd^T J_fwith the column pattern derived fromJ_fwhatever its kind; a one-entry sparse row carries the y derivative;sum_matrices_*combines them into the node's Jacobian. A newquad_over_lin_exprholds the three handles. The leaf case and the Hessian are unchanged.Two side effects: the fill is linear in
nnz(J_f)whereyTA_fill_valuessearched the output row per column, and the branch now callsjacobian_init/eval_jacobianon the child (no-ops for anew_linearchild with a preset Jacobian), so any affine child works, not only a linear operator.After this,
yTA_fill_values,count_nonzero_colsandinsert_idxhave no engine caller (library PR moving them totests/legacyfollows), and matmul.c is the last user of the engine's CSC mirror.Verified locally: Release, Debug and UBSan builds, 293 engine tests pass, guard-malloc +
leaks --atExitclean, clang-format clean.🤖 Generated with Claude Code