Fix GLACIER training path: restore PredSpecDB-aware add_dag_intens.py, Lightning 2.x scheduler hook, add smoke test - #44
Merged
Conversation
Restores RuiXiWangTW's fix "fix magma inten" (02e6ade) for data_scripts/dag/add_dag_intens.py. The content of that fix was overwritten in 7b59014 ("add run scripts"), which returned this file to its earlier version; the other files touched by 02e6ade are unaffected. Without it, `add_dag_intens.py --magma-output` (as called by run_scripts/glacier/add_inten.sh) cannot read the PredSpecDB magma_tree.hdf5 written by the current run_magma.py: names are matched by Path(name).stem, so no entries match and the script stops with "ValueError: Empty list to process!". The mode without --magma-output, used by the ICEBERG and MARASON run scripts, produces identical output with either version of the file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Lightning 2.x calls the hook as lr_scheduler_step(scheduler, metric), so the three-positional-argument signature raised "TypeError: JointModel.lr_scheduler_step() missing 1 required positional argument: 'metric'" after the first optimizer step of glacier/train_joint.py. Use the metric=None default already used by the other models in this repository. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
test_add_dag_intens_reads_magma_predspecdb runs run_magma.py, 01_assign_subformulae.py and add_dag_intens.py --magma-output on a four-molecule dataset in a temporary directory and checks that the PredSpecDB magma_tree.hdf5 yields one `<spec>_collision <ce>` JSON tree per spectrum that the GLACIER IntenDataset can load. test_glacier_fast_dev_run_cpu runs one CPU training step of the GLACIER JointModel with pl.Trainer(fast_dev_run=True), which exercises the lr_scheduler_step hook under the installed pytorch-lightning. Both run on CPU in a few seconds. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
|
Thank you, Jonathan. Merged. |
Contributor
Author
|
My pleasure. Thanks for the quick review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #43
On current
main(67ba0f2), the documented GLACIER training workflow stops atrun_scripts/glacier/add_inten.shand, once that is fixed, again after the first optimizer step. Details and reproduction are in #43.Commits
add_dag_intens.py(from 02e6ade). This restores RuiXiWangTW's fix "fix magma inten" (02e6ade) fordata_scripts/dag/add_dag_intens.py; the file is byte-identical to that commit. Its content was overwritten in7b59014("add run scripts"), and without it--magma-outputcannot read thePredSpecDBmagma_tree.hdf5written by the currentrun_magma.py(ValueError: Empty list to process!). The CLI flags are unchanged. The mode without--magma-output, used by the ICEBERG and MARASON run scripts, gives identical output with either version of the file (checked on a PredSpecDB withpred_<spec>names,--add-raw, with--num-workers 0and4). One behavioural difference: when no entries match, the restored version writes an empty output file and prints a message instead of raising.metric=Nonedefault in GLACIERJointModel.lr_scheduler_step. Lightning 2.x calls the hook as(scheduler, metric); this is the convention the other models in the repository already use.tests/test_glacier_training.py(CPU, about 6 s in total including imports):test_add_dag_intens_reads_magma_predspecdbrunsrun_magma.py,01_assign_subformulae.pyandadd_dag_intens.py --magma-outputin-process on a four-molecule dataset in a temporary directory, and checks that every spectrum yields a<spec>_collision <ce>tree withfragsandraw_specthat the GLACIERIntenDatasetloads.test_glacier_fast_dev_run_cpurunspl.Trainer(fast_dev_run=True, accelerator="cpu")on a small GLACIERJointModel, which exerciseslr_scheduler_step.Testing
main, both new tests fail for the intended reasons (no output entries;TypeError: JointModel.lr_scheduler_step() missing 1 required positional argument: 'metric'). On this branch both pass.pytest tests/test_joint_model.py tests/test_imports.py tests/test_glacier_training.py: 24 passed, 3 xfailed (the same 22 passed / 3 xfailed as onmain, plus the two new tests). We did not run the rest of the suite.[M+H]+, simulation-challenge rows with integer collision energy and 8-40 heavy atoms; 320/40/40 by MassSpecGym fold; we can attach the small builder script):run_magma.sh,add_dag_intens.py --magma-output, thenglacier/train_joint.pywith the arguments ofconfigs/glacier/joint_train_nist20.yamlat--batch-size 8 --max-epochs 1. One epoch completes on a single RTX 2070 Super (8 GB), about 1.4 it/s, val_loss 0.876, followed by the test stage. Environment: Python 3.11.15, torch 2.6.0+cu124, pytorch-lightning 2.6.6 fromuv sync --extra cu124. We have not run a full-length training.