Repository navigation
Conversation
Count each target's best diagonal in cache-sized target blocks: posting lists are walked once with one cursor per expanded query code, a dense (targets x diagonals) histogram is stamped per block instead of cleared, and postings are packed as (target << pbits) | position in one uint32, halving the index. The top-N candidates are taken with argpartition on a unique (-score, target) key. Counts, candidates and scores are identical to the counting-sort kernel, which remains the fallback for very large databases and queries of 65,535+ tokens.
Align up to eight length-sorted candidates at once with the same float32 recurrence and tie rules as smith_waterman_traceback; padding cells can never beat a lane's best cell, so scores, end cells and paths are unchanged. Each batch's traceback pointers stay within 32 MiB (long chains get fewer lanes, down to one), inputs other than a float32 matrix and float32 gap penalties are scored pair by pair, and TM_a skips the block seed when the block is the whole alignment. Results equal score_pair bit for bit.
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.
Summary
Speeds up
Searcher.search(defaulttm_arerank) by about 2.2–2.3× without changing any result: candidates, prefilter scores, SW scores, TM_a, structure scores, aligned-pair counts and ranks are identical tomainbit for bit. No algorithm parameter, index file format or public signature changes.rfoldsearch/prefilter.py): best-diagonal counts are accumulated in cache-sized target blocks, using one cursor per expanded query code. Each block uses a dense histogram that is stamped rather than cleared. Postings are packed as(target << pbits) | positionin one uint32, which halves the in-memory posting arrays. The top-N candidates are selected withargpartitionon a unique(-score, target)key. The counting-sort kernel is kept as the fallback for very large databases and for queries of 65,535 or more tokens.rfoldsearch/structure_score.py): up to 8 length-sorted candidates are aligned at once, using the same float32 recurrence and tie rules assmith_waterman_traceback. Padding cells can never beat a lane's best cell, so scores, end cells and paths are unchanged. Each batch's traceback pointers stay within 32 MiB, so long chains get fewer lanes, down to one. Inputs other than a float32 matrix with float32 gap penalties are scored pair by pair. TM_a skips the block seed when the block covers the whole alignment, because it would repeat the first refinement exactly.Verification
score_pairbitwise under three batching regimes, serial and parallel;mainfound 0 differences in all of these:main, digests hashed on float bit patterns:These timings come from a heavily loaded laptop, so the ratios are meaningful but the absolute times are not.
Notes
NUMBA_THREADING_LAYER=workqueueon macOS. Without it, Numba's OpenMP layer clashes with torch's libomp and crashes. This happens onmainas well.main.