Repository navigation
perf: exact-mass candidate lookup, prediction memo, parallel setup, edge-score skip - #105
Conversation
The in-RAM path walked every candidate in about four nominal-mass buckets per spectrum and ran matches_precursor on each; only ~16% pass. Candidates are now kept in an exact-mass order and binary-searched per (charge, isotope offset) with the same arithmetic as matches_precursor, then sorted by index so iteration order is unchanged. Candidates that fail the precursor check had no side effects, so this only skips work. It also visits candidates the nominal window missed. A candidate's key is round(0.9995 x mass); near a rounding boundary the observed mass and an accepted candidate (more often at isotope offsets) fall into different integers beyond the window's slack. On a 120-spectrum Lumos file against human SwissProt, 20 more PIN rows appear (1,390 -> 1,410), all valid precursor matches, mostly 4-5 kDa Cys/Met-rich peptides. The low-res fixture's PIN is byte-identical. Local x86 build under Rosetta, human SwissProt, 8 threads: low-res 34.8 -> 29.1 s, high-res 25.2 -> 22.7 s (whole process).
The 19 fragment features describe the ion and peptide, never the spectrum, so the same rows are predicted again and again across candidates and spectra. predict_frag_intensities now keeps a per-thread map from the row's bits to the raw GBDT value, keyed to the model by its tree storage and capped at 2^17 rows per thread (cleared when full). Misses still go through predict_value_batch together; a row's value does not depend on the rest of the batch, so output is bit-identical. Local x86 build under Rosetta, human SwissProt, 8 threads, both PINs byte-identical to the previous commit: low-res 29.1 -> 22.0 s, high-res 22.7 -> 16.0 s.
…llel Setup was serial: enumeration ~5 s and collision-decoy relabelling ~6 s on human SwissProt (7.6M candidates), at any thread count, on every file a pipeline searches. Enumeration now runs one protein per rayon task; the ordered collect keeps the (protein, offset, mod combination) order. Relabelling hashes each bare sequence once, keeps exact copies only of targets whose hash a decoy shares, and confirms decoys against those, instead of boxing every target sequence into one set. Labels are exactly as before. Both fixture PINs are byte-identical. Setup on the local x86 build under Rosetta: ~8-10 s -> ~4 s.
ScoredSpectrum::edge_score returns 0 for every edge when the model has no mass-error distribution or ion-existence table, which is every low-res model. psm_edge_score still built per-residue prefix arrays for every precursor-matched candidate, and the two-stage gate used a bound of 10 per residue, so it never pruned. psm_edge_score now returns 0 up front in that case, and the gate uses a bound of 0 with a tie-inclusive comparison (the queue keeps ties). Models that do score edges take the unchanged path. Both fixture PINs are byte-identical.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (5)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Benchmark VM results (8-thread Xeon Gold 6238, Percolator 3.7.1
|
| dataset | main wall |
this PR wall | change | scoring phase (match_spectra) |
PSMs @ q≤0.01 |
|---|---|---|---|---|---|
| Astral | 284 / 274 s | 205 / 198 s | −28% | 217 / 214 → 159 / 153 s | 38,394 = 38,394 |
| TMT a05058 | 101 / 93 s | 67 / 65 s | −32% | 52.7 / 51.8 → 37.9 / 36.7 s | 12,281 = 12,281 |
| UPS1 | 55 / 51 s | 42 / 41 s | −22% | 32.5 / 32.1 → 26.0 / 25.6 s | 15,838 = 15,838 (166 entrapment hits both) |
PIN output:
- Astral and UPS1: byte-identical to
main. - TMT: 9 more rows out of 409,262. These are the candidates the old nominal-bucket window skipped (change 1). The accepted count is unchanged.
Comet 2025.01 on the same host the same day took 215 s (Astral), 76 s (TMT) and 46 s (UPS1). With this PR andes is faster than Comet on all three and keeps its PSM lead (+22.1%, +16.9%, +7.5%).
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Re-ran every standard, opt-in, Comet, quick-glyco and phospho benchmark on the benchmark VM at main 7d1e456, then timed #105 against it. - Standard, --chimeric, Comet and phospho counts reproduce the previous values exactly; #105 leaves the standard counts unchanged. - With #105, andes is faster than Comet on Astral, TMT and UPS1 (0.86-0.95x its wall time) with the same 7.5-22.1% PSM lead. - --refine on Astral is +4.9% (was +14.4% before the decoy and isotope fixes); its modified PSMs run at ~3.3% entrapment FDP under the merged 1% threshold. - Quick glyco tier with the bundled mouse glycan list: 7,162 glycoPSMs, 90.1% / 90.7% confirmed by pGlyco2 / MSFragger. - UPS1: Comet shows the same entrapment rate as andes. Historical sections are kept and marked; the deep glyco tier, the matched-depth comparison and Java MS-GF+ were not re-run.
* docs: refresh benchmarks against current main (2026-10-05) Re-ran every standard, opt-in, Comet, quick-glyco and phospho benchmark on the benchmark VM at main 7d1e456, then timed #105 against it. - Standard, --chimeric, Comet and phospho counts reproduce the previous values exactly; #105 leaves the standard counts unchanged. - With #105, andes is faster than Comet on Astral, TMT and UPS1 (0.86-0.95x its wall time) with the same 7.5-22.1% PSM lead. - --refine on Astral is +4.9% (was +14.4% before the decoy and isotope fixes); its modified PSMs run at ~3.3% entrapment FDP under the merged 1% threshold. - Quick glyco tier with the bundled mouse glycan list: 7,162 glycoPSMs, 90.1% / 90.7% confirmed by pGlyco2 / MSFragger. - UPS1: Comet shows the same entrapment rate as andes. Historical sections are kept and marked; the deep glyco tier, the matched-depth comparison and Java MS-GF+ were not re-run. * docs: add time, CPU and memory against Comet; --refine after #106 - New table (README and docs/benchmarks): wall, CPU time and peak memory for andes and Comet on Astral, TMT, UPS1 and phospho, measured with /usr/bin/time on the benchmark VM. andes uses 22-43% less CPU time; it needs 2x Comet's memory on TMT and phospho. - --refine row updated for #106: 40,028 PSMs (+4.3%), Pass-2 entrapment FDP 2.8% (was 3.3%).
…den --deep-features-top (#111) * search: in strong mode, compute full features only for the rows that survive the trim Strong mode retains 25 candidates per spectrum, ranks them by the strong score and trims to the user's top-N (10). Every retained row got the full feature set, including the uncached rich-ion GBDT, the fragment-LLR battery and the site features, although the strong score needs only features computed before them. Retained rows now get a light pass, and after the trim the survivors get the full one. The calibrated strong score is still taken over the whole retained pool. The survivor pass uses a new TopNQueue::update_in_place that pushes the heap's elements back in array order, so the layout, and with it the output order of rows tied on every sort key, is unchanged (BinaryHeap::from does not preserve it). The main path also reuses the edge score from the candidate loop instead of recomputing it. The path-parity guard now also scans the shared make_features closure; edge_score is set by compute_psm_features_with_edge, so its exception was stale and is removed. Both fixture PINs are byte-identical to main. * scoring: evaluate GBDT trees on packed 16-byte nodes After #105, tree-ensemble evaluation is still 31-45% of CPU on Astral, TMT and UPS1 (perf on the benchmark VM). Each node visit read five separate arrays (feature, threshold, left, right, default_left, value). GbdtPeakModel now builds, on first use, a packed copy of its trees: one 16-byte record per node holding the feature, the threshold (or the leaf value), the left child and the right child with the NaN direction in its high bit. predict_value and predict_value_batch walk it with the same comparisons in the same order, so results are bit-identical; a new test checks that against Tree::eval, including NaN and short rows. The cache lives in a new GbdtPeakModel::packed field (construct with Default::default()); equality ignores it. Both fixture PINs are byte-identical to main. * search: hidden --deep-features-top K to compute model features for the best K rows only Each spectrum emits up to 10 PIN rows, and every row gets the model-based features (rich-ion LLR GBDT, fragment-LLR battery, site features). Ranks 2-10 cost about a third of low-res search time. With --deep-features-top K, all rows take the light pass and only the best K (by the queue's rank score, ties included) get the full one; the others keep those columns at 0.0. Default 0 keeps every row, and output is byte-identical to before. For measurement before any default changes.
Four speed changes. Three leave output byte-identical; the first is not byte-identical because it fixes a recall bug, explained below.
Changes
1. Exact-mass candidate lookup (
search)matches_precursorup to 4× per candidate. Only ~16% passed.matches_precursor, and the matches are sorted by index so iteration order is unchanged.round(0.9995 × mass). Near a rounding boundary, an accepted candidate (more often at isotope offsets) can fall outside the window's slack, and it was never looked at.matches_precursoraccepts, for ppm and Da tolerances, z 2–4, isotope offsets −1..2.2. Memoised fragment-intensity predictions (
scoring)3. Parallel setup (
search)4. Skip edge scoring when the model cannot score edges (
scoring,search)psm_edge_scorestill built per-residue arrays for every candidate, and the gate's bound of 10 per residue never pruned.Measured so far (local x86 build under Rosetta, human SwissProt, 8 threads)
These timings come from a loaded laptop: the same binary varied 5.7–14 s on the scoring phase between runs. They show direction, not size.
Still to do before merging
main, in one session.Local
cargo test --workspaceand clippy (-D warnings) pass.Summary by CodeRabbit
Performance
Scoring