Add torch option for linalg for NMA and transform#2208
Draft
jamesmkrieger wants to merge 6 commits into
Draft
Conversation
jamesmkrieger
marked this pull request as draft
January 22, 2026 13:41
Contributor
Author
|
This isn't ready yet. Ensemble superpose method failed because I didn't convert to tensor before svd, just like superpose function |
importLA was preferring torch.linalg (from 'try torch linalg'), which silently broke PCA/NMA
in any torch environment: solveEig's non-scipy branch returns the FULL ascending spectrum but
never applied the eigvals index subset, so callers sliced the smallest modes -> calcModes gave
0 modes; performSVD passed a numpy array to torch.linalg.svd -> TypeError.
Fixes:
- importLA prefers scipy > numpy > torch (torch last); add setLinalgBackend/getLinalgBackend to
force a backend ('torch' selects the experimental GPU path, uses CUDA when available).
- solveEig _eigh: numpy/torch branch now applies the eigvals index range (mirrors scipy
subset_by_index) so downstream selects the intended modes; torch runs on CUDA when available.
- performSVD: convert deviations to a (CUDA) tensor for the torch backend and back.
Verified: scipy/numpy/torch backends all return identical, correct eigenvalues for calcModes
and performSVD.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jamesmkrieger
requested review from
karolamik13
and removed request for
AnthonyBogetti
July 21, 2026 18:22
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.
We may want to not make it default because it's not actually faster, but here's a start