molgpao 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. molgpao-1.0.0/.gitignore +21 -0
  2. molgpao-1.0.0/LICENSE +21 -0
  3. molgpao-1.0.0/PKG-INFO +69 -0
  4. molgpao-1.0.0/README.md +40 -0
  5. molgpao-1.0.0/pyproject.toml +67 -0
  6. molgpao-1.0.0/src/molgpao/__init__.py +46 -0
  7. molgpao-1.0.0/src/molgpao/chemistry/__init__.py +15 -0
  8. molgpao-1.0.0/src/molgpao/chemistry/valence_reconciler.py +945 -0
  9. molgpao-1.0.0/src/molgpao/conditioner.py +190 -0
  10. molgpao-1.0.0/src/molgpao/engine.py +6120 -0
  11. molgpao-1.0.0/src/molgpao/generator/__init__.py +1 -0
  12. molgpao-1.0.0/src/molgpao/generator/condition_contrast.py +17 -0
  13. molgpao-1.0.0/src/molgpao/generator/electronic_constraints.py +18 -0
  14. molgpao-1.0.0/src/molgpao/generator/molecular_state.py +198 -0
  15. molgpao-1.0.0/src/molgpao/generator/octree_backend.py +152 -0
  16. molgpao-1.0.0/src/molgpao/generator/octree_model.py +924 -0
  17. molgpao-1.0.0/src/molgpao/generator/random_streams.py +33 -0
  18. molgpao-1.0.0/src/molgpao/generator/spatial_box.py +64 -0
  19. molgpao-1.0.0/src/molgpao/lora.py +163 -0
  20. molgpao-1.0.0/src/molgpao/octree_process_critic.py +1323 -0
  21. molgpao-1.0.0/src/molgpao/post_tree_refiner.py +549 -0
  22. molgpao-1.0.0/src/molgpao/slots.py +64 -0
  23. molgpao-1.0.0/src/molgpao/vendor/UNI3DAR_LICENSE.txt +21 -0
  24. molgpao-1.0.0/src/molgpao/vendor/__init__.py +1 -0
  25. molgpao-1.0.0/src/molgpao/vendor/flash_attn/__init__.py +3 -0
  26. molgpao-1.0.0/src/molgpao/vendor/flash_attn/flash_attn_interface.py +43 -0
  27. molgpao-1.0.0/src/molgpao/vendor/uni3dar/__init__.py +1 -0
  28. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/__init__.py +20 -0
  29. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/atom_data.py +335 -0
  30. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/atom_dictionary.py +228 -0
  31. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/base_grid_dataset.py +475 -0
  32. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/cluster_sample_dataset.py +54 -0
  33. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/conformer_sample_dataset.py +92 -0
  34. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/crystal_data_utils.py +342 -0
  35. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/crystal_grid_dataset.py +98 -0
  36. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/data_type_dataset.py +18 -0
  37. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/data_utils.py +153 -0
  38. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/grid_dataset.py +114 -0
  39. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/grid_utils.py +191 -0
  40. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/lmdb_dataset.py +86 -0
  41. molgpao-1.0.0/src/molgpao/vendor/uni3dar/data/protein_grid_dataset.py +48 -0
  42. molgpao-1.0.0/src/molgpao/vendor/uni3dar/inference.py +321 -0
  43. molgpao-1.0.0/src/molgpao/vendor/uni3dar/losses/__init__.py +16 -0
  44. molgpao-1.0.0/src/molgpao/vendor/uni3dar/losses/ar_loss.py +315 -0
  45. molgpao-1.0.0/src/molgpao/vendor/uni3dar/losses/metric_reduce.py +121 -0
  46. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/__init__.py +1 -0
  47. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/attention.py +127 -0
  48. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/autoregressive_prediction_head.py +73 -0
  49. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/diffusion/__init__.py +47 -0
  50. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/diffusion/diffusion_utils.py +73 -0
  51. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/diffusion/gaussian_diffusion.py +877 -0
  52. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/diffusion/respace.py +129 -0
  53. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/diffusion_prediction_head.py +387 -0
  54. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/kv_cache.py +68 -0
  55. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/layers.py +214 -0
  56. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/rope.py +71 -0
  57. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/transformer_encoder.py +125 -0
  58. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/uni3dar.py +888 -0
  59. molgpao-1.0.0/src/molgpao/vendor/uni3dar/models/uni3dar_sampler.py +993 -0
  60. molgpao-1.0.0/src/molgpao/vendor/uni3dar/tasks/__init__.py +7 -0
  61. molgpao-1.0.0/src/molgpao/vendor/uni3dar/tasks/uni3dar.py +424 -0
  62. molgpao-1.0.0/src/molgpao/vendor/unicore/__init__.py +27 -0
  63. molgpao-1.0.0/src/molgpao/vendor/unicore/data.py +56 -0
  64. molgpao-1.0.0/src/molgpao/vendor/unicore/losses.py +14 -0
  65. molgpao-1.0.0/src/molgpao/vendor/unicore/models.py +27 -0
  66. molgpao-1.0.0/src/molgpao/vendor/unicore/modules.py +39 -0
  67. molgpao-1.0.0/src/molgpao/vendor/unicore/tasks.py +12 -0
  68. molgpao-1.0.0/tests/test_kv_cache.py +41 -0
  69. molgpao-1.0.0/tests/test_molgpao_exports.py +29 -0
  70. molgpao-1.0.0/tests/test_octree_process_critic.py +1017 -0
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ build/
4
+ dist/
5
+ *.egg-info/
6
+ .venv/
7
+ .pytest_cache/
8
+ .DS_Store
9
+ *.pt
10
+ *.pth
11
+ *.ckpt
12
+ *.safetensors
13
+ *.u3m
14
+ *.mgpao
15
+ pretrained/
16
+ weights/
17
+ dataset/
18
+ paper/*.aux
19
+ paper/*.blg
20
+ paper/*.log
21
+ paper/*.out
molgpao-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shangqian Chen, Guojiang Zhao, Zheng Cheng, Jiankun Wang, Hongshuai Wang, Zhifeng Gao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
molgpao-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.5
2
+ Name: molgpao
3
+ Version: 1.0.0
4
+ Summary: MolGPAO: Molecular Generative Pre-trained Autoregressive Octree with Speculative Decoding and Sub-Millisecond Seam Healing
5
+ Project-URL: Homepage, https://github.com/ShangChien/molgpao
6
+ Project-URL: Repository, https://github.com/ShangChien/molgpao
7
+ Project-URL: Issues, https://github.com/ShangChien/molgpao/issues
8
+ Author: Guojiang Zhao, Zheng Cheng, Jiankun Wang, Hongshuai Wang, Zhifeng Gao
9
+ Author-email: Shangqian Chen <chensq@dp.tech>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: 3d-molecular-generation,autoregressive,chemistry,drug-design,octree,speculative-decoding
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
20
+ Requires-Python: <3.13,>=3.11
21
+ Requires-Dist: lmdb>=1.4
22
+ Requires-Dist: numba>=0.59
23
+ Requires-Dist: numpy<2.0.0,>=1.26.0
24
+ Requires-Dist: rdkit>=2022.9.5
25
+ Requires-Dist: scipy>=1.11.0
26
+ Requires-Dist: torch>=2.5.0
27
+ Requires-Dist: tqdm>=4.66
28
+ Description-Content-Type: text/markdown
29
+
30
+ # MolGPAO (`molgpao`)
31
+
32
+ **MolGPAO: Molecular Generative Pre-trained Autoregressive Octree for Drug-Scale 3D Molecules**
33
+
34
+ Standalone, zero-external-surrogate, zero-RL, zero-inference-MLIP 3D octree autoregressive molecular generation engine (`M_out = 1`).
35
+
36
+ ## Key Innovations
37
+
38
+ 1. **Scale-Free Global Budget Modulation (`ScaleFreeBudgetEmbedding`)** & hierarchical organic packing priors (`L5 -> L1`).
39
+ 2. **Continuous Combinatorial Speculative Octree Funnel (`m_s1 -> m_s2 -> 1`)** with vectorized FlashAttention-2 pause-and-gather decoding.
40
+ 3. **Anti-Shortcut Ground-Truth `TwoStageOctreeProcessCritic`** combining 64-RBF covalent edge gating and exact `SO(3)`-invariant 12-channel multipole norms (`QM9` blind mismatched-target `r = 0.9867-0.9989`).
41
+ 4. **Sub-Millisecond `<0.5 ms` `SE(3)` `PostTreeGraphRefiner`** distilled strictly on synthetic Morton-seam perturbations + zero-heavy-displacement `ValenceReconciler` (`RMSD_heavy = 0.0000 Å`).
42
+ 5. **Bubble-Free Stride-2 GPU Leaf Decoding** eliminating `>95%` of host-device synchronization stalls.
43
+
44
+ ## Highlights
45
+
46
+ - **GEOM-Drugs (`10,000` molecules, `0.49 GPU-h`)**: Valid & Connected lifted `6.78x` (`12.70% -> 86.15%`, `99.83%` atom stability); at `N = 100`, `7.3x` faster (`1->1->1`) or `1.65x` faster with `2.0x` higher valid-connected yield (`16->4->1`) than 100-step `FlowMol`.
47
+ - **QM9 Disjoint `50k/50k` (`1 x 6-prop`, `0.43 GPU-h`, `362x` less compute than 6-model `PropMolFlow`)**: Beats `PropMolFlow` on `ε_HOMO` (`221.84` vs `253.99 meV`) and dipole `μ` (`0.4902` vs `0.6202 D`) with `100.0%` chemical legality.
48
+ - **OE62 Pure Ground-Truth `HOMO` (`0.56 GPU-h`, `92.8x` less compute than `52 GPU-h` `PropMolFlow`)**: `34.38%` vs `30.75%` blind clean hit yield and **`2.0x` live `GPU4PySCF PBE0/def2-TZVP` hit rate (`33.3%` vs `16.7%`)**.
49
+
50
+ ## Repository Structure
51
+
52
+ - `src/molgpao/`: Standalone Python package (`MolGPAOEngine`, `TwoStageOctreeProcessCritic`, `PostTreeGraphRefiner`, `ValenceReconciler`).
53
+ - `scripts/`: Standalone `GEOM-Drugs`, `QM9`, and `OE62` benchmarks and figure plotting scripts.
54
+ - `results/`: Canonical JSON benchmark records backing all paper tables and figures.
55
+ - `paper/`: Complete arXiv LaTeX/Markdown manuscript (`main_molgpao.pdf`, `MolGPAO_Paper.md`, `MolGPAO_arXiv_Submission.tar.gz`).
56
+ - `tests/`: Unit test suite.
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ pip install molgpao
62
+ ```
63
+
64
+ ## Quick Verification
65
+
66
+ ```bash
67
+ pytest -q
68
+ (cd paper && tectonic -X compile main_molgpao.tex)
69
+ ```
@@ -0,0 +1,40 @@
1
+ # MolGPAO (`molgpao`)
2
+
3
+ **MolGPAO: Molecular Generative Pre-trained Autoregressive Octree for Drug-Scale 3D Molecules**
4
+
5
+ Standalone, zero-external-surrogate, zero-RL, zero-inference-MLIP 3D octree autoregressive molecular generation engine (`M_out = 1`).
6
+
7
+ ## Key Innovations
8
+
9
+ 1. **Scale-Free Global Budget Modulation (`ScaleFreeBudgetEmbedding`)** & hierarchical organic packing priors (`L5 -> L1`).
10
+ 2. **Continuous Combinatorial Speculative Octree Funnel (`m_s1 -> m_s2 -> 1`)** with vectorized FlashAttention-2 pause-and-gather decoding.
11
+ 3. **Anti-Shortcut Ground-Truth `TwoStageOctreeProcessCritic`** combining 64-RBF covalent edge gating and exact `SO(3)`-invariant 12-channel multipole norms (`QM9` blind mismatched-target `r = 0.9867-0.9989`).
12
+ 4. **Sub-Millisecond `<0.5 ms` `SE(3)` `PostTreeGraphRefiner`** distilled strictly on synthetic Morton-seam perturbations + zero-heavy-displacement `ValenceReconciler` (`RMSD_heavy = 0.0000 Å`).
13
+ 5. **Bubble-Free Stride-2 GPU Leaf Decoding** eliminating `>95%` of host-device synchronization stalls.
14
+
15
+ ## Highlights
16
+
17
+ - **GEOM-Drugs (`10,000` molecules, `0.49 GPU-h`)**: Valid & Connected lifted `6.78x` (`12.70% -> 86.15%`, `99.83%` atom stability); at `N = 100`, `7.3x` faster (`1->1->1`) or `1.65x` faster with `2.0x` higher valid-connected yield (`16->4->1`) than 100-step `FlowMol`.
18
+ - **QM9 Disjoint `50k/50k` (`1 x 6-prop`, `0.43 GPU-h`, `362x` less compute than 6-model `PropMolFlow`)**: Beats `PropMolFlow` on `ε_HOMO` (`221.84` vs `253.99 meV`) and dipole `μ` (`0.4902` vs `0.6202 D`) with `100.0%` chemical legality.
19
+ - **OE62 Pure Ground-Truth `HOMO` (`0.56 GPU-h`, `92.8x` less compute than `52 GPU-h` `PropMolFlow`)**: `34.38%` vs `30.75%` blind clean hit yield and **`2.0x` live `GPU4PySCF PBE0/def2-TZVP` hit rate (`33.3%` vs `16.7%`)**.
20
+
21
+ ## Repository Structure
22
+
23
+ - `src/molgpao/`: Standalone Python package (`MolGPAOEngine`, `TwoStageOctreeProcessCritic`, `PostTreeGraphRefiner`, `ValenceReconciler`).
24
+ - `scripts/`: Standalone `GEOM-Drugs`, `QM9`, and `OE62` benchmarks and figure plotting scripts.
25
+ - `results/`: Canonical JSON benchmark records backing all paper tables and figures.
26
+ - `paper/`: Complete arXiv LaTeX/Markdown manuscript (`main_molgpao.pdf`, `MolGPAO_Paper.md`, `MolGPAO_arXiv_Submission.tar.gz`).
27
+ - `tests/`: Unit test suite.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install molgpao
33
+ ```
34
+
35
+ ## Quick Verification
36
+
37
+ ```bash
38
+ pytest -q
39
+ (cd paper && tectonic -X compile main_molgpao.tex)
40
+ ```
@@ -0,0 +1,67 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "molgpao"
7
+ version = "1.0.0"
8
+ description = "MolGPAO: Molecular Generative Pre-trained Autoregressive Octree with Speculative Decoding and Sub-Millisecond Seam Healing"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11,<3.13"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ keywords = [
14
+ "3d-molecular-generation",
15
+ "octree",
16
+ "autoregressive",
17
+ "speculative-decoding",
18
+ "drug-design",
19
+ "chemistry",
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 4 - Beta",
23
+ "Intended Audience :: Science/Research",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Topic :: Scientific/Engineering :: Chemistry",
28
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
29
+ ]
30
+ authors = [
31
+ { name = "Shangqian Chen", email = "chensq@dp.tech" },
32
+ { name = "Guojiang Zhao" },
33
+ { name = "Zheng Cheng" },
34
+ { name = "Jiankun Wang" },
35
+ { name = "Hongshuai Wang" },
36
+ { name = "Zhifeng Gao" },
37
+ ]
38
+ dependencies = [
39
+ "numpy>=1.26.0,<2.0.0",
40
+ "scipy>=1.11.0",
41
+ "torch>=2.5.0",
42
+ "rdkit>=2022.9.5",
43
+ "lmdb>=1.4",
44
+ "numba>=0.59",
45
+ "tqdm>=4.66",
46
+ ]
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/ShangChien/molgpao"
50
+ Repository = "https://github.com/ShangChien/molgpao"
51
+ Issues = "https://github.com/ShangChien/molgpao/issues"
52
+
53
+ [tool.hatch.build.targets.sdist]
54
+ include = [
55
+ "/src/molgpao",
56
+ "/tests",
57
+ "/README.md",
58
+ "/LICENSE",
59
+ "/pyproject.toml",
60
+ ]
61
+
62
+ [tool.hatch.build.targets.wheel]
63
+ packages = ["src/molgpao"]
64
+
65
+ [tool.pytest.ini_options]
66
+ testpaths = ["tests"]
67
+ pythonpath = [".", "src"]
@@ -0,0 +1,46 @@
1
+ """MolGPAO: Standalone Speculative Octree 3D Molecular Generation Engine."""
2
+
3
+ from .chemistry.valence_reconciler import ValenceReconciler
4
+ from .conditioner import LoomConditioner
5
+ from .engine import LoomUni3DARGenerator
6
+ from .lora import LoRALinear, inject_uni3dar_lora, inject_xyz_head_lora
7
+ from .octree_process_critic import (
8
+ NUM_COARSE_GEOM_FEATS,
9
+ NUM_ELEM_CLOUD_FEATS,
10
+ OctreeElementProcessCritic,
11
+ OctreeProcessCritic,
12
+ TwoStageOctreeProcessCritic,
13
+ compute_element_cloud_features,
14
+ fit_octree_element_process_critic,
15
+ fit_octree_process_critic,
16
+ )
17
+ from .post_tree_refiner import PostTreeGraphRefiner, fit_post_tree_graph_refiner
18
+ from .slots import GeneratorSlot, resolve_effort_candidates
19
+
20
+ MolGPAOEngine = LoomUni3DARGenerator
21
+ Uni3DARMolEngine = MolGPAOEngine
22
+
23
+ __version__ = "1.0.0"
24
+
25
+ __all__ = [
26
+ "MolGPAOEngine",
27
+ "Uni3DARMolEngine",
28
+ "LoomUni3DARGenerator",
29
+ "LoomConditioner",
30
+ "LoRALinear",
31
+ "inject_uni3dar_lora",
32
+ "inject_xyz_head_lora",
33
+ "NUM_COARSE_GEOM_FEATS",
34
+ "NUM_ELEM_CLOUD_FEATS",
35
+ "OctreeProcessCritic",
36
+ "OctreeElementProcessCritic",
37
+ "TwoStageOctreeProcessCritic",
38
+ "compute_element_cloud_features",
39
+ "fit_octree_process_critic",
40
+ "fit_octree_element_process_critic",
41
+ "PostTreeGraphRefiner",
42
+ "fit_post_tree_graph_refiner",
43
+ "ValenceReconciler",
44
+ "GeneratorSlot",
45
+ "resolve_effort_candidates",
46
+ ]
@@ -0,0 +1,15 @@
1
+ """Chemistry validation and 3D neutral-valence reconciliation utilities for `Loom`."""
2
+
3
+ from .valence_reconciler import (
4
+ ReconciliationResult,
5
+ ValenceReconciler,
6
+ reconcile_3d_point_cloud,
7
+ reconcile_trajectory_batch,
8
+ )
9
+
10
+ __all__ = [
11
+ "ReconciliationResult",
12
+ "ValenceReconciler",
13
+ "reconcile_3d_point_cloud",
14
+ "reconcile_trajectory_batch",
15
+ ]