Skip to content

Faster prefilter and alignment stage, bit-identical to 1.0.0 - #46

Merged
DylanYang merged 2 commits into
mainfrom
grouped-prefilter
Nov 20, 2026
Merged

DylanYang merged 2 commits into
mainfrom
grouped-prefilter

Conversation

@DylanYang

Copy link
Copy Markdown
Owner

Code-only speed-ups. No change to the algorithm, parameters (top_n 500), scores or rankings.

Prefilter (4d19b49): query positions are grouped by 4-mer code, so each posting list is read once per distinct code instead of once per query position. Helical homopolymer 4-mers recur at many positions and have the longest lists (up to 1.59M postings), so this removes most index reads. Output is identical to the released kernel.

SW traceback + TM_a (cc771cf):

  • SW: flat uninitialised pointer matrix (row/column 0 are never read), H rows swapped instead of copied and zeroed, substitution row hoisted. Recurrences, comparison order and tie rules unchanged.
  • TM_a: the block-seed refinement stops once its selection repeats a step of the all-pairs run at the same or an earlier step, since the rest cannot raise the maximum. Gapless alignments (about 70%) skip it entirely.

Verification

  • New tests/structure_score_v100.py freezes the 1.0.0 module; tests/test_structure_score_equivalence.py checks SW, TM_a and score_candidates against it bit for bit. Added a repeated-code prefilter test.
  • Full suite: 124 passed, 2 skipped.
  • NuFold v914, 100 queries x 500 candidates: 0/50,000 mismatches in (S_SW, TM_a, aligned).

Speed (single core)

  • 2080, NuFold v914: prefilter 1.92x, SW+TM_a stage 1.09x.
  • AutoDL 8470Q, prefilter change only, full DB mean: RhoFold+ 83,156 1.032 -> 0.611 s; NuFold 531,888 0.479 -> 0.339 s.

Query positions are grouped by 4-mer code, so a code that recurs in the
query (helical homopolymer 4-mers, which also have the longest posting
lists) is scanned once instead of once per position. Output is identical
to the released kernel; test added for repeated codes.

NuFold v914, top_n 500, single core: prefilter 1.92x, search 1.58x faster.
SW traceback: flat uninitialised pointer matrix (row/column 0 are never
read), H rows swapped instead of copied and zeroed, substitution row
hoisted. Recurrences, comparison order and tie rules are unchanged.

TM_a: the block-seed refinement stops once its selection repeats a step
of the all-pairs run at the same or an earlier step; the rest of that run
cannot raise the maximum. Gapless alignments (block = every pair) skip it
entirely.

tests/structure_score_v100.py freezes the 1.0.0 module as the reference
for the new bitwise equivalence tests. NuFold v914, 50,000 query-candidate
pairs: 0 mismatches, SW+TM_a stage 1.09x faster.
@DylanYang
DylanYang merged commit 8097ae1 into main Nov 20, 2026
2 checks passed
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