Repository navigation
onnx-infer: review fixes (AGBD footer, tract names, extraction retry, N-term sites, Unimod matching) - #145
Conversation
…it and decode natively parse_agbd reads the n_iso/iso_x/iso_y footer that GbdtPeakModel::to_bytes writes and rejects only bytes after it. The ONNX graph stays the raw tree sum (predict_value); the sigmoid flag and isotonic map go to the manifest extras. make_local_fixtures writes the footer and now also builds tree_leq; the committed .agbd fixtures are regenerated and a test decodes them with scoring::gbdt_eval::GbdtPeakModel::from_bytes.
Names come from the outlet labels tract-onnx sets from the graph's tensor names; the producing node's name is only the fallback. The intensity_mlp fixture now names its nodes (/MatMul, /Add, /Relu) so tests on both backends check that the output is reported as `score`.
The part parquet is written only when every run of the task succeeded; the summary JSON's complete field is the done marker, a failed task removes any stale part and exits 1, so resubmitting the array retries it.
…-terminal mods at site 0 parse_peptide builds the Form from RtPeptide::from_andes, so the PeptDeep, DeepLC, Prosit, MS2PIP and andes-ms2 paths share the parser andes-rt and andes-ms2 use. pyro-Glu and a lone TMT delta after a leading K now sit at site 0, as in alphabase (Gln->pyro-Glu@Q^Any_N-term at site 0); before, they went to residue 1, which changes PeptDeep's mod_x row. DeepLC keeps pyro-Glu on residue 1, matching its reference panel. Masses are Unimod monoisotopic. The PeptDeep reference panel gains pyro-Gln, pyro-Glu and N-terminal TMT peptides with their andes spelling; model_parity checks the parsed names and sites against peptdeep's.
TMTpro (+304.207145) resolved to iTRAQ8plex (+304.205359) because every entry within 2 mDa competed on id alone. rt_native::mods::match_mass and mod_composition.match_mass now pick the closest site-compatible mass; equal masses (to 1e-6 Da) still go to the lowest id.
- rescore_pin: skip and count PIN lines that are blank, short or have a non-numeric ScanNr, spectra without a scan number and duplicate scans; a non-finite RT prediction is written as missing. - README quick start packs the two 7-residue peptides at seq_len 7. - peptdeep::encode comments: nothing reads extras.mod_hidden; lowercase residues are read as uppercase. - rescore_pin_arms: RT calibration only for sources an arm uses as rt. - rt_train: --fewshot-ptm drops that PTM's other peptidoforms from train/val.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
Warning Review limit reachedYou'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 53 minutes. View limit details
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 |
ypriverol
left a comment
There was a problem hiding this comment.
Review — tip of onnx-infer stack (primary fix target)
Good cleanup PR (AGBD footer, tract names, extract retry, N-term/Unimod). This tip is where remaining substrate bugs should be fixed before merging the stack toward main.
Still open at this tip (verified against onnx-infer/review-fixups-b)
| Sev | Location | Finding |
|---|---|---|
| High | src/rescoring/features.rs SPECTRUM_CORE_FEATURES |
Still tic_top_fraction / mz_intensity_weighted_std. quantms-rescoring uses fraction_tic_top_10 / weighted_std_mz (QUANTMS_FEATURES). Contract tests freeze the wrong names. |
| High | ALPHAPEPTDEEP_CORE_FEATURES |
Still includes rt_diff / predicted_retention_time (DeepLC). Combining generators → duplicate PIN columns / unit confusion. |
| Medium | RescoringBatch::from_rows |
Missing features → 0.0 (looks like perfect RT/MSE). Prefer hard error. |
| Medium | TopNPolicy::filter_sorted_by_rank |
Does not read rank; interleaved spectra can admit >N. |
| Medium | Cargo.lock |
time still 0.3.41 (RUSTSEC-2026-0009) via tract pin. |
| Low | CI | Clippy without --features tract,ort; no Python test_fixtures.py lane for TreeEnsemble. |
PeptDeep AA/pads/scaling/dtype casts and run_one look fixed upstack — good.
LLM Fix Brief (copy-paste for implementing agent)
You are fixing remaining onnx-infer review items on bigbio/andes.
Checkout: onnx-infer/review-fixups-b (PR #145 tip). Open a branch onnx-infer/review-fixups-c from it.
MUST FIX:
1) crates/onnx-infer/src/rescoring/features.rs
- SPECTRUM_CORE_FEATURES := ["snr","spectral_entropy","fraction_tic_top_10","weighted_std_mz"]
- ALPHAPEPTDEEP_CORE_FEATURES := remove "rt_diff" and "predicted_retention_time" (MS2-only names)
- Update crates/onnx-infer/tests/contracts.rs frozen lists to match
- Grep repo for old names and update docs/examples
2) crates/onnx-infer/src/rescoring/psm.rs
- RescoringBatch::from_rows: if feature missing → return Err(Error::InvalidArg(...)) not 0.0
- Replace test batch_packs_missing_as_zero with batch_errors_on_missing_feature
- TopNPolicy: add filter that groups by spectrum_ref and keeps lowest ranks; reject or sort unsorted input; add interleaved-spectrum test
3) Dependencies
- Bump tract-onnx to a release that does not force time<0.3.42, OR document isolation; ensure Cargo.lock time >= 0.3.42
- cargo test -p onnx-infer --features tract
- cargo test -p onnx-infer --features ort (if available)
- cargo clippy -p onnx-infer --all-targets --features tract -- -D warnings
4) CI (.github/workflows/ci.yml)
- clippy step also with --features tract (and ort on ubuntu if feasible)
- optional: python scripts/test_fixtures.py in onnx-infer with pip onnxruntime
DO NOT: reintroduce alphabetical AA table; do not remove L+2 pads or CHARGE_FACTOR/NCE_FACTOR; do not make ort default.
Acceptance:
- All onnx-infer tests green with tract (and ort if feature builds)
- rg confirms no tic_top_fraction / mz_intensity_weighted_std left
- time crate in Cargo.lock >= 0.3.42
Open PR against onnx-infer/review-fixups-b describing each fix.
The stack fixed several of the same review findings. Where both sides fix one finding, the stack's implementation is kept: - AGBD footer: parse_agbd_full, the parity table, peak_gbdt_calibrated.agbd and tests/agbd_native.rs replace this branch's calibrated peak_gbdt.agbd and tests/agbd_fixtures.rs. The export manifest keeps apply_sigmoid, iso_x and iso_y in its extras. - tract output names: the stack's outlet-label lookup; the intensity_mlp name tests for tract and ort are kept (the fixture keeps its named nodes). - Unimod mass matching: the stack's closest-mass rule in Rust and Python; this branch's extra TMTpro/iTRAQ8plex, pyro-Glu and oxidation asserts are kept. - RT calibration per arm and few-shot exclusion: the stack's versions. The example parser stays on RtPeptide::from_andes (N-terminal mods at site 0), which already decodes the summed N-terminal + residue delta through split_nterm_residue_delta; the stack's andes-writer test is kept on it.
|
Merged Superseded by the stack:
Unique to this PR, kept:
|
Fixes the review findings on the onnx-infer stack (#132 → #142). Stacked on #142.
AGBD export reads the calibration footer.
parse_agbdraised on every native blob becauseGbdtPeakModel::to_bytesalways appendsn_iso+iso_x/iso_y. The parser now reads that footer before rejecting extra bytes. The ONNX graph still exports the raw tree sum, the same value nativepredict_valuereturns. The sigmoid flag and the isotonic points go into the manifestextras(apply_sigmoid,iso_x,iso_y). The fixtures now carry a non-trivial footer, and the newtests/agbd_fixtures.rsdecodes them with the nativefrom_bytesand checks they re-serialise byte-for-byte.tract output names. Names now come from
outlet_label, not the producing node, so tract and ort agree. This was visible on real exports: DeepLCrtwas reported as/Add_1and PeptDeeprt_predas/Squeeze. A test covers both backends and fails on the old code.Extraction retry.
ms2_extract_rawwrites the part parquet only when every run succeeded. A task is marked done bycomplete: trueinpart-N.json, so a partial failure is redone when resubmitted. A pytest covers fail → resubmit → complete → skip.N-terminal mods at site 0. The example encoders now parse peptides through
RtPeptide::from_andes, so every model path uses one parser. pyro-Glu, and a lone TMT on a leading K, now sit at site 0, which matches training and alphabase. The position changes peptdeep output: N-terminal TMT RT moves from 0.507 to 0.580. The parity panel gained pyro-Gln, pyro-Glu and N-terminal TMT peptides.Unimod mass matching. When resolving a mass delta, the closest mass now wins and the lowest id only breaks ties; this is done the same way in Rust and Python. Before, TMTpro resolved to iTRAQ8plex. Training never used mass matching, because ProForma is parsed by Unimod id, so the trained RT model is unaffected. Only inference on TMTpro PINs was affected.
Smaller items:
rescore_pinskips malformed PIN rows and spectra with a missing or duplicate scan number, reporting how many it skipped instead of panicking.encode.rscomments now match the code.--all-targets)-D warnings