Skip to content

Commit 8cc29d0

Browse files
authored
Fix rc12 review cleanup issues (#313)
* Fix rc12 review cleanup issues * Update orchestrator docs for worker context rename * Clarify calibration peptide feature sizing * Extract calibration CUDA batch sizing * Add release workflow and notebook audit
1 parent 7d156f0 commit 8cc29d0

57 files changed

Lines changed: 1669 additions & 635 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Have a bugfix or other contribution? We would love your help. See our [contribut
2020
## 2.3.0 release candidate
2121

2222
> [!IMPORTANT]
23-
> 2.3.0 is currently a release candidate (`2.3.0rc11`), not yet a final release.
23+
> 2.3.0 is currently a release candidate (`2.3.0rc12`), not yet a final release.
2424
> It keeps the same public API and pre-trained models as 2.2.x. Install it with
2525
> `pip install --pre mhcflurry`, or pin the version with
26-
> `pip install mhcflurry==2.3.0rc11`. A plain `pip install --upgrade mhcflurry`
26+
> `pip install mhcflurry==2.3.0rc12`. A plain `pip install --upgrade mhcflurry`
2727
> stays on the latest stable release (2.2.x) until 2.3.0 is final, since pip
2828
> skips pre-releases.
2929
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# 2023 Retraining Notebook Audit
2+
3+
This audits the copied notebook bundle in `notebooks/2023-retraining/` against
4+
the maintained release scripts and 2.3.x evaluation commands. The notebooks are
5+
valuable source material, but they include generated data, checkpoint notebooks,
6+
old imports, and local paths, so they should be ported into scripts rather than
7+
committed as the workflow.
8+
9+
## What The Notebooks Cover
10+
11+
- Benchmark assembly: joins `data_evaluation` sample shards into wide
12+
monoallelic and multiallelic benchmark tables with MHCflurry, NetMHCpan, and
13+
MixMHCpred columns.
14+
- Accuracy scoring: per-sample and per-length AUC / PPV tables, percent-change
15+
columns against NetMHCpan BA, NetMHCpan EL, MixMHCpred, and older MHCflurry.
16+
- Figure generation: paper-style scatter panels, score bars, processing motifs,
17+
processing-vs-affinity correlation plots, and presentation coefficient plots.
18+
- Supplemental outputs: sample tables, benchmark data files, model-selection
19+
accuracy workbook, antigen-processing motif workbook, and supplementary data
20+
CSV/XLSX files.
21+
- Exploratory analyses: novel-allele analysis, proteasome mass-spec analysis,
22+
and an immunogenicity experiment depending on external local files.
23+
24+
## Differences From Maintained Workflows
25+
26+
- Data curation is split differently. Current maintained scripts use
27+
`downloads-generation/` to build raw downloads and `scripts/training/` to build
28+
release models. The notebooks start from already-generated downloads and create
29+
analysis artifacts under `notebooks/2023-retraining/artifacts/`.
30+
- The current `data_evaluation` download generates train-excluded benchmark
31+
files and sample shards. The notebooks additionally join those shards into
32+
wide analysis tables and include an abandoned no-exclude-train path.
33+
- The notebooks label recent multiallelic samples using PMIDs `31844290` and
34+
`31154438`. Current presentation training excludes `31844290`, `31495665`, and
35+
`31154438`; this needs one named holdout policy before new public weights are
36+
trained and evaluated.
37+
- The notebooks use old notebook-era dependencies and names (`keras`,
38+
`tensorflow`, `mhcnames` in places). Ports should use the current PyTorch code,
39+
`mhcgnomes` / existing allele normalization helpers, and maintained CLI
40+
commands.
41+
- Current `mhcflurry compare-models` covers affinity and presentation regression
42+
metrics, and `mhcflurry plot-model-comparison` renders generic plots. It does
43+
not yet recreate the paper-style benchmark tables, sample-group comparisons,
44+
model-selection workbook, motif workbook, or supplemental figures.
45+
- The current full training script trains processing `no_flank` and
46+
`short_flanks` variants, then uses `short_flanks` as the with-flank processing
47+
component for presentation. Older download-generation trained a separate
48+
`models.selected.with_flanks` variant. That semantic difference should be
49+
resolved explicitly before publishing 2.3.0 weights.
50+
- Historical runplz files in `jobs/` patched scripts in place for one experiment
51+
and called deleted comparison scripts. Remote execution is now represented by
52+
maintained scripts instead of patching a remote copy.
53+
54+
## Missing Figure And Table Ports
55+
56+
- Predictor metadata / aesthetics: convert `0 aesthetics.ipynb` into a small
57+
`predictor_info.csv` generator with stable labels, colors, and descriptions.
58+
- Wide benchmark tables: port the monoallelic and multiallelic shard-join logic
59+
from `1 prepare benchmark dataset*.ipynb`.
60+
- Accuracy score tables: port the AUC / PPV / percent-change tables from
61+
`2 monoallelic accuracy plots.ipynb` and `2 multiallelic accuracy.ipynb`.
62+
- Monoallelic figures: BA/EL/MixMHCpred scatter panels, training-count vs AUC,
63+
and novel-allele comparison tables / plots.
64+
- Multiallelic figures: PPV/AUC scatter panels comparing NetMHCpan BA,
65+
NetMHCpan EL, MixMHCpred, older MHCflurry, and presentation score variants,
66+
including recent-vs-old sample grouping.
67+
- Model-selection evidence: port the unselected-model held-out decoy AUC workbook
68+
and HLA locus score bars.
69+
- Processing evidence: port antigen-processing motif count/PWM workbook,
70+
processing logo figure, and processing-vs-affinity correlation plots.
71+
- Supplemental outputs: port sample table, supplemental sample table with
72+
accuracies, benchmark supplemental CSVs, and proteasome mass-spec additional
73+
file generation.
74+
- Immunogenicity experiment: defer until external source files are located and
75+
licensed; do not make this a release gate yet.
76+
77+
## Porting Plan
78+
79+
1. Add `scripts/analysis/` for reusable release-analysis scripts. Keep notebooks
80+
out of the maintained path; use them only as references.
81+
2. Extract shared metric helpers: PPV@N, sign normalization, bootstrap intervals,
82+
percent-change calculations, and sample/length grouping.
83+
3. Add a benchmark-assembly script that consumes a `data_evaluation` directory
84+
and writes wide monoallelic/multiallelic analysis CSVs from the group files.
85+
4. Add an accuracy-table script that writes the notebook-style
86+
`accuracy_scores.*.csv` tables from those wide benchmarks.
87+
5. Add figure scripts that consume the generated tables and produce stable PNG /
88+
PDF outputs under a release-analysis directory.
89+
6. Add processing-motif generation from the presentation benchmark and trained
90+
processing predictors. This should be scriptable without `logomaker` unless
91+
the logo plot is explicitly requested; the workbook can be generated first.
92+
7. Decide the 2.3.0 holdout policy in one place: PMIDs, pMHC overlap removal,
93+
and whether evaluation data is filtered out of affinity / processing /
94+
presentation training. Move any useful logic from `jobs/filter_training...`
95+
into maintained scripts after that decision.
96+
8. Resolve the processing variant naming: either train a real
97+
`models.selected.with_flanks` variant again or document and test that
98+
`short_flanks` is the canonical with-flank presentation input for 2.3.x.
99+
9. Make the release gate one command:
100+
`scripts/release/retrain_evaluate_deploy.sh` trains, evaluates, plots, and
101+
runs deployment validation. It supports local, runplz/Brev, and SSH-backed
102+
remote machines.
103+
104+
## Current Single-Command Entry Point
105+
106+
Local:
107+
108+
```bash
109+
scripts/release/retrain_evaluate_deploy.sh \
110+
--run-dir /path/to/release-run \
111+
--release 2.3.0 \
112+
--backend local \
113+
--deploy-mode dry-run
114+
```
115+
116+
Brev through runplz:
117+
118+
```bash
119+
scripts/release/retrain_evaluate_deploy.sh \
120+
--run-dir /path/to/release-run \
121+
--release 2.3.0 \
122+
--backend runplz \
123+
--deploy-mode dry-run
124+
```
125+
126+
Generic SSH machine:
127+
128+
```bash
129+
scripts/release/retrain_evaluate_deploy.sh \
130+
--run-dir /path/to/local-copy \
131+
--release 2.3.0 \
132+
--backend ssh \
133+
--remote user@host \
134+
--remote-repo /path/to/mhcflurry \
135+
--remote-run-dir /path/to/remote-release-run \
136+
--deploy-mode dry-run
137+
```

docs/development.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Development Maintenance
2+
3+
## Private API and Fallback Cleanup
4+
5+
MHCflurry should keep internal helpers movable. Tests and sibling modules should
6+
not pin underscore-prefixed functions unless the helper is truly private to the
7+
same module.
8+
9+
1. Promote shared helpers before cross-module use.
10+
If a helper is imported by another module or tested directly, give it a
11+
public name in its owner module and document the contract in one sentence.
12+
13+
2. Test owner modules, not compatibility facades.
14+
Tests for moved helpers should import the helper module directly. Compatibility
15+
shim tests should cover public behavior only: old imports still expose the
16+
documented entry point and produce the same result.
17+
18+
3. Make fallback paths observable.
19+
Fallbacks for missing optional tools or hardware probes may return a safe
20+
default. Fallbacks caused by import errors, bad local refactors, or invalid
21+
user configuration should fail loudly instead of being caught by broad
22+
`except Exception` blocks.
23+
24+
4. Keep compatibility shims thin.
25+
Old module paths may re-export public entry points and delegate unknown
26+
attributes, but they should not replace `sys.modules` or assert identity with
27+
the new implementation module.
28+
29+
5. Track remaining private test hooks.
30+
The remaining direct private imports in tests should be triaged into:
31+
public helper, same-module implementation detail tested through behavior, or
32+
compatibility shim slated for removal after the 2.3 release line stabilizes.

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ python_tutorial
99
commandline_tools
1010
api
1111
testing
12+
development
1213
```

docs/orchestrator.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ orchestrator process training worker process
2525
───────────────────── ───────────────────────
2626
2727
parse args (forked / spawned)
28-
load training data inherit GLOBAL_DATA
29-
build GLOBAL_DATA ─┐
28+
load training data inherit WORKER_CONTEXT
29+
build WORKER_CONTEXT ─┐
3030
3131
hoist env knobs │
3232
TORCHINDUCTOR_COMPILE_THREADS
@@ -91,7 +91,7 @@ Two backends, one CLI surface:
9191
historical CPU-overflow behavior.
9292
- **Cluster** (`cluster_parallelism.py`): one job per work-item
9393
submitted via `bsub` / `sbatch` / `sh`. Workers serialize
94-
GLOBAL_DATA to NFS and deserialize on the worker side.
94+
WORKER_CONTEXT to NFS and deserialize on the worker side.
9595

9696
Worker-side code (`train_model()`, etc.) is identical between
9797
backends. Only the orchestrator branches on `args.cluster_parallelism`.
@@ -269,7 +269,7 @@ before compiling losses to avoid the PyTorch 2.4 / Triton
269269

270270
1. Add a `_initialize_<name>(args, all_work_items)` helper near the
271271
existing ones in `train_pan_allele_models_command.py`.
272-
2. Stash the result in `GLOBAL_DATA["<name>"]`.
272+
2. Stash the result in `WORKER_CONTEXT["<name>"]`.
273273
3. Document the lookup key. Workers retrieve via
274274
`constant_data["<name>"]` (forked workers inherit; spawned/cluster
275275
workers receive via pickle).

0 commit comments

Comments
 (0)