lhallee commited on
Commit
ccefb84
·
verified ·
1 Parent(s): c8be7ff

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +163 -163
README.md CHANGED
@@ -1,163 +1,163 @@
1
- ---
2
- library_name: transformers
3
- tags: []
4
- ---
5
-
6
- # NOTE
7
- The GitHub with the implementation and requirements can be found [here](https://github.com/Synthyra/FastPLMs.git).
8
-
9
- # Boltz2 AutoModel (Inference-only)
10
- This is a barebones Huggingface `AutoModel` compatible implementation of Boltz2 focused on fast inference workflows.
11
-
12
- The implementation is located in `fastplms/boltz/` and exposes:
13
- - `Boltz2Config`
14
- - `Boltz2Model`
15
- - `predict_structure(amino_acid_sequence, ...)`
16
- - `save_as_cif(structure_output, output_path, ...)`
17
-
18
- ## Design goals
19
- - Inference-only (no training hooks, no Lightning trainer usage).
20
- - Lightweight runtime around `torch` + `transformers` (plus `numpy`).
21
- - AutoModel remote-code compatibility via `trust_remote_code=True`.
22
- - Confidence outputs included in prediction outputs (`plddt`, `ptm`, `iptm`, and derived confidence score when available).
23
-
24
- ## Runtime note
25
- This implementation is self-contained inside `fastplms/boltz/` and does not require
26
- the original cloned `boltz` package at runtime.
27
-
28
- ## Use with transformers
29
-
30
- ### Load from an exported directory
31
- ```python
32
- import torch
33
- from transformers import AutoModel
34
-
35
- model = AutoModel.from_pretrained(
36
- "Synthyra/Boltz2",
37
- trust_remote_code=True,
38
- dtype=torch.float32,
39
- ).eval()
40
- ```
41
-
42
- ### Predict structure from sequence
43
- ```python
44
- out = model.predict_structure(
45
- amino_acid_sequence="MSTNPKPQRKTKRNTNRRPQDVKFPGG",
46
- recycling_steps=3,
47
- num_sampling_steps=200,
48
- diffusion_samples=1,
49
- )
50
-
51
- print(out.sample_atom_coords.shape)
52
- print(None if out.plddt is None else out.plddt.shape)
53
- ```
54
-
55
- ### Save CIF
56
- ```python
57
- model.save_as_cif(out, "prediction.cif")
58
- ```
59
-
60
- ## Convert Boltz checkpoint to HF export
61
- Use:
62
-
63
- ```bash
64
- py -m fastplms.boltz.get_weights --checkpoint_path fastplms/boltz/weights/boltz2_conf.ckpt --output_dir boltz2_automodel_export
65
- ```
66
-
67
- The export directory contains:
68
- - `config.json`
69
- - `pytorch_model.bin`
70
- - `modeling_boltz2.py`
71
- - `minimal_featurizer.py`
72
- - `minimal_structures.py`
73
- - `cif_writer.py`
74
- - `vb_*.py` (self-contained vendored Boltz2 inference modules/constants)
75
-
76
- ## Output object fields
77
- `predict_structure(...)` returns `Boltz2StructureOutput` with:
78
- - `sample_atom_coords`
79
- - `atom_pad_mask`
80
- - `plddt`
81
- - `complex_plddt`
82
- - `ptm`
83
- - `iptm`
84
- - `confidence_score` (derived when available)
85
- - `raw_output`
86
-
87
- ## Limitations
88
- - Current featurization path is protein-only and minimal.
89
- - This implementation is meant for practical inference and export workflows, not full Boltz training parity.
90
-
91
- ## Docker-first compliance testing
92
-
93
- Build the container at repo root:
94
-
95
- ```bash
96
- docker build -t fastplms-test -f Dockerfile .
97
- ```
98
-
99
- Launch a test shell:
100
-
101
- ```bash
102
- docker run --rm --gpus all -it -v ${PWD}:/workspace fastplms-test bash
103
- ```
104
-
105
- Inside the container, run Boltz2 compliance against pip `boltz`:
106
-
107
- ```bash
108
- python -m testing.run_boltz2_compliance --device cuda --dtype float32 --seed 42 --num-sequences 3 --recycling-steps 3 --num-sampling-steps 200 --diffusion-samples 1 --pass-coord-metric aligned --write-cif-artifacts
109
- ```
110
-
111
- Artifacts are written to `testing/results/<timestamp>/boltz2_compliance/` by default:
112
- - `metrics.json`
113
- - `metrics.csv`
114
- - `summary.txt`
115
- - `structures/seq_<idx>/ours_seq<idx>.cif`
116
- - `structures/seq_<idx>/ref_seq<idx>.cif`
117
-
118
- Coordinate metrics now include both raw and rigid-aligned variants:
119
- - `coord_mae`, `coord_rmse`, `coord_max_abs` (raw frame-dependent deltas)
120
- - `coord_mae_aligned`, `coord_rmse_aligned`, `coord_max_abs_aligned` (Kabsch aligned)
121
- - `pairwise_dist_mae` (frame-invariant pairwise-distance delta)
122
-
123
- Pass/fail uses `--pass-coord-metric aligned` by default. Set `--pass-coord-metric raw` to use the raw coordinate thresholds.
124
-
125
- ## Citations
126
-
127
- ```bibtex
128
- @misc{FastPLMs,
129
- author={Hallee, Logan and Bichara, David and Gleghorn, Jason P.},
130
- title={FastPLMs: Fast, efficient, protein language model inference from Huggingface AutoModel.},
131
- year={2024},
132
- url={https://huggingface.co/Synthyra/ESMplusplus_small},
133
- DOI={10.57967/hf/3726},
134
- publisher={Hugging Face}
135
- }
136
- ```
137
-
138
- ```bibtex
139
- @article{passaro2025boltz2,
140
- title={Boltz-2: Exploring the Frontiers of Biomolecular Prediction},
141
- author={Passaro, Saro and Corso, Gabriele and Wohlwend, Jeremy and Reveiz, Mateo and Bordes, Florian and Wicky, Basile and Dayan, Peter and Jing, Bowen},
142
- journal={bioRxiv},
143
- year={2025}
144
- }
145
- ```
146
-
147
- ```bibtex
148
- @article{wohlwend2024boltz1,
149
- title={Boltz-1: Democratizing Biomolecular Interaction Modeling},
150
- author={Wohlwend, Jeremy and Corso, Gabriele and Passaro, Saro and Reveiz, Mateo and Leidal, Ken and Swanson, Wojtek and Kher, Gilmer and Lember, Tommi and Jaakkola, Tommi},
151
- journal={bioRxiv},
152
- year={2024}
153
- }
154
- ```
155
-
156
- ```bibtex
157
- @inproceedings{paszke2019pytorch,
158
- title={PyTorch: An Imperative Style, High-Performance Deep Learning Library},
159
- author={Paszke, Adam and Gross, Sam and Massa, Francisco and Lerer, Adam and Bradbury, James and Chanan, Gregory and Killeen, Trevor and Lin, Zeming and Gimelshein, Natalia and Antiga, Luca and Desmaison, Alban and K{\"o}pf, Andreas and Yang, Edward and DeVito, Zach and Raison, Martin and Tejani, Alykhan and Chilamkurthy, Sasank and Steiner, Benoit and Fang, Lu and Bai, Junjie and Chintala, Soumith},
160
- booktitle={Advances in Neural Information Processing Systems 32},
161
- year={2019}
162
- }
163
- ```
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # NOTE
7
+ The GitHub with the implementation and requirements can be found [here](https://github.com/Synthyra/FastPLMs.git).
8
+
9
+ # Boltz2 AutoModel (Inference-only)
10
+ This is a barebones Huggingface `AutoModel` compatible implementation of Boltz2 focused on fast inference workflows.
11
+
12
+ The implementation is located in `fastplms/boltz/` and exposes:
13
+ - `Boltz2Config`
14
+ - `Boltz2Model`
15
+ - `predict_structure(amino_acid_sequence, ...)`
16
+ - `save_as_cif(structure_output, output_path, ...)`
17
+
18
+ ## Design goals
19
+ - Inference-only (no training hooks, no Lightning trainer usage).
20
+ - Lightweight runtime around `torch` + `transformers` (plus `numpy`).
21
+ - AutoModel remote-code compatibility via `trust_remote_code=True`.
22
+ - Confidence outputs included in prediction outputs (`plddt`, `ptm`, `iptm`, and derived confidence score when available).
23
+
24
+ ## Runtime note
25
+ This implementation is self-contained inside `fastplms/boltz/` and does not require
26
+ the original cloned `boltz` package at runtime.
27
+
28
+ ## Use with transformers
29
+
30
+ ### Load from an exported directory
31
+ ```python
32
+ import torch
33
+ from transformers import AutoModel
34
+
35
+ model = AutoModel.from_pretrained(
36
+ "Synthyra/Boltz2",
37
+ trust_remote_code=True,
38
+ dtype=torch.float32,
39
+ ).eval()
40
+ ```
41
+
42
+ ### Predict structure from sequence
43
+ ```python
44
+ out = model.predict_structure(
45
+ amino_acid_sequence="MSTNPKPQRKTKRNTNRRPQDVKFPGG",
46
+ recycling_steps=3,
47
+ num_sampling_steps=200,
48
+ diffusion_samples=1,
49
+ )
50
+
51
+ print(out.sample_atom_coords.shape)
52
+ print(None if out.plddt is None else out.plddt.shape)
53
+ ```
54
+
55
+ ### Save CIF
56
+ ```python
57
+ model.save_as_cif(out, "prediction.cif")
58
+ ```
59
+
60
+ ## Convert Boltz checkpoint to HF export
61
+ Use:
62
+
63
+ ```bash
64
+ py -m fastplms.boltz.get_weights --checkpoint_path fastplms/boltz/weights/boltz2_conf.ckpt --output_dir boltz2_automodel_export
65
+ ```
66
+
67
+ The export directory contains:
68
+ - `config.json`
69
+ - `pytorch_model.bin`
70
+ - `modeling_boltz2.py`
71
+ - `minimal_featurizer.py`
72
+ - `minimal_structures.py`
73
+ - `cif_writer.py`
74
+ - `vb_*.py` (self-contained vendored Boltz2 inference modules/constants)
75
+
76
+ ## Output object fields
77
+ `predict_structure(...)` returns `Boltz2StructureOutput` with:
78
+ - `sample_atom_coords`
79
+ - `atom_pad_mask`
80
+ - `plddt`
81
+ - `complex_plddt`
82
+ - `ptm`
83
+ - `iptm`
84
+ - `confidence_score` (derived when available)
85
+ - `raw_output`
86
+
87
+ ## Limitations
88
+ - Current featurization path is protein-only and minimal.
89
+ - This implementation is meant for practical inference and export workflows, not full Boltz training parity.
90
+
91
+ ## Docker-first compliance testing
92
+
93
+ Build the container at repo root:
94
+
95
+ ```bash
96
+ docker build -t fastplms-test -f Dockerfile .
97
+ ```
98
+
99
+ Launch a test shell:
100
+
101
+ ```bash
102
+ docker run --rm --gpus all -it -v ${PWD}:/workspace fastplms-test bash
103
+ ```
104
+
105
+ Inside the container, run Boltz2 compliance against pip `boltz`:
106
+
107
+ ```bash
108
+ python -m testing.run_boltz2_compliance --device cuda --dtype float32 --seed 42 --num-sequences 3 --recycling-steps 3 --num-sampling-steps 200 --diffusion-samples 1 --pass-coord-metric aligned --write-cif-artifacts
109
+ ```
110
+
111
+ Artifacts are written to `testing/results/<timestamp>/boltz2_compliance/` by default:
112
+ - `metrics.json`
113
+ - `metrics.csv`
114
+ - `summary.txt`
115
+ - `structures/seq_<idx>/ours_seq<idx>.cif`
116
+ - `structures/seq_<idx>/ref_seq<idx>.cif`
117
+
118
+ Coordinate metrics now include both raw and rigid-aligned variants:
119
+ - `coord_mae`, `coord_rmse`, `coord_max_abs` (raw frame-dependent deltas)
120
+ - `coord_mae_aligned`, `coord_rmse_aligned`, `coord_max_abs_aligned` (Kabsch aligned)
121
+ - `pairwise_dist_mae` (frame-invariant pairwise-distance delta)
122
+
123
+ Pass/fail uses `--pass-coord-metric aligned` by default. Set `--pass-coord-metric raw` to use the raw coordinate thresholds.
124
+
125
+ ## Citations
126
+
127
+ ```bibtex
128
+ @misc{FastPLMs,
129
+ author={Hallee, Logan and Bichara, David and Gleghorn, Jason P.},
130
+ title={FastPLMs: Fast, efficient, protein language model inference from Huggingface AutoModel.},
131
+ year={2024},
132
+ url={https://huggingface.co/Synthyra/ESMplusplus_small},
133
+ DOI={10.57967/hf/3726},
134
+ publisher={Hugging Face}
135
+ }
136
+ ```
137
+
138
+ ```bibtex
139
+ @article{passaro2025boltz2,
140
+ title={Boltz-2: Exploring the Frontiers of Biomolecular Prediction},
141
+ author={Passaro, Saro and Corso, Gabriele and Wohlwend, Jeremy and Reveiz, Mateo and Bordes, Florian and Wicky, Basile and Dayan, Peter and Jing, Bowen},
142
+ journal={bioRxiv},
143
+ year={2025}
144
+ }
145
+ ```
146
+
147
+ ```bibtex
148
+ @article{wohlwend2024boltz1,
149
+ title={Boltz-1: Democratizing Biomolecular Interaction Modeling},
150
+ author={Wohlwend, Jeremy and Corso, Gabriele and Passaro, Saro and Reveiz, Mateo and Leidal, Ken and Swanson, Wojtek and Kher, Gilmer and Lember, Tommi and Jaakkola, Tommi},
151
+ journal={bioRxiv},
152
+ year={2024}
153
+ }
154
+ ```
155
+
156
+ ```bibtex
157
+ @inproceedings{paszke2019pytorch,
158
+ title={PyTorch: An Imperative Style, High-Performance Deep Learning Library},
159
+ author={Paszke, Adam and Gross, Sam and Massa, Francisco and Lerer, Adam and Bradbury, James and Chanan, Gregory and Killeen, Trevor and Lin, Zeming and Gimelshein, Natalia and Antiga, Luca and Desmaison, Alban and K{\"o}pf, Andreas and Yang, Edward and DeVito, Zach and Raison, Martin and Tejani, Alykhan and Chilamkurthy, Sasank and Steiner, Benoit and Fang, Lu and Bai, Junjie and Chintala, Soumith},
160
+ booktitle={Advances in Neural Information Processing Systems 32},
161
+ year={2019}
162
+ }
163
+ ```