Replace block-aligner with a custom SIMD aligner#612
Closed
NicolasBuchin wants to merge 1 commit into
Closed
Conversation
NicolasBuchin
marked this pull request as draft
July 18, 2026 13:51
The piecewise path used block-aligner for the global alignments between anchors and for the x-drop extensions off the first and last anchor. Both now go to src/simdaligner, an AVX2 kernel on a difference recurrence, and the block-aligner dependency is dropped. Runtime is lower and the extensions off the ends of the chain are more accurate. x-drop is not needed any more, so `--xdrop` is removed. The new `--bw` sets the bandwidth. Note the new aligner is x86_64-only, where block-aligner also had NEON and wasm backends. Is-new-baseline: yes
NicolasBuchin
force-pushed
the
sim-aligner
branch
from
July 18, 2026 15:02
1e8da14 to
3d6b1cb
Compare
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.
Replace block-aligner with a custom SIMD aligner
The piecewise path used block-aligner for the global alignments between anchors and for the x-drop extensions off the first and last anchor. Both now go to
src/simdaligner, and the block-aligner dependency is dropped.The kernel does affine-gap alignment on the difference recurrence of Suzuki & Kasahara (BMC Bioinformatics, 2018). Storing adjacent-cell differences bounds every value by the scoring scheme alone, with no length term, so 8-bit lanes hold at any sequence length. That gives 32 lanes per AVX2 vector with no widening path and no overflow-and-restart.
SimdAligner::newrejects schemes that would violate the bound rather than wrap a lane. Note that there is one kernel and no scalar fallback.Between anchors it is called unbanded, i.e. exact: optimal score under the scheme, no x-drop, no early exit. block-aligner capped its block size, so long anchor gaps could fall back to a heuristic result. Now we guarantee exactness. We also guarantee that among equally scoring alignments the CIGAR returned is the one minimising the edit distance, and it is the exact CIGAR representation strobealign already uses, so there is no translation left and no wrappers in the piecewise aligner.
Off the ends of the chain, x-drop is removed. Instead we use a bandwidth heuristic: extensions against a longer reference are confined to
wdiagonals off the anchor diagonal, and shorter ones are exact. Within the bandwidth the result is optimal.--xdropis removed and--bw <N>is added, defaulting to 1024 bandwidth. Note that x-drop also went through a block-length heuristic, so it was never exact either.Results are in ends.pdf and ends-se-accuracy-table.pdf: single-end
align, fruitfly/maize/chrY/CHM13 crossed with sim0/sim4/sim6, 50–30000 bp. Runtime is lower throughout, with the gap widening past ~500 bp and widest on sim6 and chrY. Accuracy is practically unchanged below 15 kb and improves a bit from 25 to 30 kb. On short reads the runtime difference is harder to resolve end to end, since this was run on my laptop, so I also benchmarked the alignment calls directly against block-aligner across a range of sizes: over a corpus of ~1M real between-anchor calls the SIMD kernel is 3.4x faster overall and faster in every size bucket including the smallest, with identical scores.One caveat: the new aligner is x86_64 and AVX2 only (
SimdAligner::is_supportedto check,newpanics otherwise), and the piecewise aligner imports it unconditionally, so as it stands the crate does not build on aarch64 at all, I need to add arm64 support.One last mention: the new aligner also comes with a new alignment type, split reference alignment. Not yet in use, but it will probably be needed for duplication detection.
Todo: