Document ChEMBL3D and GEOM checkpoints with shared inference quickstart
Browse files- README.md +148 -62
- geom/explicit_h/manifest.json +4 -0
- geom/explicit_h/runtime/README.md +24 -0
README.md
CHANGED
|
@@ -5,93 +5,179 @@ tags:
|
|
| 5 |
- molecular-generation
|
| 6 |
- flow-matching
|
| 7 |
- chembl3d
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
# Morph
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
| --- | --- | --- |
|
| 18 |
-
| Explicit hydrogens | 200, 300, 400 | [chembl3d/explicit_h](chembl3d/explicit_h) |
|
| 19 |
-
| Implicit hydrogens (heavy-atom graphs) | 100, 200, 300 | [chembl3d/implicit_h](chembl3d/implicit_h) |
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
- `distributions.json`: a readable export of the same statistics.
|
| 33 |
-
- `config.yaml`: portable sampling config with dataset loading disabled.
|
| 34 |
-
- `training_config.yaml`: the original Hydra training configuration, for provenance.
|
| 35 |
-
- `runtime/`: frozen source/configs and dependency specifications for this run.
|
| 36 |
-
- `metadata.json`: epochs, optimizer steps, original filenames, and SHA-256 hashes.
|
| 37 |
-
- `validation.json`: strict checkpoint loading, current/EMA forward checks and
|
| 38 |
-
a one-molecule end-to-end sampling check. This is a functionality check, not
|
| 39 |
-
a validity benchmark.
|
| 40 |
|
| 41 |
-
##
|
| 42 |
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
```bash
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
```
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
```bash
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
--num-mols 64 --batch-size 16 --device cuda --output implicit_h.sdf
|
| 61 |
```
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
```bash
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
```
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
|
| 80 |
## Hydrogen handling and training data
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
-
The
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
and coordinate normalization were recomputed for the heavy-atom representation.
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
- molecular-generation
|
| 6 |
- flow-matching
|
| 7 |
- chembl3d
|
| 8 |
+
- geom-drugs
|
| 9 |
+
- 3d
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Morph: 3D molecular generation
|
| 13 |
|
| 14 |
+
Unconditional molecular generation checkpoints trained on **ChEMBL3D** and
|
| 15 |
+
**GEOM-Drugs**, with the configurations, vocabularies and training distributions
|
| 16 |
+
needed for inference. No training dataset is required to load a model or generate
|
| 17 |
+
molecules.
|
| 18 |
|
| 19 |
+
## Available checkpoints
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
| Dataset | Model name | Hydrogen representation | Completed epochs | Files |
|
| 22 |
+
| --- | --- | --- | --- | --- |
|
| 23 |
+
| ChEMBL3D | `chembl3d-explicit-h` | Explicit H atoms | 200, 300, 400 | [Bundle](https://huggingface.co/maltefranke/morph/tree/main/chembl3d/explicit_h) |
|
| 24 |
+
| ChEMBL3D | `chembl3d-implicit-h` | Heavy atoms; implicit H | 100, 200, 300 | [Bundle](https://huggingface.co/maltefranke/morph/tree/main/chembl3d/implicit_h) |
|
| 25 |
+
| GEOM-Drugs | `geom-explicit-h` | Explicit H atoms | 50 | [Bundle](https://huggingface.co/maltefranke/morph/tree/main/geom/explicit_h) |
|
| 26 |
|
| 27 |
+
Epoch numbers count **completed training epochs**: `epoch_050.ckpt` means 50
|
| 28 |
+
completed epochs and stores the zero-based Lightning counter `epoch=49`.
|
| 29 |
+
Checkpoints are original training files containing current weights, EMA weights
|
| 30 |
+
and optimizer state.
|
| 31 |
|
| 32 |
+
The [catalog](https://huggingface.co/maltefranke/morph/blob/main/catalog.json)
|
| 33 |
+
is the source of truth for available model names and epochs. Each entry pins an
|
| 34 |
+
immutable release revision so its weights and supporting files stay together.
|
| 35 |
+
New catalog entries are discovered without updating the Python package.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
## Install and authenticate
|
| 38 |
|
| 39 |
+
The runtime bundled with GEOM includes the shared inference interface and catalog
|
| 40 |
+
discovery for all models in the table. Install it in a Python environment:
|
| 41 |
|
| 42 |
```bash
|
| 43 |
+
python -m pip install 'huggingface_hub>=1.0,<2'
|
| 44 |
+
hf auth login
|
| 45 |
+
hf download maltefranke/morph --local-dir morph-runtime \
|
| 46 |
+
--include 'geom/explicit_h/runtime/*'
|
| 47 |
+
python -m pip install ./morph-runtime/geom/explicit_h/runtime
|
| 48 |
+
morph models list
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Authentication requires an account with access to this model repository.
|
| 52 |
+
Python >=3.11 and a compatible PyTorch 2.9 installation are required; CUDA
|
| 53 |
+
generation needs a CUDA-capable PyTorch build. Dependency constraints and tested
|
| 54 |
+
versions are included in the runtime. An existing Morph environment with catalog
|
| 55 |
+
discovery can use the examples directly. On a cluster, run model loading and
|
| 56 |
+
generation inside a compute allocation.
|
| 57 |
+
|
| 58 |
+
## Load and generate from Python
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
from morph.inference import load_pretrained
|
| 62 |
+
|
| 63 |
+
model = load_pretrained("geom-explicit-h", epoch=50, device="cuda")
|
| 64 |
+
|
| 65 |
+
trajectories, validity, vocab, coordinate_std = model.generate(
|
| 66 |
+
n_mols=64,
|
| 67 |
+
batch_size=16,
|
| 68 |
+
seed=42,
|
| 69 |
+
return_traj=False,
|
| 70 |
+
)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
Use `device="cpu"` for CPU inference. The same interface loads ChEMBL3D:
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
model = load_pretrained("chembl3d-explicit-h", epoch=400, device="cuda")
|
| 77 |
+
# Or choose the heavy-atom model:
|
| 78 |
+
model = load_pretrained("chembl3d-implicit-h", epoch=300, device="cuda")
|
| 79 |
```
|
| 80 |
|
| 81 |
+
Loading downloads only the selected checkpoint and its six required asset files,
|
| 82 |
+
then reuses the Hugging Face cache. Each checkpoint is approximately 510 MB.
|
| 83 |
+
Omitting `epoch` selects the latest published epoch for the chosen model.
|
| 84 |
+
|
| 85 |
+
**EMA weights are used by default.** The inference loader constructs one network
|
| 86 |
+
and loads only the selected weights; the unselected network and optimizer tensors
|
| 87 |
+
are not materialized from the memory-mapped checkpoint. To select current
|
| 88 |
+
training weights, pass `use_ema=False` to `load_pretrained`.
|
| 89 |
+
|
| 90 |
+
Generation defaults to 100 integration steps. Each attempt remains in the returned
|
| 91 |
+
lists, including invalid molecules. `trajectories[i][-1]` is its final graph and
|
| 92 |
+
`validity[i]` is its RDKit validity result. Pass `return_traj=True` to retain all
|
| 93 |
+
integration frames. Returned coordinates are already in **Angstrom**; do not
|
| 94 |
+
multiply them by `coordinate_std` again.
|
| 95 |
+
|
| 96 |
+
## CLI and downloads
|
| 97 |
+
|
| 98 |
+
Generate GEOM-Drugs molecules and save valid structures to SDF:
|
| 99 |
|
| 100 |
```bash
|
| 101 |
+
morph generate --model geom-explicit-h --epoch 50 \
|
| 102 |
+
--device cuda --batch 64 --batch-size 16 --output geom-e50.sdf
|
|
|
|
| 103 |
```
|
| 104 |
|
| 105 |
+
`--batch` is the total number of generation attempts. Add `--save-trajs` to save
|
| 106 |
+
trajectories and validity flags beside the SDF. `--no-ema` selects current
|
| 107 |
+
weights, and `--steps` and `--seed` control sampling.
|
| 108 |
+
|
| 109 |
+
Download a portable bundle without loading the model:
|
| 110 |
|
| 111 |
```bash
|
| 112 |
+
morph models download geom-explicit-h --epoch 50 --local-dir morph-models
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
Load that local bundle without network access or catalog lookup:
|
| 116 |
+
|
| 117 |
+
```python
|
| 118 |
+
model = load_pretrained(
|
| 119 |
+
weights_dir="morph-models/geom/explicit_h",
|
| 120 |
+
epoch=50,
|
| 121 |
+
device="cuda",
|
| 122 |
+
)
|
| 123 |
```
|
| 124 |
|
| 125 |
+
Use another model name from the table for ChEMBL3D. The interface also accepts
|
| 126 |
+
direct Hub repository IDs with `subfolder` and `revision`. Pass `cache_dir` to
|
| 127 |
+
choose a cache location, or `local_files_only=True` to load a previously cached
|
| 128 |
+
release without network access. The corresponding CLI options are `--cache-dir`
|
| 129 |
+
and `--offline`.
|
| 130 |
|
| 131 |
+
The root `sample.py` remains available as the archived ChEMBL3D sampling entry
|
| 132 |
+
point with its corresponding bundled runtimes. The shared interface above
|
| 133 |
+
supports all three published model variants.
|
| 134 |
|
| 135 |
## Hydrogen handling and training data
|
| 136 |
|
| 137 |
+
| Dataset | Training filter | Representation |
|
| 138 |
+
| --- | --- | --- |
|
| 139 |
+
| ChEMBL3D | At most 100 total atoms, including H before hydrogen removal | Explicit-H and implicit-H variants |
|
| 140 |
+
| GEOM-Drugs | At most 72 total atoms, including H | Explicit-H variant |
|
| 141 |
+
|
| 142 |
+
Both ChEMBL3D variants use the same split membership: 1,474,008 training,
|
| 143 |
+
184,295 validation and 184,242 test molecules. The implicit-H model predicts
|
| 144 |
+
heavy atoms, bonds and formal charges; RDKit infers hydrogens during conversion
|
| 145 |
+
and validity checking. Its geometry statistics and coordinate normalization were
|
| 146 |
+
recomputed for the heavy-atom representation.
|
| 147 |
|
| 148 |
+
The GEOM-Drugs epoch 50 checkpoint was obtained by resuming the best checkpoint
|
| 149 |
+
after 48 completed epochs. The resumed run validates every epoch and retains
|
| 150 |
+
checkpoints every fifth epoch. Only the epochs listed in the catalog have been
|
| 151 |
+
published here.
|
|
|
|
| 152 |
|
| 153 |
+
Explicit-H models generate H atoms as graph vertices. Every model uses its own
|
| 154 |
+
ordered vocabularies, distributions and saved configuration; keep those files
|
| 155 |
+
together. The training atom limits describe dataset filtering and do not impose
|
| 156 |
+
a hard atom-count limit during generation.
|
| 157 |
|
| 158 |
+
## Bundle contents and verification
|
| 159 |
+
|
| 160 |
+
Each model directory contains:
|
| 161 |
+
|
| 162 |
+
- `epoch_NNN.ckpt`: the published original training checkpoints.
|
| 163 |
+
- `config.yaml`: portable inference configuration with dataset loading disabled.
|
| 164 |
+
- `atom_tokens.txt`, `edge_tokens.txt`, `charge_tokens.txt`: ordered vocabularies.
|
| 165 |
+
- `distributions.pt`: original training statistics, including atom counts,
|
| 166 |
+
coordinate scale, type frequencies and geometry histograms.
|
| 167 |
+
- `distributions.json`: a readable export of those statistics.
|
| 168 |
+
- `metadata.json`: dataset, hydrogen mode, epochs, optimizer steps, original
|
| 169 |
+
filenames and checkpoint SHA-256 hashes.
|
| 170 |
+
- `training_config.yaml`: the original training configuration for provenance.
|
| 171 |
+
- `runtime/`: archived source, configs and dependency specifications.
|
| 172 |
+
- `validation.json`: results of checkpoint loading and sampling checks.
|
| 173 |
+
|
| 174 |
+
The published bundles were checked for strict current/EMA weight loading and
|
| 175 |
+
end-to-end sampling. These are functionality checks, not validity benchmarks.
|
| 176 |
+
The GEOM release also passed remote file-size and hash verification.
|
| 177 |
+
|
| 178 |
+
The [ChEMBL3D release manifest](https://huggingface.co/maltefranke/morph/blob/ab9bea92f499f03450ebc99459fce04461504a41/manifest.json)
|
| 179 |
+
describes the original ChEMBL3D release at its pinned revision, including its
|
| 180 |
+
historical model card. GEOM has its own
|
| 181 |
+
[bundle manifest](https://huggingface.co/maltefranke/morph/blob/b839af108eaade757a5d2d668d05498e8c733c1e/geom/explicit_h/manifest.json).
|
| 182 |
+
Original training configs contain historical cluster paths; use `config.yaml`
|
| 183 |
+
through the inference loader for portable generation.
|
geom/explicit_h/manifest.json
CHANGED
|
@@ -598,5 +598,9 @@
|
|
| 598 |
"validation.json": {
|
| 599 |
"bytes": 294,
|
| 600 |
"sha256": "5acbbb78be426e03abd58c3dc062b30b000e91e815c329dfa7f1422c9866b740"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 601 |
}
|
| 602 |
}
|
|
|
|
| 598 |
"validation.json": {
|
| 599 |
"bytes": 294,
|
| 600 |
"sha256": "5acbbb78be426e03abd58c3dc062b30b000e91e815c329dfa7f1422c9866b740"
|
| 601 |
+
},
|
| 602 |
+
"runtime/README.md": {
|
| 603 |
+
"bytes": 1041,
|
| 604 |
+
"sha256": "7e32e04cce313c7faad9a3170ab009591aa327a900ee67f980889b7d7e4c82ba"
|
| 605 |
}
|
| 606 |
}
|
geom/explicit_h/runtime/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Morph inference runtime
|
| 2 |
+
|
| 3 |
+
This source snapshot accompanies the GEOM-Drugs explicit-H release and includes
|
| 4 |
+
the shared inference loader for the ChEMBL3D and GEOM-Drugs checkpoints published
|
| 5 |
+
in `maltefranke/morph`.
|
| 6 |
+
|
| 7 |
+
Install this directory with `python -m pip install .`. Python >=3.11 and a
|
| 8 |
+
compatible PyTorch 2.9 installation are required. Dependency constraints are in
|
| 9 |
+
`pyproject.toml`; `requirements-tested.txt` records the versions used to validate
|
| 10 |
+
the GEOM release.
|
| 11 |
+
|
| 12 |
+
```python
|
| 13 |
+
from morph.inference import load_pretrained
|
| 14 |
+
|
| 15 |
+
model = load_pretrained("geom-explicit-h", epoch=50, device="cuda")
|
| 16 |
+
trajectories, validity, vocab, coordinate_std = model.generate(n_mols=16)
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
Use `device="cpu"` for CPU inference. Run `morph models list` to discover all
|
| 20 |
+
published model names and epochs. The loader fetches a checkpoint and its
|
| 21 |
+
matching configuration, vocabularies and distributions; no dataset is required.
|
| 22 |
+
|
| 23 |
+
See the [model card](https://huggingface.co/maltefranke/morph) for installation,
|
| 24 |
+
sampling, hydrogen handling and checkpoint provenance.
|