maltefranke commited on
Commit
da1c241
·
verified ·
1 Parent(s): 377e8b5

Document ChEMBL3D and GEOM checkpoints with shared inference quickstart

Browse files
README.md CHANGED
@@ -5,93 +5,179 @@ tags:
5
  - molecular-generation
6
  - flow-matching
7
  - chembl3d
 
 
8
  ---
9
 
10
- # Morph ChEMBL3D checkpoints
11
 
12
- Six checkpoints for unconditional 3D molecular generation, with matching
13
- vocabularies, training distributions, portable inference configurations and
14
- the frozen Morph runtime from each training run.
 
15
 
16
- | Variant | Completed training epochs | Directory |
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
- The `epoch_200.ckpt` name means **200 completed epochs**. The original Lightning
22
- checkpoint stores `epoch=199`. Files are byte-for-byte copies of the selected
23
- training checkpoints, including current weights, EMA weights, and optimizer
24
- state. Sampling uses EMA weights by default.
 
25
 
26
- Each variant contains:
 
 
 
27
 
28
- - `epoch_NNN.ckpt`: the three selected checkpoints.
29
- - `atom_tokens.txt`, `edge_tokens.txt`, `charge_tokens.txt`: ordered vocabularies.
30
- - `distributions.pt`: the original training statistics, including atom counts,
31
- type frequencies, coordinate scale, and geometry histograms.
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
- ## Download and generate
42
 
43
- Download the variant you need (authenticate with `hf auth login` if required):
 
44
 
45
  ```bash
46
- hf download maltefranke/morph --local-dir morph-models \
47
- --include 'chembl3d/implicit_h/*' --include sample.py --include README.md --include manifest.json
48
- cd morph-models
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ```
50
 
51
- Install that variant's runtime in an environment with Python >=3.11 and a
52
- compatible PyTorch 2.9 installation. A CUDA-capable PyTorch build is needed to
53
- use `--device cuda`. The tested package versions are recorded in
54
- `runtime/requirements-tested.txt`; the runtime's `pyproject.toml` specifies the
55
- dependency constraints.
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  ```bash
58
- python -m pip install ./chembl3d/implicit_h/runtime
59
- python sample.py --variant implicit_h --epoch 300 \
60
- --num-mols 64 --batch-size 16 --device cuda --output implicit_h.sdf
61
  ```
62
 
63
- For explicit hydrogens, download `chembl3d/explicit_h/*` instead, install its
64
- runtime, and run:
 
 
 
65
 
66
  ```bash
67
- python sample.py --variant explicit_h --epoch 400 \
68
- --num-mols 64 --batch-size 16 --device cuda --output explicit_h.sdf
 
 
 
 
 
 
 
 
 
69
  ```
70
 
71
- The script imports the matching bundled source automatically. Each invocation
72
- uses one variant in a fresh process. No ChEMBL3D dataset or cluster paths are
73
- needed. `--device cpu` is supported, but use a compute worker for substantial
74
- sampling. Compilation is disabled by default; attention uses PyTorch SDPA.
 
75
 
76
- Generated coordinates are in Angstrom. The SDF contains valid molecules; the
77
- adjacent JSON records every attempted molecule and its validity result, including
78
- failures. Generation uses 100 integration steps and seed 42 by default.
79
 
80
  ## Hydrogen handling and training data
81
 
82
- Both variants use the same split membership: 1,474,008 training, 184,295 validation,
83
- and 184,242 test molecules. The dataset was filtered to **at most 100 total atoms,
84
- including hydrogens**, before removing hydrogens for the implicit variant.
 
 
 
 
 
 
 
85
 
86
- The explicit variant predicts H atoms as graph vertices. The implicit variant
87
- predicts heavy atoms, bonds and formal charges; RDKit infers hydrogens during
88
- conversion and validity checking. Its bundled runtime preserves that behavior.
89
- Do not mix vocabularies or distributions between variants. Geometry statistics
90
- and coordinate normalization were recomputed for the heavy-atom representation.
91
 
92
- The 100-atom cap describes the training filter, not a hard limit imposed on
93
- generated molecules. Sample counts follow the saved training prior settings.
 
 
94
 
95
- `manifest.json` lists file sizes and SHA-256 hashes. The original training configs
96
- contain historical cluster paths and should be treated as provenance; use
97
- `sample.py` with the portable `config.yaml` for inference.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.