Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,6 +1,103 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
-
|
| 4 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
library_name: onnx
|
| 6 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- protein-structure-prediction
|
| 5 |
+
- boltz
|
| 6 |
+
- alphafold
|
| 7 |
+
- onnx
|
| 8 |
+
- webgpu
|
| 9 |
+
- biology
|
| 10 |
library_name: onnx
|
| 11 |
+
base_model: boltz-community/boltz-2
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Boltz-2 ONNX (single-sequence v0)
|
| 15 |
+
|
| 16 |
+
ONNX-Runtime-compatible export of **Boltz-2** ([Wohlwend et al., 2024β2025](https://doi.org/10.1101/2025.06.14.659707); MIT-licensed), produced by [boltz-dev](https://github.com/jwohlwend/boltz). Split into two graphs so the inference loop (recycling + diffusion sampling) can run client-side β designed for [biocircus.io](https://biocircus.io), which loads these via ONNX Runtime Web + WebGPU and lets a user predict a structure entirely inside the browser tab.
|
| 17 |
+
|
| 18 |
+
This is **v0**: single-sequence protein only, no MSA, no templates, no affinity head. Confidence and full-atom output included. Three precision tiers.
|
| 19 |
+
|
| 20 |
+
## What's here
|
| 21 |
+
|
| 22 |
+
| Tier | Trunk | Diffusion step | Total | When to use |
|
| 23 |
+
|-------|------------|----------------|-------------|--------------------------------------|
|
| 24 |
+
| fp32 | 795 MB | 1.05 GB | 1.85 GB | Reference / debug |
|
| 25 |
+
| fp16 | 409 MB | 538 MB | **947 MB** | Desktop / laptop default β recommended |
|
| 26 |
+
| int8 | 217 MB | 273 MB | **490 MB** | Smartphone / tablet / low-RAM |
|
| 27 |
+
|
| 28 |
+
```
|
| 29 |
+
fp32/ fp16/ int8/
|
| 30 |
+
βββ trunk.onnx βββ trunk_fp16.onnx βββ trunk_int8.onnx
|
| 31 |
+
βββ trunk.onnx.data βββ trunk_fp16.onnx.data βββ trunk_int8.onnx.data
|
| 32 |
+
βββ diffusion_step.onnx βββ diffusion_step_fp16.onnx βββ diffusion_step_int8.onnx
|
| 33 |
+
βββ diffusion_step.onnx.data βββ diffusion_step_fp16.onnx.data βββ diffusion_step_int8.onnx.data
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
Each `.onnx` file is paired with an external-data sidecar (`.onnx.data`) holding the bulk of the weights. ONNX Runtime loads the pair automatically when both are co-located.
|
| 37 |
+
|
| 38 |
+
## Graph signatures
|
| 39 |
+
|
| 40 |
+
### Trunk (one recycling pass)
|
| 41 |
+
|
| 42 |
+
**Inputs** (80 total): 78 preprocessed feature tensors from the Boltz-2 input pipeline β `token_pad_mask`, `atom_pad_mask`, `ref_pos`, `ref_element`, `res_type`, `residue_index`, `token_bonds`, `type_bonds`, `mol_type`, `entity_id`, `sym_id`, etc. β plus `s_prev [B, N, 384]` and `z_prev [B, N, N, 128]` (zeros on the first recycling iteration; trunk outputs fed back on subsequent ones).
|
| 43 |
+
|
| 44 |
+
**Outputs** (9 total):
|
| 45 |
+
- `s [B, N, 384]` β single representation
|
| 46 |
+
- `z [B, N, N, 128]` β pair representation
|
| 47 |
+
- `pdistogram [B, N, N, 1, 64]` β distogram logits
|
| 48 |
+
- `q [B, A, 128]`, `c [B, A, 128]` β atom-level diffusion conditioning
|
| 49 |
+
- `atom_enc_bias [B, K, W, H, 12]`, `atom_dec_bias [B, K, W, H, 12]`, `token_trans_bias [B, N, N, 384]` β diffusion biases
|
| 50 |
+
- `s_inputs [B, N, 384]` β input embedder output, reused by the diffusion step
|
| 51 |
+
|
| 52 |
+
### Diffusion step (one denoising iteration)
|
| 53 |
+
|
| 54 |
+
**Inputs** (87 total): the same 78 feature tensors plus the 8 trunk-cached tensors (`s`, `s_inputs`, `q`, `c`, three biases) + `x_noisy [B, A, 3]` (current atom coords) + `sigma [B]` (1-D tensor; the `t_hat = sigma_tm * (1 + gamma)` value computed in the orchestrator).
|
| 55 |
+
|
| 56 |
+
**Output**: `x_denoised [B, A, 3]`.
|
| 57 |
+
|
| 58 |
+
`to_keys` (used by the atom encoder) is **not** part of the graph contract β it's a `functools.partial` closure in PyTorch land. Reconstruct it inside the diffusion graph by computing `get_indexing_matrix(K = A_padded / W, W, H, device)` with the known model hyperparams W=32, H=128 (and equivalently for any other atom-window split).
|
| 59 |
+
|
| 60 |
+
## Validation
|
| 61 |
+
|
| 62 |
+
Per the [Phase 5 report](reports/phase5_validation.md), all three precisions sit *inside* the natural PyTorch inter-seed noise distribution for 1CRN single-sequence inference. Pairwise Kabsch-aligned CΞ± RMSD (Γ
):
|
| 63 |
+
|
| 64 |
+
```
|
| 65 |
+
PyTorch β· PyTorch ORT β· PyTorch
|
| 66 |
+
inter-seed pairs: mean 6.77, range 5.69β8.06
|
| 67 |
+
fp32 vs PyTorch: mean 6.74, range 4.94β8.99
|
| 68 |
+
fp16 vs PyTorch: mean 6.73, range 4.95β8.97
|
| 69 |
+
int8 vs PyTorch: mean 6.20, range 4.97β8.01
|
| 70 |
+
|
| 71 |
+
Cross-precision (ORT vs ORT, same seed):
|
| 72 |
+
fp32 β fp16: 0.186 β essentially lossless
|
| 73 |
+
fp32 β int8: 2.31 β within ORT cross-augmentation drift
|
| 74 |
+
fp16 β int8: 2.27
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
The high absolute RMSDs are intrinsic to **single-sequence-no-MSA** Boltz-2 (pLDDT ~0.45 on this prediction β the model is sampling broadly because it has no co-evolution signal). With MSA inputs the noise floor collapses ~10Γ; quantisation quality would still hold.
|
| 78 |
+
|
| 79 |
+
## Use in biocircus.io
|
| 80 |
+
|
| 81 |
+
The biocircus runtime fetches a `ModelManifest` that points at this repo, picks a precision tier based on hardware probe, and runs the recycling + diffusion sampling loops in TypeScript against ORT Web sessions. See [boltz_orchestrate.py](https://github.com/biocircus/boltz-dev/blob/main/scripts/boltz_orchestrate.py) for a Python reference implementation of the orchestration loop.
|
| 82 |
+
|
| 83 |
+
For the per-step diffusion math the orchestrator needs:
|
| 84 |
+
- A Haar-uniform random-rotation generator (called `compute_random_augmentation` in Python).
|
| 85 |
+
- A Kabsch-style weighted rigid align (used when `alignment_reverse_diff=True`, which it is by default in Boltz-2).
|
| 86 |
+
- The Karras noise schedule (formula and constants in `phase4/validation_report.md`).
|
| 87 |
+
|
| 88 |
+
## License & citation
|
| 89 |
+
|
| 90 |
+
MIT, matching the upstream Boltz repo. Please cite Boltz-2:
|
| 91 |
+
|
| 92 |
+
```bibtex
|
| 93 |
+
@article{wohlwend2025boltz2,
|
| 94 |
+
title = {Boltz-2: Towards Accurate and Efficient Binding Affinity Prediction},
|
| 95 |
+
author = {Wohlwend, J. and others},
|
| 96 |
+
year = {2025},
|
| 97 |
+
doi = {10.1101/2025.06.14.659707}
|
| 98 |
+
}
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## Provenance
|
| 102 |
+
|
| 103 |
+
Exported with `torch.onnx.export(..., dynamo=True)` on PyTorch 2.12, ONNX opset 18. Quantised with `onnxconverter_common.float16` (fp16) and `onnxruntime.quantization.quantize_dynamic` (int8). See the [boltz-dev](https://github.com/jwohlwend/boltz) repo's `scripts/` directory for the export and quantisation scripts, and the EXPORT_PLAN.md pitfall catalogue for documented `onnxconverter_common` workarounds on dynamo-exported graphs.
|