Speed up template similarity with pair-level parallelism - #4785
Open
JESUSROYETH wants to merge 1 commit into
Open
JESUSROYETH wants to merge 1 commit into
JESUSROYETH wants to merge 1 commit into
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.
Template similarity currently parallelizes over source rows. A common soft merge compares one new template with hundreds of targets, but exposes only one parallel task.
This flattens connected
(source, target, active_channels)pairs into typed lists and runsprangeover them. For a square matrix, rowihasN - ipairs, so pair-level scheduling also balances work better than complete rows. Support selection, cosine/L1/L2 arithmetic, lag symmetry and disconnected-pair behavior stay unchanged.I ran five paired fresh-process workflows after one warm-up on a GCP
c3-standard-8(Xeon Platinum 8481C, 8 vCPUs), with 256 units, 384 channels and 20 public soft merges.The complete workflow includes imports, analyzer setup, template calculation and JIT compilation. Every paired run improved by 26.3-28.4% and returned the same checksum.
On the public 10-second MEARec fixture, five warmed soft merges went from 6.17 ms to 2.42 ms, with exactly equal complete matrices. A separate 300-case sweep matched NumPy across all metrics and support modes, sparsity and varied shifts. The complete template-similarity module has 19 passing tests, the dense/sparse extension merge test has 2 passing cases, and Black is clean.
Related to #4310.