Repository navigation
Fix abPOA's cg_backtrack crash with large trained scores; divide trained models by their common factor - #2040
Merged
Merged
Conversation
The HPRC oct9 CHM13 build died 9/9 in cactus_consolidated(chr2) with "Error in cg_backtrack": chr2's last-train model learned a gap extension of 2, which the 30x scaling for the long-gap piece turned into -O 1290,3870 -E 60,2, and abPOA's choice of a 16-bit DP did not account for the "minus infinity" it then used (+1824 for those scores). Windows that did not abort could be misaligned silently. abPOA is bumped to 12f99c4 (ComparativeGenomicsToolkit/abPOA#14), which picks the 16/32-bit width from bounds on the scores, checks every alignment whose width it cannot prove safe, redoes a failed 16-bit alignment at 32 bits, and stops with a message naming the scores only if a 32-bit check fails. Wherever 36110ac was right its MSAs are unchanged, and with cactus's AVX2 build the DP runs at 0.997 of 36110ac's cycles. last_scoring: - apply_long_gap() divides the scaled model by the gcd of its scores (reduce_scores), which leaves every alignment and tie as it was: the chr2 model becomes 645,30,1935,1 with its matrix halved, and models with an extension of 1 are untouched. This is logged at info. - parse_train_file() rejects a model with an extension below 1, a negative open, or a match score of 0 or less, so training falls back as when it fails. - A warning is logged when a model is so large that abPOA could not prove a full window's 32-bit alignment exact (abpoa_exact_depth, which mirrors abPOA's rule). - The "Overriding abPOA scores" line keeps its prefix and now ends with the chromosome, the learned gap extension, the factor every score was multiplied by and the common factor divided out. pafTest.py now runs in make test: it imports from cactus.paf.paf, so pytest can collect it, and is in testModules. test_get_leaf_event_pairs had been failing since get_leaf_event_pairs() became get_event_pairs() and now checks the same pairs through the current function. Tests: LastScoringTest in pafTest.py (reduction exact for extensions 1-8, config attributes, log levels, exact depth, rejection); test_trained_scores_beyond_16_bits in poaBarTest.c, where the chr2 model must give the same MSAs as the model halved (36110ac aborts in it). cactus_consolidated on yeast chrI and chrIV gives byte-identical c2h, fasta and ref to 36110ac with the default scores, a trained model and the chr2 model halved, and with the chr2 model itself equals the halved model where 36110ac dies in cg_backtrack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013YWGkqE3ND862JF8QRZERV
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.
Fixes the crash that stopped the oct9 CHM13 HPRC build:
cactus_consolidated(chr2)died 9 times out of 9 with abPOA'sError in cg_backtrack. chr2's last-train model was the only one of the 25 to learn a gap extension of 2, and the ×30 scaling for the long-gap piece turned it intoGapOpen 1290; GapExtend 60; GapOpen2 3870; GapExtend2 2. abPOA's 16-bit gate did not account for the 512·max(gap extension) margin of its "minus infinity" floor, which came out at +1824, above real scores. Windows that did not abort could be misaligned silently. The learned extension sat just over a rounding edge (1.515 against 1.5), and other models are close to it (1.43), so this can happen again.This bumps abPOA to a version that picks its score width from bounds on the scores (ComparativeGenomicsToolkit/abPOA#14). It also makes trained models smaller without changing them.
What changes:
apply_long_gap()now divides the scaled model by the greatest common divisor of all its scores (reduce_scores()).645, 30, 1935, 1with its matrix halved. A learned extension of 1, as every other model so far has, is left alone.parse_train_file()rejects a model with a gap extension below 1, a negative gap open, or any match score of 0 or less.last_train()the alignment then falls back to the defaults, or to a borrowed model, as when training fails.--scoresFilemodel with these problems is now an error.abpoa_exact_depth()mirrors abPOA's rule for when a 32-bit alignment is proven exact. If a model only allows a window-long sequence (partialOrderAlignmentWindow, 10 kb) to be proven exact on graphs less than 50 windows deep, a warning names the model.Overriding abPOA scores with trained values: …keeps its prefix, which logs are grepped for. It now ends, for example, with(chr2: learned gap extension 2; all scores multiplied by 30, then divided by their common factor 2).cactus_alignpasses the chromosome name in.pafTest.pynow runs in CI:cactus.paf.paf, so pytest can collect it.testModules, somake testruns it (GitLabtest-job).test_get_leaf_event_pairs, broken since 2022, is updated toget_event_pairs().apply_scores_to_config()now gives the actual factor defaults (3 for the open, 30 for the extension), and there is aReleaseNotes.mdentry.Results:
cactus_consolidatedon the captured yeast chrI and chrIV inputs (single-threaded; the old abPOA is 36110ac):-O 400,1200 -E 30,1)-O 1410,4230 -E 30,1)-O 645,1935 -E 30,1)-O 1290,3870 -E 60,2)Error in cg_backtrack; new: same as halved"Identical" means byte-identical c2h, fasta and ref output. Peak memory is the same.
Tests:
test_trained_scores_beyond_16_bitsinbar/tests/poaBarTest.c: 200 random windows aligned with the chr2 model must give the same MSA as with every score halved.cactus_barTestspasses 22/22. Linked against 36110ac, it aborts in this test withError in cg_backtrack.LastScoringTestinsrc/cactus/paf/pafTest.pychecks:645, 30, 1935, 1;make paf/pafTest.py_runtestpasses 12/12.🤖 Generated with Claude Code
https://claude.ai/code/session_013YWGkqE3ND862JF8QRZERV