Repository navigation
Speed up DDMC.fit: faster responsibility matmuls and cached background PWM - #576
Merged
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.
Follows from profiling
DDMC.fit(context: #566's scalability target).1. Responsibility matmuls.
resp.T @ Xwith tall-skinnyresp(many peptides, few clusters) is very slow under multithreaded OpenBLAS on a 48-core machine: 73 ms vs 7.4 ms for the equal(X.T @ resp).Ton a 6,022 x 1,000 batch. It runs 2-3 times per mini-batch step and in the M step, so a new helper_rtxuses the faster form everywhere. The gain depends on core count and will be smaller on machines with fewer cores.2. Background PWM cache.
Binomial.__init__rebuilt the background PWM from about 360k PhosphoSitePlus sequences on every fit, but it depends only on the pY/pS/pT counts andinclude_ptms. It is now memoized in_cached_background_pwm(BackgroundSeqsis split so the counts can be the cache key), and__init__copies it before mutating.Timings (48-core box, Binomial, k=50 for the synthetic runs):
The first fit in a process still pays the cache-fill cost (about 1.1 s).
Equivalence. I compared
scores_from main and this branch for Binomial and PAM250, with and without PTMs, on complete and 50%-missing CPTAC data. The maximum difference was about 1.5e-11 (floating-point reordering). Ruff, ty and pytest (98 passed) are clean.Not addressed here: the
ufunc.atscatter-adds and centroid initialization (5-9 s at scale).