Repository navigation
Adopt dense-preserving binary sums and benchmark issue 47 - #181
Merged
Merged
Conversation
Migrate all six binary allocator callers, pin sparsediff_linalg to its dense-sum implementation, and add structural/numerical regressions plus a deterministic before/after profiling target. Leave four-way and n-way sums unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the issue-47 model factory with four small explicit tests, drop the standalone profiling target and the README section, and pin the submodule to the merge commit of sparsediff_linalg#48. Co-Authored-By: Claude Fable 5.2 <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.
Summary
Companion to SparseDifferentiation/sparsediff_linalg#48,
addressing the binary-sum portion of
SparseDifferentiation/sparsediff_linalg#47.
add,multiply,matmul,quad_over_lin, elementwise Hessians, andquad_form.plus the binary dense-sum fix).
binary_sum_profiletarget underPROFILE_ONLY.Four-way/n-way sums and their evaluation order are unchanged.
Dependency / merge order
Review and merge the library PR first. This PR currently pins its published
head commit. If the library PR is squash-merged or rebased, update this submodule
pin to the resulting merged commit before merging this integration.
Validation
Engine and library suites pass in Release, Debug with
SP_TRACK_MEMORY, andASan+UBSan. New tests check dense intermediate kinds and exact nnz, gradients
and Hessians against numerical differentiation at changed inputs, a sparse
control, and composed
matmul,quad_over_lin, andquad_formpaths.Changed C files pass clang-format and whitespace checks.
Performance
Apple M2 arm64, macOS 26.7.3, AppleClang 21.0.0, Release, Accelerate,
VECLIB_MAXIMUM_THREADS=1. Each median uses 21 samples after five warmups.Baseline: engine
1efa7c26with librarya8ee39ff, using the same profile sourceas the patched run (so prior library changes are not counted as this fix).
Gradient timings include root forward and Jacobian evaluation. Hessian timings
include those plus Hessian evaluation. Initialization is separate; legitimate
affine caching remains enabled. Conversions, reference checks, and printing are
outside timed evaluation regions.
sum((Ax)^2)sum((Ax-b)^2)sum(logistic(Ax-b))sum(sqrt((Ax)^2))sum(sqrt(1+(Ax)^2))sum(sqrt((Ax-b)^2))sum(sqrt(1+(Ax-b)^2))Affine workloads use A = 2000 x 400; the two-block model has 800 variables.
Logit uses m=1000, d=20, K=20. Values and gradient/Hessian sums and norms agree
within 1e-9 absolute/relative tolerance; structural counts agree exactly.
The logit Jacobian and final Hessian are dense, but its intermediate n-way
Hessian sum remains sparse and is deferred.
Reproduce
cmake -S . -B build/profile -DCMAKE_BUILD_TYPE=Release -DPROFILE_ONLY=ON cmake --build build/profile --target binary_sum_profile VECLIB_MAXIMUM_THREADS=1 ./build/profile/binary_sum_profileSee README for the baseline setup and OpenBLAS thread setting. The CSV output
also includes initialization times, sample ranges, kinds, nnz, and numerical
summaries. No absolute-time CI assertions are introduced.