Skip to content

Add torch option for linalg for NMA and transform#2208

Draft
jamesmkrieger wants to merge 6 commits into
prody:mainfrom
jamesmkrieger:jmk_torch
Draft

Add torch option for linalg for NMA and transform#2208
jamesmkrieger wants to merge 6 commits into
prody:mainfrom
jamesmkrieger:jmk_torch

Conversation

@jamesmkrieger

Copy link
Copy Markdown
Contributor

We may want to not make it default because it's not actually faster, but here's a start

@jamesmkrieger
jamesmkrieger marked this pull request as draft January 22, 2026 13:41
@jamesmkrieger

Copy link
Copy Markdown
Contributor Author

This isn't ready yet. Ensemble superpose method failed because I didn't convert to tensor before svd, just like superpose function

jamesmkrieger and others added 2 commits January 22, 2026 14:07
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
jamesmkrieger requested review from karolamik13 and removed request for AnthonyBogetti July 21, 2026 18:22
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.

1 participant