Simplify Python RPCA: remove dead code, fix numba structure, vectorize hot loop#1
Open
mazenahmad wants to merge 3 commits into
Open
Simplify Python RPCA: remove dead code, fix numba structure, vectorize hot loop#1mazenahmad wants to merge 3 commits into
mazenahmad wants to merge 3 commits into
Conversation
…e hot loop - Move GPA accumulation kernel to a module-level @njit function instead of @jit on an instance method (numba cannot compile self); drop the ProcessPoolExecutor + wrapper + chunking machinery it required and let numba handle per-frame parallelism. Compute the reference mean once instead of every frame, and preallocate the coords array. - Delete dead helpers _calculate_rotation_matrix and _project_coordinates. - Collapse the O(n_res^2 * atoms^2) interaction-matrix loop into per-residue group vectors (G_i . G_j) for identical results in O(n_res^2). - Drop unused imports (align, cdist, ThreadPoolExecutor, multiprocessing, numba float64/int64) and no-op per-method OMP_NUM_THREADS env writes. - Replace the broken per-frame time scan in read_trajectory with a materialized times array + np.searchsorted. - Remove the invalid n_jobs kwarg passed to AnalysisBase and use zero-arg super() in the nested FastCovarianceAnalysis class. https://claude.ai/code/session_018SSc1GoJMfc7Ey8n9EKgrK
…ACS/MDA Proof-of-concept Python package that reuses the project's original C numerical core for relative PCA without any GROMACS or MDAnalysis dependency. - rpca_api.c/.h: thin buffer-in/buffer-out C entry point that calls Simultaneous_Diagonalization() from src/linear_algebra.c and adds the relative-PCA KL scoring/ordering glue. - _sdiag.pyx: zero-copy, nogil Cython binding exposing sdiag() on numpy arrays; returns geigval/gevec/kl/kl_m/acc_kl/rank. - setup.py links the package's C API against ../src/linear_algebra.c (single source of truth) and LAPACK/BLAS only. - Tests validate the defining property (G^T A G = I, G^T B G = diag), the KL formula and ordering, and cross-check eigenvalues against scipy.linalg.eigh. The built extension links only openblas/libm/libc/ libgfortran - verified no gromacs/mdanalysis. https://claude.ai/code/session_018SSc1GoJMfc7Ey8n9EKgrK
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.
@jit on an instance method (numba cannot compile self); drop the
ProcessPoolExecutor + wrapper + chunking machinery it required and let
numba handle per-frame parallelism. Compute the reference mean once
instead of every frame, and preallocate the coords array.
group vectors (G_i . G_j) for identical results in O(n_res^2).
numba float64/int64) and no-op per-method OMP_NUM_THREADS env writes.
materialized times array + np.searchsorted.
super() in the nested FastCovarianceAnalysis class.
https://claude.ai/code/session_018SSc1GoJMfc7Ey8n9EKgrK