Repository navigation
fix: validate reused coordinate decompositions by pursuit algorithm - #1932
Merged
jlarson4 merged 1 commit intoOct 22, 2026
Merged
Conversation
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.
Description
Coordinate patching rejects valid
gradient_pursuitdecompositions when they are supplied explicitly or reused through the per-position/cache path. Its compatibility validator currently applies NNLS KKT stationarity to both supported algorithms, although gradient pursuit deliberately performs approximate projected-gradient updates.For example, with dictionary rows
[[1, 0, 0], [0.7, 0.7, 0], [0, 0, 1]], activation[1, 0.3, 0], andk=2, a fresh gradient-pursuit patch from atom 0 to atom 2 returns[0, 0.3, 1]. Passing its own decomposition back into the solver instead raisesNNLS result violates stationarity on positive coordinates.solve_coordinate_patch_positions()encounters the same error even on its first call because it passes the freshly computed decomposition through the reuse validator.This change validates gradient-pursuit coordinates by replaying the coefficient updates over the recorded selected atoms, including the solver's final active-support pruning. It avoids a vocabulary-wide selection scan on reuse. The existing NNLS KKT validation and shared activation/dictionary/reconstruction checks remain in place, so self-consistently rescaled coordinates and stale activations are still rejected.
The existing
algorithmargument now selects the validation rule for supplied/cached decompositions as well as the fresh solver; its docstrings state that it must match the decomposition's producer. No decomposition fields or public signatures change.Type of change
Validation
The regression coverage includes correlated atoms, explicit reuse, per-position calls, cache misses/hits, both coefficient-update algorithms, activation scales, invalid coordinates, empty supports, unknown algorithms, and hook/offline parity through
JacobianLens.mypy .: 389 source files passed.git diff --check: passed.The complete unit suite and GPU/MPS tests were not run.
Checklist