Skip to content

perf: strong-mode features only for survivors, packed GBDT nodes; hidden --deep-features-top - #111

Merged
ypriverol merged 3 commits into
mainfrom
perf/gbdt-packed-nodes
Oct 6, 2026
Merged

ypriverol merged 3 commits into
mainfrom
perf/gbdt-packed-nodes

Conversation

@ypriverol

Copy link
Copy Markdown
Contributor

Three commits. With default settings, all PINs are byte-identical to main.

Changes

1. Strong mode: full features only for the rows that survive the trim.

  • Strong mode keeps 25 candidates per spectrum, ranks them by the strong score and trims to 10. Every retained row used to get the full feature set, including the uncached rich-ion GBDT, the fragment-LLR battery and the site features.
  • Now the pool gets a light pass (the strong score needs only the cheap features), and the survivors get the full one.
  • A new TopNQueue::update_in_place pushes the heap's elements back in array order, so rows tied on every sort key keep their output order. BinaryHeap::from does not preserve it, which was found and fixed during testing.
  • The main path also reuses the candidate loop's edge score instead of recomputing it.
  • The path-parity guard now scans the shared make_features closure, and its stale edge_score exception is removed.

2. GBDT trees evaluated on packed 16-byte nodes.

  • Each node holds the feature, the threshold or leaf value, the left child, and the right child with the NaN direction in its high bit.
  • The comparisons are the same and run in the same order. A new test checks bit-identity against Tree::eval, including NaN and short rows.
  • The cache is a new GbdtPeakModel::packed field, built on first use; equality ignores it.

3. Hidden --deep-features-top K (default 0 = all rows, byte-identical). It computes the model features only for each spectrum's best K rows. This is for measurement only, and the default does not change. Measured below, K = 3 saved 4–13% CPU with identifications flat on Astral and TMT and −0.5% on UPS1, so it is not proposed as a default.

Measured on the benchmark VM

main against this branch, 8 threads, binaries alternated, 2 runs each, /usr/bin/time -v:

dataset main wall / CPU this branch wall / CPU change peak memory
Astral 193, 190 s / 1,173, 1,156 s 183, 183 s / 1,109, 1,114 s −4.5% wall, −4.6% CPU 7.7 → 7.1 GB
TMT a05058 65, 65 s / 313, 312 s 63, 63 s / 302, 302 s −3% unchanged
UPS1 41, 40 s / 204, 204 s 41, 41 s / 206, 209 s none unchanged
Phospho 911 s / 5,853 s 900 s / 5,761 s −1% unchanged

PINs are byte-identical to main on all four datasets.

The packed-node layout contributed little: tree evaluation is bound by how many evaluations run, not by node layout. Most of the Astral gain is from change 1.

--deep-features-top (Percolator -Y, seeds 42/1/2, PSMs at 1%):

dataset K = all K = 3 K = 1 CPU, K = 3 / K = 1
Astral 38,394 / 38,517 / 38,483 38,524 / 38,429 / 38,376 38,110 / 38,265 / 38,135 −4% / −6%
TMT 12,281 / 12,342 / 12,264 12,305 / 12,344 / 12,320 12,246 / 12,289 / 12,260 −8% / −13%
UPS1 15,838 / 15,701 / 15,777 15,755 / 15,618 / 15,706 — −13%

Workspace tests and clippy (-D warnings) pass.

…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.
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.
…e 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.
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3347131f-0658-49ad-89c0-fd0da86a68e4
📥 Commits

Reviewing files that changed from the base of the PR and between 7e93bdc and ea2b9c1.

📒 Files selected for processing (17)
  • crates/andes/src/bin/andes/cli.rs
  • crates/andes/src/bin/andes/search.rs
  • crates/model-train/src/gbdt/train.rs
  • crates/model-train/src/gbdt/tree.rs
  • crates/model-train/tests/roundtrip.rs
  • crates/output/src/glyco_pin.rs
  • crates/output/src/pin.rs
  • crates/output/src/tsv.rs
  • crates/scoring/src/gbdt_eval.rs
  • crates/scoring/src/param_model.rs
  • crates/scoring/src/scoring/scored_spectrum.rs
  • crates/scoring/src/scoring/strong_score.rs
  • crates/search/src/mass_calibrator.rs
  • crates/search/src/match_engine.rs
  • crates/search/src/psm.rs
  • crates/search/src/search_params.rs
  • crates/search/tests/path_parity.rs
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ypriverol
ypriverol merged commit 77e972e into main Oct 6, 2026
5 checks passed
@ypriverol
ypriverol deleted the perf/gbdt-packed-nodes branch October 15, 2026 16:05
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