Skip to content

2026 model update - #28

Open
rodvrees wants to merge 6 commits into
feat/core-trainingfrom
feat/transformer-model
Open

rodvrees wants to merge 6 commits into
feat/core-trainingfrom
feat/transformer-model

Conversation

@rodvrees

Copy link
Copy Markdown
Member

No description provided.

rodvrees and others added 6 commits October 29, 2026 18:31
A 4-layer transformer trunk replaces the convolutional atom/diatom branches
when `use_transformer_trunk` is set: a learned charge embedding is prepended
to the sequence as a register token that every residue attends to, the
pre-norm self-attention blocks carry a learned relative-distance and
terminus-proximity bias, and a learned-query attention pooling reads out.

Training options used by the new model: global-feature and target
standardisation (statistics stored in the checkpoint), stochastic weight
averaging, OneCycle, weight decay and precision. Early stopping is now off by
default (`patience` None) as it fired prematurely, and the normal/xavier/
kaiming initialisers get explicit parameters instead of PyTorch's defaults.
Several further options are added off by default (FlexTrunk, per-charge and
heteroscedastic heads, charge-balanced sampling, mixup, sibling and ranking
losses).

`predict()` now defaults to a GPU when one is available, and reads each
checkpoint once.

`finetune()` on a transformer-trunk or FlexTrunk backbone used to raise
AttributeError. IM2DeepTransfer now delegates to the backbone, so the trunk,
the register token and both standardisation scalers are applied and stay
fixed, and BackboneFreeze covers the trunk. The Weights & Biases best-MAE log
call is restricted to rank zero.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
RegressionCCSCalibration fits `target = slope * source + intercept` per
charge, for models whose training labels were harmonised with a regression
rather than a shift. Charges with too little overlap fall back to one fit
across all charges, and to an identity transform when nothing overlaps, so
calibration never fails on a dataset the reference does not cover.

Both calibrations now record, per charge, how many anchors matched, whether
the charge fell back to the all-charge fit, and the residual spread, exposed
through `stats_for_charge()`, so rescoring can judge how far to trust a run's
calibrated CCS.

Declares the scikit-learn dependency the regression uses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
IM2DeepUni.ckpt is now the 2026 transformer model: 1.05M parameters, trained
on a 4.83M-precursor collated set. It records its own architecture and
featurisation (72 global features, corrected positional deltas), which
predict() and finetune() read back. The checkpoint is stripped to weights and
config, and its recorded config carries no Weights & Biases project or worker
count, since finetune() copies the backbone's config into every new run.

The default calibration reference moves with it:
reference_ccs_2026.csv.gz (1,054,960 precursors sampled from the model's
training set) replaces reference_ccs.csv.gz as DEFAULT_REFERENCE_DATASET_PATH.
The shift is `observed - reference` CCS, so the reference has to sit on the
model's scale, and the old one is 14-25 A^2 below it. On the held-out set the
calibrated MAE is 6.16 A^2 against the new reference, 8.97 for the previous
model and reference, and 18.09 for the new model with the old reference.

New tests pin the pairing: the recorded config, the reference format, the
model/reference scale agreement per charge, calibration recovering a known
shift through the default reference, and fine-tuning from the bundled model.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Changelog entries for the transformer trunk, the training options, the
regression calibration, the replaced model and reference (with measured
numbers), the UNIMOD-accession notation of the new reference, and the
finetune fix. The README gains a note on the reference's scale and notation,
and the training guide drops the claim that the bundled models use the legacy
positional encoding.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The CI lint job runs `ruff format --check`, which failed on transformer_trunk.py
and _model_ops.py. Whitespace and line wrapping only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`ty check im2deep` reported 35 diagnostics, 9 of them already present on
feat/core-training. Torch buffers, Lightning's trainer API and `Dataset`
subclasses are not typed precisely enough for `ty`, so those lines get
rule-specific `# ty: ignore[...]` comments, the convention already used in
callbacks.py. The one real fix is `int(cast(int, charge))` in the regression
calibration, matching the rest of that file. A stale blanket `type: ignore`
that `ty` flagged is removed.

The wandb logger tests that enable wandb now skip when it is not installed:
the dev dependency group does not include it, so they failed in CI (also on
feat/core-training) as soon as the lint and typecheck jobs let the test job run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rodvrees
rodvrees added this pull request to stack #30 October 29, 2026 20:46

This branch has not been deployed

No deployments
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