Skip to content

Fix GLACIER training path: restore PredSpecDB-aware add_dag_intens.py, Lightning 2.x scheduler hook, add smoke test - #44

Merged
rogerwwww merged 4 commits into
coleygroup:mainfrom
roy7:fix-glacier-training-pr
Sep 21, 2026
Merged

rogerwwww merged 4 commits into
coleygroup:mainfrom
roy7:fix-glacier-training-pr

Conversation

@roy7

@roy7 roy7 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Disclosure: this pull request was prepared by Claude Fable 5.1 (Anthropic's AI coding assistant), working in Jonathan Roy's environment at his direction. The reproduction, git-history analysis and fixes were done by the AI on a clean clone; Jonathan reviewed the findings and is posting this from his account.

Fixes #43

On current main (67ba0f2), the documented GLACIER training workflow stops at run_scripts/glacier/add_inten.sh and, once that is fixed, again after the first optimizer step. Details and reproduction are in #43.

Commits

  1. Restore PredSpecDB-aware add_dag_intens.py (from 02e6ade). This restores RuiXiWangTW's fix "fix magma inten" (02e6ade) for data_scripts/dag/add_dag_intens.py; the file is byte-identical to that commit. Its content was overwritten in 7b59014 ("add run scripts"), and without it --magma-output cannot read the PredSpecDB magma_tree.hdf5 written by the current run_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 with pred_<spec> names, --add-raw, with --num-workers 0 and 4). One behavioural difference: when no entries match, the restored version writes an empty output file and prints a message instead of raising.
  2. metric=None default in GLACIER JointModel.lr_scheduler_step. Lightning 2.x calls the hook as (scheduler, metric); this is the convention the other models in the repository already use.
  3. Smoke tests, tests/test_glacier_training.py (CPU, about 6 s in total including imports):
    • test_add_dag_intens_reads_magma_predspecdb runs run_magma.py, 01_assign_subformulae.py and add_dag_intens.py --magma-output in-process on a four-molecule dataset in a temporary directory, and checks that every spectrum yields a <spec>_collision <ce> tree with frags and raw_spec that the GLACIER IntenDataset loads.
    • test_glacier_fast_dev_run_cpu runs pl.Trainer(fast_dev_run=True, accelerator="cpu") on a small GLACIER JointModel, which exercises lr_scheduler_step.

Testing

  • With the versions of the two fixed files from 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 on main, plus the two new tests). We did not run the rest of the suite.
  • End to end on a 400-spectrum MassSpecGym 1.5 subset that we constructed ([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, then glacier/train_joint.py with the arguments of configs/glacier/joint_train_nist20.yaml at --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 from uv sync --extra cu124. We have not run a full-length training.

roy7 and others added 3 commits September 20, 2026 22:55
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>
@rogerwwww
rogerwwww merged commit 6efdbd3 into coleygroup:main Sep 21, 2026
1 check passed
@rogerwwww

Copy link
Copy Markdown
Collaborator

Thank you, Jonathan. Merged.

@roy7

roy7 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

My pleasure. Thanks for the quick review!

@roy7
roy7 deleted the fix-glacier-training-pr branch September 21, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants