InvDesTool 0.1.0a12__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.
- invdestool-0.1.0a12/LICENSE +21 -0
- invdestool-0.1.0a12/MANIFEST.in +7 -0
- invdestool-0.1.0a12/NOTICE +12 -0
- invdestool-0.1.0a12/PKG-INFO +214 -0
- invdestool-0.1.0a12/README.md +198 -0
- invdestool-0.1.0a12/docs/adapter_provenance.json +65 -0
- invdestool-0.1.0a12/docs/architecture.md +17 -0
- invdestool-0.1.0a12/docs/datasets.md +80 -0
- invdestool-0.1.0a12/docs/environment_inventory.json +4821 -0
- invdestool-0.1.0a12/docs/environments.md +65 -0
- invdestool-0.1.0a12/docs/models.md +2961 -0
- invdestool-0.1.0a12/docs/validation.md +59 -0
- invdestool-0.1.0a12/environments/legacy-cu121.requirements.txt +23 -0
- invdestool-0.1.0a12/environments/modern-cu126.requirements.txt +30 -0
- invdestool-0.1.0a12/examples/con_full_inputs.json +4 -0
- invdestool-0.1.0a12/examples/csp_inputs.json +3 -0
- invdestool-0.1.0a12/examples/discover_and_plan.py +16 -0
- invdestool-0.1.0a12/examples/dng_inputs.json +3 -0
- invdestool-0.1.0a12/pyproject.toml +25 -0
- invdestool-0.1.0a12/setup.cfg +4 -0
- invdestool-0.1.0a12/src/InvDesTool.egg-info/PKG-INFO +214 -0
- invdestool-0.1.0a12/src/InvDesTool.egg-info/SOURCES.txt +56 -0
- invdestool-0.1.0a12/src/InvDesTool.egg-info/dependency_links.txt +1 -0
- invdestool-0.1.0a12/src/InvDesTool.egg-info/entry_points.txt +2 -0
- invdestool-0.1.0a12/src/InvDesTool.egg-info/top_level.txt +1 -0
- invdestool-0.1.0a12/src/invdestool/__init__.py +11 -0
- invdestool-0.1.0a12/src/invdestool/__main__.py +3 -0
- invdestool-0.1.0a12/src/invdestool/_io.py +49 -0
- invdestool-0.1.0a12/src/invdestool/_match.py +87 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/__init__.py +1 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/benchmark_generation_v2.py +194 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/crystaldit.py +43 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/csp_classic_adapters_v1.py +146 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/csp_conditional_adapters_v1.py +125 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/csp_crystallm_inference_v2.py +18 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/csp_crystallm_postprocess_v2.py +30 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/csp_extension_adapters_v1.py +331 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/csp_extension_uni3dar.py +146 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/dao_guided.py +63 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/dng_multimodel_generate_v3_2026_10_21.py +191 -0
- invdestool-0.1.0a12/src/invdestool/_vendor/mat2seq_recovered_v1.py +149 -0
- invdestool-0.1.0a12/src/invdestool/_worker.py +279 -0
- invdestool-0.1.0a12/src/invdestool/catalog.py +102 -0
- invdestool-0.1.0a12/src/invdestool/cli.py +233 -0
- invdestool-0.1.0a12/src/invdestool/client.py +353 -0
- invdestool-0.1.0a12/src/invdestool/data/environments.json +277 -0
- invdestool-0.1.0a12/src/invdestool/data/invdestool-demo.json +165 -0
- invdestool-0.1.0a12/src/invdestool/data/model_guides.json +750 -0
- invdestool-0.1.0a12/src/invdestool/data/models.json +5004 -0
- invdestool-0.1.0a12/src/invdestool/datasets.py +90 -0
- invdestool-0.1.0a12/src/invdestool/download.py +290 -0
- invdestool-0.1.0a12/src/invdestool/environments.py +51 -0
- invdestool-0.1.0a12/src/invdestool/errors.py +16 -0
- invdestool-0.1.0a12/src/invdestool/experiment.py +166 -0
- invdestool-0.1.0a12/src/invdestool/inputs.py +133 -0
- invdestool-0.1.0a12/tests/test_experiment.py +130 -0
- invdestool-0.1.0a12/tests/test_package.py +537 -0
- invdestool-0.1.0a12/tools/write_model_docs.py +113 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 School of Physics, Renmin University of China
|
|
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.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include docs/adapter_provenance.json docs/architecture.md docs/datasets.md
|
|
3
|
+
include docs/environment_inventory.json docs/environments.md docs/models.md docs/validation.md
|
|
4
|
+
recursive-include environments *.txt
|
|
5
|
+
include examples/con_full_inputs.json examples/csp_inputs.json examples/dng_inputs.json examples/discover_and_plan.py
|
|
6
|
+
include tools/write_model_docs.py
|
|
7
|
+
recursive-include tests *.py
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
The bundled invdestool-demo dataset includes three structures derived from
|
|
2
|
+
the JARVIS-DFT 3D dataset (jdft_3d.json), 2022-12-12 snapshot, by Kamal Choudhary.
|
|
3
|
+
Source DOI 10.6084/m9.figshare.6815699
|
|
4
|
+
https://doi.org/10.6084/m9.figshare.6815699
|
|
5
|
+
|
|
6
|
+
These data are licensed under Creative Commons Attribution 4.0 International.
|
|
7
|
+
https://creativecommons.org/licenses/by/4.0/
|
|
8
|
+
|
|
9
|
+
InvDesTool selected the records and exported their exact compositions and
|
|
10
|
+
normalized reference-cell geometries. The record IDs are JVASP-135435,
|
|
11
|
+
JVASP-30047, and JVASP-8204. The bundled JSON includes the source IDs and
|
|
12
|
+
the correspondence to the demonstration case IDs.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: InvDesTool
|
|
3
|
+
Version: 0.1.0a12
|
|
4
|
+
Summary: InvDesTool for inverse materials design with crystal structure prediction and de novo generation
|
|
5
|
+
Author: InvDesToolTeam
|
|
6
|
+
Maintainer: InvDesToolTeam
|
|
7
|
+
License-Expression: MIT AND CC-BY-4.0
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: NOTICE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# InvDesTool · 材料逆向设计工具包
|
|
18
|
+
|
|
19
|
+
InvDesTool 统一发现、配置和调用无机晶体 CSP / DNG 生成模型。发行名为 `InvDesTool`,安装后即可 `import invdestool` 或使用 `invdestool` 命令。
|
|
20
|
+
|
|
21
|
+
InvDesTool 由中国人民大学物理学院的 **InvDesToolTeam** 开发和维护。
|
|
22
|
+
|
|
23
|
+
`0.1.0a12` 开发版提供 58 个生成适配配置(28 CSP、30 DNG)、9 个 DNG 调研候选以及 `idt.run()` 数据集入口。实际生成需要对应的模型文件和运行环境。各版本的验证范围见 [验证记录](docs/validation.md)。
|
|
24
|
+
|
|
25
|
+
## Python 快速开始
|
|
26
|
+
|
|
27
|
+
从本目录用 `python -m pip install .` 安装,也可以用 `pip` 安装本地构建的 wheel。安装后可直接查看模型和预览 CSP 或 DNG 请求。
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import invdestool as idt
|
|
31
|
+
|
|
32
|
+
plan = idt.run("crystalite_mp20", "invdestool-demo", num_samples=2, batch_size=2, dry_run=True)
|
|
33
|
+
print(plan["dataset"], plan["planned_batches"])
|
|
34
|
+
|
|
35
|
+
models = idt.list_models(task="CSP", runnable=True)
|
|
36
|
+
guide = idt.model_info("diffcsp")
|
|
37
|
+
print(guide["papers"], guide["parameters"])
|
|
38
|
+
print(guide["installation"]["files"])
|
|
39
|
+
csp_plan = idt.generate("crystalite_mp20", "Li2O", dry_run=True)
|
|
40
|
+
dng_plan = idt.generate("dng_diffcsp_mp20", num_atoms=12, dry_run=True)
|
|
41
|
+
crystaldit_plan = idt.generate("dng_crystaldit_mp20", num_samples=4, dry_run=True)
|
|
42
|
+
guided_plan = idt.generate("dao_mp20_guided", "Li2O", dry_run=True)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
在 [模型运行环境](docs/environments.md) 中执行实际生成。也可以用 `python=` 指定已准备好的解释器。`download=True` 允许按模型卡获取缺少的权重和源码。已有本地资源时可直接传 `model_path=` 和 `source_path=`。
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
result = idt.generate("crystalite_mp20", "Li2O", num_samples=4, gpu=0, download=True)
|
|
49
|
+
print(result.output_dir)
|
|
50
|
+
print(result.structures)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
每次生成默认在缓存的 `runs/` 下创建独立结果目录,也可用 `output_dir=` 指定新目录。可以通过 `result.attempts` 检查每次尝试的结果。`dry_run=True` 仅校验输入、条件和参数并返回计划。
|
|
54
|
+
|
|
55
|
+
## 用数据集批量生成和评测
|
|
56
|
+
|
|
57
|
+
准备好运行环境后,一次调用可生成整个数据集的候选、写出 CIF 并汇总指标。
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
result = idt.run("crystalite_mp20", "invdestool-demo", num_samples=2, batch_size=2, gpu=0, download=True)
|
|
61
|
+
print(result.metrics)
|
|
62
|
+
print(result.samples[0]["candidates"])
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`invdestool-demo` 内置 3 个 ICTS 样本。`num_samples=2` 给每个样本分配 2 个候选,共 6 次尝试。`batch_size=2` 指每批最多送入模型 2 个候选。使用自己的数据时,把数据集名换成 JSON 文件路径或 Python 样本列表。样本也可以各自填写 `num_samples`,未填写的样本沿用本批已填写数量的最大值。[逐样本候选数示例](docs/datasets.md#逐样本候选数) · [数据集格式和指标说明](docs/datasets.md)
|
|
66
|
+
|
|
67
|
+
## 安装与查看
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# 在本目录执行;只安装轻量入口,不安装 Torch/JAX、下载权重或启动 GPU
|
|
71
|
+
python -m pip install .
|
|
72
|
+
|
|
73
|
+
invdestool models
|
|
74
|
+
invdestool models --task CSP
|
|
75
|
+
invdestool models --task DNG --runnable
|
|
76
|
+
invdestool info diffcsp
|
|
77
|
+
invdestool info dng_omatg_Linear-ODE --json
|
|
78
|
+
invdestool envs
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
每个配置有独立说明,列出作者、论文、DOI、输入和单位、可调及固定参数、环境和文件布局。已核实的 arXiv DOI 单独标注。EquiCSP 提供论文集链接。`Con-CDVAE` 与 `cond-CDVAE` 是不同模型。[模型手册](docs/models.md)
|
|
82
|
+
|
|
83
|
+
## 使用本地权重
|
|
84
|
+
|
|
85
|
+
可保存整个模型库根目录。每个权重包按 `家族/训练集/任务/配置 ID/` 查找,保留配置所需的 checkpoint、参数文件和其他配套文件。默认库位于缓存的 `models/` 目录。Crystalite 的两个配置分别位于 `crystalite/mp20/csp/crystalite_mp20/` 和 `crystalite/mpts52/csp/crystalite_mpts52/`。
|
|
86
|
+
|
|
87
|
+
已保存的单模型路径优先。库中已有的 `<model-id>/` 平铺目录也可以继续使用。模型目录可放置 `source/` 和 `data/`,单独保存的 `--source-path` 和 `--data-path` 优先。用 `invdestool info MODEL` 查看本机解析出的路径、训练集和所需文件。
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
invdestool configure-models-dir ~/crystal-models
|
|
91
|
+
invdestool configure-runtime legacy-cu121 --python /your/envs/legacy/bin/python
|
|
92
|
+
|
|
93
|
+
invdestool configure diffcsp \
|
|
94
|
+
--model-path /your/models/diffcsp/mp_csp \
|
|
95
|
+
--source-path /your/repos/DiffCSP
|
|
96
|
+
|
|
97
|
+
# 只读检查文件/解释器;--runtime 只探测模块是否存在,不加载模型或访问 GPU
|
|
98
|
+
invdestool doctor diffcsp --verify-hashes --runtime
|
|
99
|
+
|
|
100
|
+
invdestool generate diffcsp --formula Li2O --num-samples 4 \
|
|
101
|
+
--param step_lr=0.00001 --seed 42 --batch-size 4 \
|
|
102
|
+
--gpu 0 --output ./runs/diffcsp_li2o
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`Li4O2` 会保留 6 个原子的整数输入,不自动约为 `Li2O`。多个输入可重复 `--formula`,也可通过 `--input` 读取 JSON。CrystalFormer 原生约化组成接口例外,会在模型卡中明确说明。
|
|
106
|
+
|
|
107
|
+
## 下载由使用者决定
|
|
108
|
+
|
|
109
|
+
使用 `download`、`--download` 或 Python 的 `download=True` 显式获取模型文件。可以随时用 `--dry-run` 或 `dry_run=True` 离线查看计划。
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# 先看文件、下载来源、体积、哈希与本地目标路径
|
|
113
|
+
invdestool download crystalite_mp20 --dry-run
|
|
114
|
+
|
|
115
|
+
# 使用默认路径:$INVDESTOOL_CACHE 或 $XDG_CACHE_HOME/invdestool
|
|
116
|
+
# XDG_CACHE_HOME 未设置时使用 ~/.cache/invdestool
|
|
117
|
+
invdestool download crystalite_mp20
|
|
118
|
+
|
|
119
|
+
# 下载支持自动获取的权重,并返回待手动准备的源码和位置
|
|
120
|
+
invdestool download dng_crystaldit_mp20 --available-only
|
|
121
|
+
|
|
122
|
+
# 自定义缓存目录,权重放在其 models/ 下对应的分层目录
|
|
123
|
+
invdestool download crystalite_mp20 --cache-dir /your/crystal-cache
|
|
124
|
+
|
|
125
|
+
# 或精确指定权重和源码目录
|
|
126
|
+
invdestool download crystalite_mp20 \
|
|
127
|
+
--model-path /your/models/crystalite/mp20 \
|
|
128
|
+
--source-path /your/repos/crystalite
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
42 个配置的所需资源有自动下载路径,16 个配置含手动步骤。手动项列出作者地址、应选版本、文件名和目标目录。作者只公布下载目录时,手册给出要选的配置和解压后所需的文件。直接下载支持断点续传和大小、SHA256 校验。发布包按清单取出所需成员。同一源码版本在默认缓存中供多个配置复用。
|
|
132
|
+
|
|
133
|
+
运行依赖安装在单独环境中。`invdestool envs --export ./runtime-recipes` 可导出两个候选环境的依赖骨架。用 `configure-runtime` 保存组内共用的 Python,或用 `configure MODEL --python` 为该模型覆盖。可以直接绑定已有的合适环境。[运行环境](docs/environments.md)
|
|
134
|
+
|
|
135
|
+
## Python API
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from invdestool import configure_models_dir, configure_runtime, list_models, model_info, load_model
|
|
139
|
+
|
|
140
|
+
models = list_models(task="CSP")
|
|
141
|
+
card = model_info("diffcsp")
|
|
142
|
+
print(card["parameters"])
|
|
143
|
+
configure_models_dir("~/crystal-models")
|
|
144
|
+
configure_runtime("legacy-cu121", python="/your/envs/legacy/bin/python")
|
|
145
|
+
|
|
146
|
+
model = load_model(
|
|
147
|
+
"diffcsp",
|
|
148
|
+
download=False,
|
|
149
|
+
model_path="/your/models/diffcsp/mp_csp",
|
|
150
|
+
source_path="/your/repos/DiffCSP",
|
|
151
|
+
python="/your/envs/legacy/bin/python",
|
|
152
|
+
sampling_parameters={"step_lr": 1e-5},
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# 不写文件、不联网、不启动解释器/GPU
|
|
156
|
+
plan = model.generate(
|
|
157
|
+
compositions=["Li2O", {"Si": 2}],
|
|
158
|
+
num_samples=4,
|
|
159
|
+
gpu=0,
|
|
160
|
+
output_dir="./runs/example",
|
|
161
|
+
dry_run=True,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
# 真正调用时使用 dry_run=False,并选择新的输出文件夹
|
|
165
|
+
result = model.generate(
|
|
166
|
+
compositions="Li2O", num_samples=4, seed=42,
|
|
167
|
+
gpu=0, output_dir="./runs/diffcsp_example",
|
|
168
|
+
)
|
|
169
|
+
print(result.manifest)
|
|
170
|
+
structures = result.structures # 几何字典列表,不需要在调用者环境安装 pymatgen
|
|
171
|
+
attempts = result.attempts # 包含失败/未知的全部原始尝试
|
|
172
|
+
# structures_pm = result.to_pymatgen() # 此转换需要调用者另有 pymatgen
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
自动下载用法:`load_model("crystalite_mp20", download=True, cache_dir="/your/cache", python="/your/envs/modern/bin/python")`。如果本地资源已齐全,可以始终使用 `download=False`。
|
|
176
|
+
|
|
177
|
+
## DNG 与有条件模型
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
invdestool generate dng_diffcsp_mp20 --num-atoms 12 --num-samples 8 \
|
|
181
|
+
--gpu 0 --output ./runs/dng_diffcsp
|
|
182
|
+
|
|
183
|
+
invdestool generate cond_mp20 --formula C4 \
|
|
184
|
+
--conditions '{"pressure_GPa": 0.0}' \
|
|
185
|
+
--param n_step_each=100 --gpu 0 --output ./runs/cond_c4
|
|
186
|
+
|
|
187
|
+
invdestool generate con_default_material_conditions --formula Li2O \
|
|
188
|
+
--conditions '{"formation_energy_per_atom": -2.0}' \
|
|
189
|
+
--gpu 0 --output ./runs/con_li2o
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Con 的形成能为显式用户请求,不默认填零。`full` 需要六个条件,`less` 的可选条件沿原生 TRAIN 先验;已知 N 从请求派生。需要作者 TRAIN 属性表时,通过 `--data-path` 指定包含 `mp4conz/train.csv` 的数据目录。`crystal_system` 使用作者整数编码 **0..6**。Cond 的压力通过发布 scaler 处理,不截断极端外推。
|
|
193
|
+
|
|
194
|
+
DNG 的 `num_atoms` 列表每个元素代表一次尝试;标量 N 可配合 `num_samples`。本包目前对 MatterGen 接通的是空性质条件的原生生成接口,模型卡没有暴露的性质引导参数不会假装支持。
|
|
195
|
+
|
|
196
|
+
CrystalDiT MP20 使用 `num_samples` 指定尝试数,由模型生成组成和原子数,原生上限为 20 个槽位。运行时传入匹配的 `source_path=`。有源码后可用 `download=True` 获取发布权重。DAO-G 四款引导配置组合了 MP20 或 MPTS52 生成器与标准或去重 DAO-P。`model_path=` 指向同时包含生成器和引导器子目录的 DAO-G 资产根目录,具体相对路径可用 `idt.get_model(model_id)["files"]` 查询。本机路径示例见 `examples/local_benchmark_profiles.json`。
|
|
197
|
+
|
|
198
|
+
## 环境与结果
|
|
199
|
+
|
|
200
|
+
主包没有强制第三方依赖,可与任意模型环境一起安装,不必额外建一个入口环境。现有 9 个运行入口的依赖盘点给出 **2 个共享推理环境的合并目标**,以及 JAX 单独保留时的 3 环境备选。两个新环境目前是待验证方案,并非已完成迁移;完整冲突、版本、适用范围与安装骨架见 [environments.md](docs/environments.md)。
|
|
201
|
+
|
|
202
|
+
每次模型调用使用独立子进程和所选 Python。自动设置 `CUDA_DEVICE_ORDER=PCI_BUS_ID`、`CUDA_VISIBLE_DEVICES=<物理卡>`,模型内部使用 `cuda:0`。不全局固定 GPU,不自动抢占空卡或接管 benchmark 队列。`--timeout` 在子进程外限制整个调用的墙钟时间。
|
|
203
|
+
|
|
204
|
+
每次生成使用新输出目录,包含 `request.json`、`manifest.json`、`attempts.json`、`runtime.log`、逐批 raw `.pt` 和成功结构的 CIF。不会为了凑成功数补采样。几何转换失败不自动解释为热力学不稳定;未知和失败保留在原始分母中。原始张量由使用者在自己可信的运行环境中产生,本包不会自动反序列化外来的结果 `.pt`。
|
|
205
|
+
|
|
206
|
+
## 开发与发布状态
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# CPU 合同/下载/子进程测试,不运行真实模型
|
|
210
|
+
PYTHONPATH=src PYTHONDONTWRITEBYTECODE=1 python -m unittest discover -s tests -v
|
|
211
|
+
python -m pip wheel . --no-deps -w dist
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
工具包代码采用 [MIT 许可证](LICENSE)。随包示例数据采用 CC BY 4.0,来源与改动见 [NOTICE](NOTICE)。模型作者的源码、权重和数据依各自许可证获取。适配器来源及改动见 [adapter_provenance.json](docs/adapter_provenance.json)。
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# InvDesTool · 材料逆向设计工具包
|
|
2
|
+
|
|
3
|
+
InvDesTool 统一发现、配置和调用无机晶体 CSP / DNG 生成模型。发行名为 `InvDesTool`,安装后即可 `import invdestool` 或使用 `invdestool` 命令。
|
|
4
|
+
|
|
5
|
+
InvDesTool 由中国人民大学物理学院的 **InvDesToolTeam** 开发和维护。
|
|
6
|
+
|
|
7
|
+
`0.1.0a12` 开发版提供 58 个生成适配配置(28 CSP、30 DNG)、9 个 DNG 调研候选以及 `idt.run()` 数据集入口。实际生成需要对应的模型文件和运行环境。各版本的验证范围见 [验证记录](docs/validation.md)。
|
|
8
|
+
|
|
9
|
+
## Python 快速开始
|
|
10
|
+
|
|
11
|
+
从本目录用 `python -m pip install .` 安装,也可以用 `pip` 安装本地构建的 wheel。安装后可直接查看模型和预览 CSP 或 DNG 请求。
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import invdestool as idt
|
|
15
|
+
|
|
16
|
+
plan = idt.run("crystalite_mp20", "invdestool-demo", num_samples=2, batch_size=2, dry_run=True)
|
|
17
|
+
print(plan["dataset"], plan["planned_batches"])
|
|
18
|
+
|
|
19
|
+
models = idt.list_models(task="CSP", runnable=True)
|
|
20
|
+
guide = idt.model_info("diffcsp")
|
|
21
|
+
print(guide["papers"], guide["parameters"])
|
|
22
|
+
print(guide["installation"]["files"])
|
|
23
|
+
csp_plan = idt.generate("crystalite_mp20", "Li2O", dry_run=True)
|
|
24
|
+
dng_plan = idt.generate("dng_diffcsp_mp20", num_atoms=12, dry_run=True)
|
|
25
|
+
crystaldit_plan = idt.generate("dng_crystaldit_mp20", num_samples=4, dry_run=True)
|
|
26
|
+
guided_plan = idt.generate("dao_mp20_guided", "Li2O", dry_run=True)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
在 [模型运行环境](docs/environments.md) 中执行实际生成。也可以用 `python=` 指定已准备好的解释器。`download=True` 允许按模型卡获取缺少的权重和源码。已有本地资源时可直接传 `model_path=` 和 `source_path=`。
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
result = idt.generate("crystalite_mp20", "Li2O", num_samples=4, gpu=0, download=True)
|
|
33
|
+
print(result.output_dir)
|
|
34
|
+
print(result.structures)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
每次生成默认在缓存的 `runs/` 下创建独立结果目录,也可用 `output_dir=` 指定新目录。可以通过 `result.attempts` 检查每次尝试的结果。`dry_run=True` 仅校验输入、条件和参数并返回计划。
|
|
38
|
+
|
|
39
|
+
## 用数据集批量生成和评测
|
|
40
|
+
|
|
41
|
+
准备好运行环境后,一次调用可生成整个数据集的候选、写出 CIF 并汇总指标。
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
result = idt.run("crystalite_mp20", "invdestool-demo", num_samples=2, batch_size=2, gpu=0, download=True)
|
|
45
|
+
print(result.metrics)
|
|
46
|
+
print(result.samples[0]["candidates"])
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`invdestool-demo` 内置 3 个 ICTS 样本。`num_samples=2` 给每个样本分配 2 个候选,共 6 次尝试。`batch_size=2` 指每批最多送入模型 2 个候选。使用自己的数据时,把数据集名换成 JSON 文件路径或 Python 样本列表。样本也可以各自填写 `num_samples`,未填写的样本沿用本批已填写数量的最大值。[逐样本候选数示例](docs/datasets.md#逐样本候选数) · [数据集格式和指标说明](docs/datasets.md)
|
|
50
|
+
|
|
51
|
+
## 安装与查看
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# 在本目录执行;只安装轻量入口,不安装 Torch/JAX、下载权重或启动 GPU
|
|
55
|
+
python -m pip install .
|
|
56
|
+
|
|
57
|
+
invdestool models
|
|
58
|
+
invdestool models --task CSP
|
|
59
|
+
invdestool models --task DNG --runnable
|
|
60
|
+
invdestool info diffcsp
|
|
61
|
+
invdestool info dng_omatg_Linear-ODE --json
|
|
62
|
+
invdestool envs
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
每个配置有独立说明,列出作者、论文、DOI、输入和单位、可调及固定参数、环境和文件布局。已核实的 arXiv DOI 单独标注。EquiCSP 提供论文集链接。`Con-CDVAE` 与 `cond-CDVAE` 是不同模型。[模型手册](docs/models.md)
|
|
66
|
+
|
|
67
|
+
## 使用本地权重
|
|
68
|
+
|
|
69
|
+
可保存整个模型库根目录。每个权重包按 `家族/训练集/任务/配置 ID/` 查找,保留配置所需的 checkpoint、参数文件和其他配套文件。默认库位于缓存的 `models/` 目录。Crystalite 的两个配置分别位于 `crystalite/mp20/csp/crystalite_mp20/` 和 `crystalite/mpts52/csp/crystalite_mpts52/`。
|
|
70
|
+
|
|
71
|
+
已保存的单模型路径优先。库中已有的 `<model-id>/` 平铺目录也可以继续使用。模型目录可放置 `source/` 和 `data/`,单独保存的 `--source-path` 和 `--data-path` 优先。用 `invdestool info MODEL` 查看本机解析出的路径、训练集和所需文件。
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
invdestool configure-models-dir ~/crystal-models
|
|
75
|
+
invdestool configure-runtime legacy-cu121 --python /your/envs/legacy/bin/python
|
|
76
|
+
|
|
77
|
+
invdestool configure diffcsp \
|
|
78
|
+
--model-path /your/models/diffcsp/mp_csp \
|
|
79
|
+
--source-path /your/repos/DiffCSP
|
|
80
|
+
|
|
81
|
+
# 只读检查文件/解释器;--runtime 只探测模块是否存在,不加载模型或访问 GPU
|
|
82
|
+
invdestool doctor diffcsp --verify-hashes --runtime
|
|
83
|
+
|
|
84
|
+
invdestool generate diffcsp --formula Li2O --num-samples 4 \
|
|
85
|
+
--param step_lr=0.00001 --seed 42 --batch-size 4 \
|
|
86
|
+
--gpu 0 --output ./runs/diffcsp_li2o
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`Li4O2` 会保留 6 个原子的整数输入,不自动约为 `Li2O`。多个输入可重复 `--formula`,也可通过 `--input` 读取 JSON。CrystalFormer 原生约化组成接口例外,会在模型卡中明确说明。
|
|
90
|
+
|
|
91
|
+
## 下载由使用者决定
|
|
92
|
+
|
|
93
|
+
使用 `download`、`--download` 或 Python 的 `download=True` 显式获取模型文件。可以随时用 `--dry-run` 或 `dry_run=True` 离线查看计划。
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# 先看文件、下载来源、体积、哈希与本地目标路径
|
|
97
|
+
invdestool download crystalite_mp20 --dry-run
|
|
98
|
+
|
|
99
|
+
# 使用默认路径:$INVDESTOOL_CACHE 或 $XDG_CACHE_HOME/invdestool
|
|
100
|
+
# XDG_CACHE_HOME 未设置时使用 ~/.cache/invdestool
|
|
101
|
+
invdestool download crystalite_mp20
|
|
102
|
+
|
|
103
|
+
# 下载支持自动获取的权重,并返回待手动准备的源码和位置
|
|
104
|
+
invdestool download dng_crystaldit_mp20 --available-only
|
|
105
|
+
|
|
106
|
+
# 自定义缓存目录,权重放在其 models/ 下对应的分层目录
|
|
107
|
+
invdestool download crystalite_mp20 --cache-dir /your/crystal-cache
|
|
108
|
+
|
|
109
|
+
# 或精确指定权重和源码目录
|
|
110
|
+
invdestool download crystalite_mp20 \
|
|
111
|
+
--model-path /your/models/crystalite/mp20 \
|
|
112
|
+
--source-path /your/repos/crystalite
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
42 个配置的所需资源有自动下载路径,16 个配置含手动步骤。手动项列出作者地址、应选版本、文件名和目标目录。作者只公布下载目录时,手册给出要选的配置和解压后所需的文件。直接下载支持断点续传和大小、SHA256 校验。发布包按清单取出所需成员。同一源码版本在默认缓存中供多个配置复用。
|
|
116
|
+
|
|
117
|
+
运行依赖安装在单独环境中。`invdestool envs --export ./runtime-recipes` 可导出两个候选环境的依赖骨架。用 `configure-runtime` 保存组内共用的 Python,或用 `configure MODEL --python` 为该模型覆盖。可以直接绑定已有的合适环境。[运行环境](docs/environments.md)
|
|
118
|
+
|
|
119
|
+
## Python API
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from invdestool import configure_models_dir, configure_runtime, list_models, model_info, load_model
|
|
123
|
+
|
|
124
|
+
models = list_models(task="CSP")
|
|
125
|
+
card = model_info("diffcsp")
|
|
126
|
+
print(card["parameters"])
|
|
127
|
+
configure_models_dir("~/crystal-models")
|
|
128
|
+
configure_runtime("legacy-cu121", python="/your/envs/legacy/bin/python")
|
|
129
|
+
|
|
130
|
+
model = load_model(
|
|
131
|
+
"diffcsp",
|
|
132
|
+
download=False,
|
|
133
|
+
model_path="/your/models/diffcsp/mp_csp",
|
|
134
|
+
source_path="/your/repos/DiffCSP",
|
|
135
|
+
python="/your/envs/legacy/bin/python",
|
|
136
|
+
sampling_parameters={"step_lr": 1e-5},
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# 不写文件、不联网、不启动解释器/GPU
|
|
140
|
+
plan = model.generate(
|
|
141
|
+
compositions=["Li2O", {"Si": 2}],
|
|
142
|
+
num_samples=4,
|
|
143
|
+
gpu=0,
|
|
144
|
+
output_dir="./runs/example",
|
|
145
|
+
dry_run=True,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# 真正调用时使用 dry_run=False,并选择新的输出文件夹
|
|
149
|
+
result = model.generate(
|
|
150
|
+
compositions="Li2O", num_samples=4, seed=42,
|
|
151
|
+
gpu=0, output_dir="./runs/diffcsp_example",
|
|
152
|
+
)
|
|
153
|
+
print(result.manifest)
|
|
154
|
+
structures = result.structures # 几何字典列表,不需要在调用者环境安装 pymatgen
|
|
155
|
+
attempts = result.attempts # 包含失败/未知的全部原始尝试
|
|
156
|
+
# structures_pm = result.to_pymatgen() # 此转换需要调用者另有 pymatgen
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
自动下载用法:`load_model("crystalite_mp20", download=True, cache_dir="/your/cache", python="/your/envs/modern/bin/python")`。如果本地资源已齐全,可以始终使用 `download=False`。
|
|
160
|
+
|
|
161
|
+
## DNG 与有条件模型
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
invdestool generate dng_diffcsp_mp20 --num-atoms 12 --num-samples 8 \
|
|
165
|
+
--gpu 0 --output ./runs/dng_diffcsp
|
|
166
|
+
|
|
167
|
+
invdestool generate cond_mp20 --formula C4 \
|
|
168
|
+
--conditions '{"pressure_GPa": 0.0}' \
|
|
169
|
+
--param n_step_each=100 --gpu 0 --output ./runs/cond_c4
|
|
170
|
+
|
|
171
|
+
invdestool generate con_default_material_conditions --formula Li2O \
|
|
172
|
+
--conditions '{"formation_energy_per_atom": -2.0}' \
|
|
173
|
+
--gpu 0 --output ./runs/con_li2o
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Con 的形成能为显式用户请求,不默认填零。`full` 需要六个条件,`less` 的可选条件沿原生 TRAIN 先验;已知 N 从请求派生。需要作者 TRAIN 属性表时,通过 `--data-path` 指定包含 `mp4conz/train.csv` 的数据目录。`crystal_system` 使用作者整数编码 **0..6**。Cond 的压力通过发布 scaler 处理,不截断极端外推。
|
|
177
|
+
|
|
178
|
+
DNG 的 `num_atoms` 列表每个元素代表一次尝试;标量 N 可配合 `num_samples`。本包目前对 MatterGen 接通的是空性质条件的原生生成接口,模型卡没有暴露的性质引导参数不会假装支持。
|
|
179
|
+
|
|
180
|
+
CrystalDiT MP20 使用 `num_samples` 指定尝试数,由模型生成组成和原子数,原生上限为 20 个槽位。运行时传入匹配的 `source_path=`。有源码后可用 `download=True` 获取发布权重。DAO-G 四款引导配置组合了 MP20 或 MPTS52 生成器与标准或去重 DAO-P。`model_path=` 指向同时包含生成器和引导器子目录的 DAO-G 资产根目录,具体相对路径可用 `idt.get_model(model_id)["files"]` 查询。本机路径示例见 `examples/local_benchmark_profiles.json`。
|
|
181
|
+
|
|
182
|
+
## 环境与结果
|
|
183
|
+
|
|
184
|
+
主包没有强制第三方依赖,可与任意模型环境一起安装,不必额外建一个入口环境。现有 9 个运行入口的依赖盘点给出 **2 个共享推理环境的合并目标**,以及 JAX 单独保留时的 3 环境备选。两个新环境目前是待验证方案,并非已完成迁移;完整冲突、版本、适用范围与安装骨架见 [environments.md](docs/environments.md)。
|
|
185
|
+
|
|
186
|
+
每次模型调用使用独立子进程和所选 Python。自动设置 `CUDA_DEVICE_ORDER=PCI_BUS_ID`、`CUDA_VISIBLE_DEVICES=<物理卡>`,模型内部使用 `cuda:0`。不全局固定 GPU,不自动抢占空卡或接管 benchmark 队列。`--timeout` 在子进程外限制整个调用的墙钟时间。
|
|
187
|
+
|
|
188
|
+
每次生成使用新输出目录,包含 `request.json`、`manifest.json`、`attempts.json`、`runtime.log`、逐批 raw `.pt` 和成功结构的 CIF。不会为了凑成功数补采样。几何转换失败不自动解释为热力学不稳定;未知和失败保留在原始分母中。原始张量由使用者在自己可信的运行环境中产生,本包不会自动反序列化外来的结果 `.pt`。
|
|
189
|
+
|
|
190
|
+
## 开发与发布状态
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# CPU 合同/下载/子进程测试,不运行真实模型
|
|
194
|
+
PYTHONPATH=src PYTHONDONTWRITEBYTECODE=1 python -m unittest discover -s tests -v
|
|
195
|
+
python -m pip wheel . --no-deps -w dist
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
工具包代码采用 [MIT 许可证](LICENSE)。随包示例数据采用 CC BY 4.0,来源与改动见 [NOTICE](NOTICE)。模型作者的源码、权重和数据依各自许可证获取。适配器来源及改动见 [adapter_provenance.json](docs/adapter_provenance.json)。
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"source": "scripts/csp_classic_adapters_v1.py",
|
|
4
|
+
"original_sha256": "f2b92cb8a6c1b255683cccbe0401cfe34f26f970ca7fa1862a24308442cf222a",
|
|
5
|
+
"snapshot": "csp_classic_adapters_v1.py",
|
|
6
|
+
"packaged_sha256": "aca24659bedf190220d2bb0a4f13a4b8526b9e3ba5f622c048f6fa2d44fea172",
|
|
7
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"source": "scripts/csp_extension_adapters_v1.py",
|
|
11
|
+
"original_sha256": "b753e55fe8c793ed9559b1ab1dc77f32a994e631399edaeda619905f6c528ef7",
|
|
12
|
+
"snapshot": "csp_extension_adapters_v1.py",
|
|
13
|
+
"packaged_sha256": "241237efc83c3df1da3d8f6aace72a56202e26c50258f08a694fa39d43a48001",
|
|
14
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"source": "scripts/csp_extension_uni3dar.py",
|
|
18
|
+
"original_sha256": "8dca40fd5539281f6c21a4a957df7908d3fa698da1eeb948b336681ac1f90745",
|
|
19
|
+
"snapshot": "csp_extension_uni3dar.py",
|
|
20
|
+
"packaged_sha256": "75dadc0cd79eb8a4787cab0625c743b1be5a1c8a9d18794a5e6b28d1c602b4db",
|
|
21
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"source": "scripts/csp_conditional_adapters_v1.py",
|
|
25
|
+
"original_sha256": "c5df36e4bcdf42b690f7bc1a2e31d452febd7d6661ab2c35c6089622620f8856",
|
|
26
|
+
"snapshot": "csp_conditional_adapters_v1.py",
|
|
27
|
+
"packaged_sha256": "3f71bae62484c3469bf3dbbed243f89887ddcd43e219160337e5801510eacbb4",
|
|
28
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"source": "scripts/csp_crystallm_inference_v2.py",
|
|
32
|
+
"original_sha256": "a0c9dd4924c1ecf1a23dccba0b9675ec34cb8381497db69ef27e617831b88ca0",
|
|
33
|
+
"snapshot": "csp_crystallm_inference_v2.py",
|
|
34
|
+
"packaged_sha256": "a0c9dd4924c1ecf1a23dccba0b9675ec34cb8381497db69ef27e617831b88ca0",
|
|
35
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"source": "scripts/csp_crystallm_postprocess_v2.py",
|
|
39
|
+
"original_sha256": "ff5eb7e01525ce47db87d62c9b6a48f5848f6634133670db21238b4eaeaf5f2a",
|
|
40
|
+
"snapshot": "csp_crystallm_postprocess_v2.py",
|
|
41
|
+
"packaged_sha256": "ff5eb7e01525ce47db87d62c9b6a48f5848f6634133670db21238b4eaeaf5f2a",
|
|
42
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"source": "scripts/mat2seq_recovered_v1.py",
|
|
46
|
+
"original_sha256": "cff4adb86f27c715af916817cbf075ec7aec2b4479a8ee3db156dd550c9f9f6d",
|
|
47
|
+
"snapshot": "mat2seq_recovered_v1.py",
|
|
48
|
+
"packaged_sha256": "ae0416b40d606c30340880a1fe1df31b6bdb9c27ae9da185c2bbba39e749b7d8",
|
|
49
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"source": "scripts/dng_multimodel_generate_v3_2026_10_21.py",
|
|
53
|
+
"original_sha256": "b6c4eb6a97cc977a4a8defca08a25575fb53d8e952cfb9006754c254c0f2b6be",
|
|
54
|
+
"snapshot": "dng_multimodel_generate_v3_2026_10_21.py",
|
|
55
|
+
"packaged_sha256": "cf14e8794756f8086b9b05d554d82e185bae0a12c5a367077402573dd2e4080b",
|
|
56
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"source": "scripts/benchmark_generation_v2.py",
|
|
60
|
+
"original_sha256": "61fd3d9c4884cbc1ee9c048fe8af05928f09bd95526bfac4a1d0a054f4dbfcd3",
|
|
61
|
+
"snapshot": "benchmark_generation_v2.py",
|
|
62
|
+
"packaged_sha256": "3337ba7049a785411490ec86b55bdf6e5415c3dea13f7a675da6ac1ef0e5a821",
|
|
63
|
+
"changes": "Remove queue main; bind explicit paths; expose supported native sampler parameters. See prepare_adapters.py."
|
|
64
|
+
}
|
|
65
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# 开发边界与接口
|
|
2
|
+
|
|
3
|
+
`invdestool` 是模型调用入口包,当前不接管 benchmark 调度,不训练模型,不默认计算 MLFF 稳定性或评测指标。模型资产、作者源码与运行环境由显式资源配置绑定。
|
|
4
|
+
|
|
5
|
+
调用链为 `Model.plan` → `doctor` 文件/哈希检查 → 独立模型 Python 的 `_worker.py` → 固定版本的适配代码 → 作者采样器。队列、参考结构和旧输出目录不会进入调用链。CSP 接收精确组成。DNG 的输入由模型卡决定,CrystalDiT 等无条件生成器只接收尝试数。有条件模型使用显式的属性字段。
|
|
6
|
+
|
|
7
|
+
轻量入口只依赖 Python 标准库。每个调用的模型源码模块、Hydra/JAX/Torch 状态和工作目录局限于子进程;主进程保持原工作目录和环境变量。`load_model` 返回延迟执行的句柄,不返回已经加载到 GPU 的权重对象。默认不自动管理、选择或预留 GPU,调用者传入物理卡号或 UUID。
|
|
8
|
+
|
|
9
|
+
源码和权重不进入 wheel。`data/models.json` 随包携带模型卡、已记录权重 SHA256、显式下载路径和参数规则。模型源码按版本跨配置缓存,权重按模型配置缓存。配置文件放在所选缓存的 `profiles/`,没有全局固定 GPU 或不可更改的服务器路径。
|
|
10
|
+
|
|
11
|
+
`_vendor/` 是项目自有推理适配器的私有副本;旧队列入口和旧路径表已去除,worker 显式绑定路径。`tools/prepare_adapters.py` 可重建副本并记录原始/包内哈希。需要修改适配代码时,修改此目录下的重建脚本及副本,不能改实验目录中的冻结原脚本。
|
|
12
|
+
|
|
13
|
+
结果采用固定尝试账本,保留 `generated`、`conversion_failed`、`generation_failed`、`unsupported_input` 与 `runtime_unknown`。超时或模型加载失败不会触发额外采样。调用者可获得成功结构列表,同时检查全部尝试及 manifest,不能用成功数替代原始预算。
|
|
14
|
+
|
|
15
|
+
原始 batch 输出在几何检查前写入 `.pt`。几何字段、CIF 和可读 JSON 供正常使用;本包不自动加载用户外部提供的 raw pickle。进程退出、墙钟超时和日志由主进程记录。新调用拒绝已存在输出目录;本版没有隐式 resume,避免不同参数复用旧结果。
|
|
16
|
+
|
|
17
|
+
模型卡包含适配代码与上游 benchmark 的验证状态。InvDesTool各版本和配置的实际推理证据见[验证记录](validation.md)。环境方案保留 candidate 状态,直至完成干净环境安装和代表配置的验证。
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# 批量实验与自定义数据集
|
|
2
|
+
|
|
3
|
+
安装后可直接预览内置样本。下面的命令为 3 个样本各计划 2 个候选,每次向模型提交最多 2 个候选。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
invdestool run crystalite_mp20 invdestool-demo --num-samples 2 --batch-size 2 --dry-run
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
使用 `idt.run()` 或 `invdestool run` 提交整个数据集。实际生成使用指定的物理 GPU 和模型运行环境。`download=True` 或 `--download` 表示同意下载缺少的权重和源码。可将 `invdestool-demo` 替换为 JSON 文件路径,Python 接口也接受字典或样本列表。
|
|
10
|
+
|
|
11
|
+
## CSP 数据
|
|
12
|
+
|
|
13
|
+
每个样本使用唯一字符串 `id`。`composition` 接受精确整数式或元素计数字典。带必需条件的模型在该样本中使用 `conditions`。把下面的样本保存为 `my-csp.json`。
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"name": "my-csp",
|
|
18
|
+
"task": "CSP",
|
|
19
|
+
"cases": [
|
|
20
|
+
{"id": "li2o", "composition": "Li2O", "num_samples": 2},
|
|
21
|
+
{"id": "nacl", "composition": {"Na": 1, "Cl": 1}, "num_samples": 5},
|
|
22
|
+
{"id": "mgo", "composition": "MgO"}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
在文件所在目录运行下列命令,预览生成计划。
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
invdestool run crystalite_mp20 my-csp.json --num-samples 9 --batch-size 5 --dry-run
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
输出中的 `sample_num_samples` 为 `{"li2o": 2, "nacl": 5, "mgo": 5}`。`MgO` 沿用本批已填的最大值 5。三个样本合计 12 次尝试,每批最多 5 个候选,所以 `planned_batches` 为 3。
|
|
34
|
+
|
|
35
|
+
如需在生成后进行 CPU 结构匹配,可以给样本添加 `reference`,例如 `"reference": "refs/li2o.cif"`。相对 CIF 路径以数据集文件所在目录为准。也可以传入由 `atomic_numbers`、`lattice`(Å)和 `frac_coords` 组成的字典。参考晶胞的元素计数应与输入组成一致。
|
|
36
|
+
|
|
37
|
+
## DNG 数据
|
|
38
|
+
|
|
39
|
+
支持指定原子数的模型可以在同次调用中为各样本指定不同 `num_atoms`。由模型决定原子数的配置使用 `id`、模型接受的可选条件和可选的候选数。
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import invdestool as idt
|
|
43
|
+
|
|
44
|
+
cases = [{"id": "size-6", "num_atoms": 6}, {"id": "size-10", "num_atoms": 10}]
|
|
45
|
+
plan = idt.run("dng_diffcsp_mp20", cases, num_samples=3, batch_size=4, dry_run=True)
|
|
46
|
+
print(plan["sample_num_samples"])
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
两条 DNG 样本都没有设置逐样本数量,因此使用全局 `num_samples=3`。输出为 `{'size-6': 3, 'size-10': 3}`。
|
|
50
|
+
|
|
51
|
+
## 逐样本候选数
|
|
52
|
+
|
|
53
|
+
CSP 和 DNG 样本都可以填写正整数 `num_samples`。有填写的样本使用自己的值,空缺样本使用本批所有已填写值的最大值。只有整批都未填写时,才使用 `idt.run(..., num_samples=N)` 或 CLI 的 `--num-samples N`,默认每条 1 个。
|
|
54
|
+
|
|
55
|
+
Python 可以直接传入样本列表,得到与 CSP 命令行示例相同的候选数量。
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import invdestool as idt
|
|
59
|
+
|
|
60
|
+
cases = [
|
|
61
|
+
{"id": "li2o", "composition": "Li2O", "num_samples": 2},
|
|
62
|
+
{"id": "nacl", "composition": "NaCl", "num_samples": 5},
|
|
63
|
+
{"id": "mgo", "composition": "MgO"},
|
|
64
|
+
]
|
|
65
|
+
plan = idt.run("crystalite_mp20", cases, num_samples=9, batch_size=5, dry_run=True)
|
|
66
|
+
print(plan["sample_num_samples"])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 结果与指标
|
|
70
|
+
|
|
71
|
+
- `samples.json` 以用户提供的样本 ID 归集候选、状态、CIF 路径和参考匹配结果。`attempts.json` 记录每个候选的完整结果和失败原因。
|
|
72
|
+
- `dataset.json` 保存本次使用的输入和参考数据快照。`metrics.json` 保存汇总、种子、批大小和数据集快照的 SHA256。
|
|
73
|
+
- `generation_rate` 为成功导出几何的候选比例,分母为所有样本计划候选数之和。`samples.json` 和 `dataset.json` 保存各样本最终采用的数量,`metrics.json` 的 `num_samples` 记录未填写样本采用的默认值。
|
|
74
|
+
- 有参考结构的 CSP 样本计算 MR@1、MR@K 和匹配样本的平均最佳归一化 RMSD。`K` 取本批最大候选数。MR@K 的分母为有参考且计划候选数至少为 `K` 的样本数,分母为零时省略该项。失败尝试计入指标,匹配超时或采样中断导致的未知按上下界报告。匹配容差和时限随指标保存。
|
|
75
|
+
|
|
76
|
+
`batch_size` 限制每批候选数。该设置与随机种子一起影响生成复现。采样器若在一批中抛出错误,已完成批次保留,尚未执行的候选记为未知。
|
|
77
|
+
|
|
78
|
+
## 内置样本来源
|
|
79
|
+
|
|
80
|
+
`invdestool-demo` 选取 ICTS 条目 `v5_00083`、`v5_00184` 和 `v5_00020`,供检查安装后的调用流程。三项参考来自 Kamal Choudhary 的 NIST JARVIS-DFT 3D 数据集(2022-12-12 快照),以 CC BY 4.0 许可发布。InvDesTool将所选结构整理为精确组成和参考晶胞几何。上游 DOI、许可链接和记录 ID 随包保留。[样本与来源](../src/invdestool/data/invdestool-demo.json)
|