Repository navigation
fix: preserve selected J-space directions across atom scales - #1942
Merged
jlarson4 merged 1 commit intoOct 23, 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
The float32 default
torch.linalg.pinvrank cutoff in sparse J-space projections depends on the ambient dimension and raw atom scales. It can discard a genuinely independent selected direction even when the normalized atoms are orthogonal.A model-free example uses two orthogonal atoms with norms 1 and 3000 and a target with coordinates
[2, 1]in 4096 dimensions. NNLS selects both atoms and reconstructs[2, 1], but the reported J-space component is[0, 1]. Its supposedly orthogonal residual still has a dot product of 2 with the first atom. Occupancy reports gains[0.8, -0.6]instead of[0.8, 0.2]. The same problem in a low-dimensional space, or with unit-norm atoms, works correctly.This change shares one selected-span projection between decomposition, occupancy and precomputed coordinate-patch validation. It normalizes atom columns and uses a float64 SVD with an explicit
sqrt(eps64)relative rank tolerance. Numerical rank no longer depends on zero-padding the ambient dimension or rescaling an atom. Exactly dependent and numerically indistinguishable directions are removed under the documented tolerance. Output dtype/device are preserved, using the existing CPU fallback for MPS linear algebra.This does not change pursuit selection, NNLS coefficient fitting or the public API. It corrects the selected-span projection and its reuse validation. The reproductions establish the mathematical failure; its prevalence in pretrained lens dictionaries has not been measured.
Type of change
Validation
Regression coverage includes orthogonal reconstruction/projection identity, residual orthogonality, occupancy gains, atom-rescaling and zero-padding invariance, explicit near-dependency behavior, redundant/empty spans, valid/invalid precomputed projections, and the public
JacobianLens.fraction_of_variancepath.git diff --check: passed.mypy .: 389 source files passed.The complete unit suite and GPU/MPS hardware checks were not run.
Checklist