Skip to content

dia: diaPASEF 27 -> 21 min at 48 CPUs (50 -> 47 at 16), byte-identical; parallel search merge, PIN parsing, RT refit, line search - #581

Merged
ypriverol merged 21 commits into
mainfrom
perf/diapasef-fast2
Nov 25, 2026
Merged

ypriverol merged 21 commits into
mainfrom
perf/diapasef-fast2

Conversation

@ypriverol

Copy link
Copy Markdown
Contributor

A second round of diaPASEF speed-ups, after #571. Steps that ran on one core now run in parallel. Outputs are byte-identical.

On PXD062685 Condition A Sample Alpha 01, with native rescoring, each A/B pair ran on disjoint halves of the same node:

CPUs / threads main this PR
16 / 14 50:48 47:01
16 / 16 45:52 43:22
48 / 46 26:52 21:04
  • Outputs: the outputs digest is a78fefbc… at 14, 16 and 46 threads, on main and on this branch. The PB-Astral slice digest (63e679ec…) is unchanged at 8 and 14 threads.
  • IDs: 70,639 precursors, 664,545 PSMs and 9,320 protein groups at q ≤ 0.01, the same as main.
  • Memory: peak RSS is 60–62 GB.
Stage at 48 CPUs (s) main this PR
search 608 467
predict 281 202
re-rank + keep + co-elution 70 49
pass-1 + RT refit 97 57
outputs 39 27

Changes

  • Search:
    • The chunk's charge-unit merge, the leave-one-out recalibration and the copy of kept peptides run in parallel.
    • The fragment-intensity cache is keyed by peptide, not to_string(), and caches the final intensities.
    • GBDT batches are padded to 8 rows instead of 32.
  • PIN reading: each block is checked as UTF-8 and split into lines in parallel, peptide and pair lookups run in parallel, and the maps use FxHash.
  • DIA passes:
    • The re-rank sorts in parallel, with the row index as tie-break so results stay deterministic.
    • Nomination uses one parallel sort.
    • The three RT-refit folds train together.
    • Co-elution and precursor-PIN maps use FxHash.
  • Rescoring:
    • The native line-search row pass runs in parallel.
    • The learned score starts right after pass 2, and its histograms are split over enough tasks for every thread.
  • Outputs: class-FDR classification and protein-inference rows run in parallel, and the target and decoy sides run together.

Tried and dropped

  • Scoring two index chunks at once (rayon::join) was slower at 16 and 48 CPUs.

At 16 CPUs the run is now CPU-bound: index voting, the fragment GBDT, the MS2 predictor and the learned-score GBDT.

@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 Nov 25, 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 9 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 80f02956-c330-4c71-bc09-bbc4f46fea84
Commits

Reviewing files that changed from the base of the PR and between 22acad2 and 9b0d056.

Files selected for processing: 17

  • crates/andes/src/bin/andes/dia.rs
  • crates/andes/src/bin/andes/dia/blocks.rs
  • crates/andes/src/bin/andes/dia/pass2.rs
  • crates/andes/src/bin/andes/dia/pin.rs
  • crates/andes/src/bin/andes/dia/qvalue.rs
  • crates/andes/src/bin/andes/dia/rt.rs
  • crates/andes/src/bin/andes/dia/score.rs
  • crates/andes/src/bin/andes/search/finish.rs
  • crates/andes/src/bin/andes/search/rescoring.rs
  • crates/model-train/src/gbdt/tree.rs
  • crates/output/src/fdr/class.rs
  • crates/output/src/protein/inference.rs
  • crates/rescore/src/svm.rs
  • crates/scoring/src/gbdt.rs
  • crates/search/src/engine/features.rs
  • crates/search/src/engine/run.rs
  • crates/search/src/fragments/predictions.rs
  • Autofix · 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

…ities

The chunk cache of fragment-intensity predictions built its key with
peptide.to_string() on every lookup (about 115 M lookups on a diaPASEF
run) and turned the cached raw values into intensities (one exp per ion)
on every hit. It now hashes the peptidoform in place, compares it with
Peptide equality (residues, residue masses, modifications, flanks: a
superset of the text the key used) and stores the intensities, shared
by Arc. The peptidoform is cloned only on a miss.
After the charge searches of a chargeless chunk, each spectrum's merged
queue is trimmed and its strong scores recalibrated leave-one-out over
the spectrum's pool, O(kept x pool) per spectrum. The loop ran on one
thread for 20,000 spectra per chunk; it now runs per spectrum on the
thread pool (each spectrum's result depends only on its own queue and
pool).
The keep-10-per-scan step sorted 75 M PIN rows by (scan group, re-rank
score) with a stable sort on one thread, and looked the scan groups up
in a SipHash map. The sort is now par_sort_unstable_by with the row
index as the last key (the order the stable sort gives, ties included)
and the group map uses FxHash (group ids still number the groups in
first-appearance order).
Nomination walked the 75 M pool rows on one thread to keep, per
(peptidoform, charge, run), the first row of the highest pool LLR. The
rows are now ranked by a parallel sort on (key, LLR descending, row
index) and the first row of each key is kept: the same rows. With a NaN
LLR (where the walk's result depends on the order) the walk stays.
…pose

The co-elution columns built two maps over the kept 9.5 M PIN rows and
the re-rank looked up each of 75 M rows' run name in SipHash maps on one
thread; they use FxHash now (only lookups and in-order pushes, no
iteration order leaks out). The co-elution feature columns are
transposed one column per task.
The RT refit trained its three cross-fitted regression GBDTs one after
the other and predicted the 9.5 M PIN rows on one thread. The folds now
train on the thread pool together, each row is predicted by its fold's
model in parallel, and the median sort runs in parallel (an f64 sort by
total_cmp gives the same sequence stable or not).
The precursor PIN reads the 9.5 M pass-1 rows into a map of the best row
per (FileName, Peptide, charge); the map is only looked up and updated
in row order, so FxHash replaces SipHash without changing the result.
On a chargeless DIA chunk each spectrum is searched at every charge in
separate charge searches; their units' PSMs were moved into the
spectra's merged queues on one thread, 14 % of a chunk's time at 46
threads (1.65 s of 12 s per chunk). When the units of a charge search
belong to distinct spectra (the usual case: one spectrum's charges have
precursor masses further apart than a chunk spans) each spectrum is now
filled on the thread pool, in the same order as before; otherwise the
units are merged one by one as before.
Every DIA pass that reads the 75 M-row PIN (predict, pool scores,
co-elution, RT refit, precursor q) looked up each row's peptide in
SipHash maps on one thread; at 48 threads the predict step ran 80 s on
about 3 cores before its RT predictions and 33 s on one core before its
MS2 predictions. The rows' known/new peptide test and their form ids are
now looked up on the thread pool, and only the new peptides are walked
in order (form ids keep their first-appearance numbering). The MS2
(peptidoform, charge) pairs are found the same way (eligibility in
parallel, numbering in row order), the row-to-pair map is parallel, and
the maps (spectrum bases, forms, pairs, anchors, folds) use FxHash; none
is iterated in an order that reaches the output.
…rallel

The kept-feature completion copies each batch's peptides (2,048 spectra,
about 90 k peptides) out of the candidate store under its lock on one
thread, 3 % of a chunk's time at 46 threads. The copy now runs on the
thread pool while the lock is held; nothing else takes that lock while a
chunk completes its kept features (the chunk's scoring has finished and
chunks are scored one at a time), so the parallel copy cannot wait on
it.
The class-wise FDR and the cutoffs classify every rescored PSM (5 M
targets and their decoys on a diaPASEF run) by its proteins' entry kinds
on one thread, several times after rescoring. The classification now
runs in parallel over the rows in the map's iteration order (rows keep
their indices), and the pooled decoy scores sort in parallel (an f64
sort by total_cmp gives the same sequence).
Reading the pass-1 PIN for the precursor PIN allocated each row's
(FileName, Peptide, charge) key and looked up its SpecId in a SipHash
map on one thread (18 s on about 3 cores at 48 threads). The keys are
now built in the parallel parse and the nominee map uses FxHash; the
best row per key is still chosen in row order.
The block reader of the DIA passes validated each 64 MB block as UTF-8
and split it into lines on the consumer thread, then handed the lines to
the parallel parse. The 75 M-row pass-1 PIN is about 60 GB of text and is
read by several passes (predict, pool scores, nomination, re-rank,
co-elution), so this serial step cost tens of seconds per run. A block
is now cut after newlines into 64 pieces that are checked and split on
the thread pool and concatenated in order: the same lines.
In each SVM fit the line search walked the training rows on one thread
to sum the two slopes and collect the breakpoints; at 48 threads it was
a third of the fit time on the diaPASEF pass-1 PIN (39 of 119 s summed
over the fits; gram 43 s, screened passes 27 s). The rows' slope terms
and breakpoints are now computed per chunk of rows in parallel, then
added and concatenated in row order: the same sums (same additions in
the same order) and the same breakpoint list before the stable sort.
The AVX2 tree walk evaluates rows in steps of 32 (four 8-lane groups),
padding a batch's row count up to a multiple of 32 with copies of its
last row. The rich-ion and fragment-intensity models are evaluated per
PSM on tens of ion rows, so the padding was a large share of the walk.
The rows are now padded to a multiple of 8: full 32-row steps as before,
then single 8-lane groups for the rest. Each row's value is still the sum
of its leaves over the trees in tree order, so the outputs are the same.
A tree node's histograms are built in tasks of 4 features. The DIA
learned score trains on about 45 features in 3 folds at once, so a node
gave about 11 tasks per fold and the 48-thread runs used about 20 cores
for its rounds. A task now takes fewer features (down to 1) when the
blocks of 4 would not give every thread one. Each bin still adds its rows
in row order, so the histograms are the same.
Protein inference turned each rescored PSM (5 M targets, and the decoys)
into its peptide's protein families on one thread, then ran the target
and decoy parsimony one after the other. The families are now found per
PSM on the thread pool and merged per peptide in a map (the best score
and the union of families do not depend on the merge order), the rows
sort in parallel (their peptides are distinct), and the target and decoy
sides run together.
The learned score of the precursor PIN (three cross-fitted GBDT rounds)
was started with pass-1 rescoring and its later rounds outlasted pass 1,
so it set the end of rescoring. It depends only on the pass-2 table and
the seed, so it now starts on its own thread right after pass 2, beside
the per-scan cut and the co-elution columns, and rescoring joins it after
pass 1 (the table moves into the thread and back). Same score; the
memory it holds (about 5 GB) now overlaps those steps, which hold less
than the search did.
@ypriverol
ypriverol merged commit 6a6d851 into main Nov 25, 2026
6 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