Skip to content

Replace Coloring by SparseMatrixColoring - #102

Merged
blegat merged 14 commits into
mainfrom
bl/smc
Oct 16, 2026
Merged

blegat merged 14 commits into
mainfrom
bl/smc

Conversation

@blegat

@blegat blegat commented Oct 16, 2026

Copy link
Copy Markdown
Owner

This is changing behavior compared to MOI.Nonlinear.ReverseAD because we are not forcing all diagonal entries to be nonzero.
As discussed in jump-dev/MathOptInterface.jl#2527, MOI fill in the diagonal entry but SMC allows to not do that.

blegat and others added 12 commits October 16, 2026 09:16
- Remove leftover `display(S)` debug statement in coloring.jl
- Add missing `Int[]` for `hess_J` field in `_FunctionStorage` else branch

https://claude.ai/code/session_01WBu9hZukriWDSSybN9gfBq
- Build lower triangular sparsity pattern (row >= col) instead of full
  symmetric matrix, so decompress_csc! with :L works correctly
- Always add diagonal entries explicitly (old Coloring module did this
  implicitly; SMC requires them to be in the sparsity pattern)
- Get CSC structure directly from the sparse matrix instead of going
  through compress/decompress
- Switch decompress_csc! from :U to :L to match lower triangular storage
- Update test expectations to CSC lower triangular order:
  J=[1,1,2] (was [1,2,1]), V=[3.4,2.1,1.3] (was [3.4,1.3,2.1])

https://claude.ai/code/session_01WBu9hZukriWDSSybN9gfBq
The SMC-based Hessian recovery stores nonzeros in lower triangular CSC
format (column-major: all entries of column j before column j+1, with
diagonal first in each column). Update all multivariate Hessian structure
and value expectations to match this ordering instead of the old
diagonal-first ordering.

https://claude.ai/code/session_01WBu9hZukriWDSSybN9gfBq
…ad of Base.promote_op

Base.promote_op may return Any for SMC.coloring since it lacks an explicit return
type annotation, causing TypeError when constructing _FunctionStorage{Any} because
Any <: AbstractColoringResult is false. Use a small test coloring call instead.

https://claude.ai/code/session_01WBu9hZukriWDSSybN9gfBq
…or_preprocess

The function was returning I/J in local variable indices but callers use
them as global variable indices (for hessian_lagrangian_structure). This
caused wrong sparsity patterns when a function depends on non-contiguous
variables (e.g., variables 4 and 5 out of 5 total).

https://claude.ai/code/session_01WBu9hZukriWDSSybN9gfBq
… coloring

Pass a full symmetric sparsity pattern to SMC.coloring instead of lower
triangular, so the tree edges are correctly oriented. Store full_colptr,
lower_pos, and full_buffer in ColoringResult to allow recovery via
decompress_csc! with :F, then extract lower-triangular values.

This fixes: BoundsError: attempt to access 0-element Vector{Int64} at index [1]
in test_coloring_end_to_end_hessian_coloring_and_recovery.

https://claude.ai/code/session_01WBu9hZukriWDSSybN9gfBq
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.78%. Comparing base (54de044) to head (a43abaf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #102      +/-   ##
==========================================
- Coverage   92.61%   91.78%   -0.84%     
==========================================
  Files          25       24       -1     
  Lines        3210     2885     -325     
==========================================
- Hits         2973     2648     -325     
  Misses        237      237              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants