bayesianflow-for-chem 1.4.1__tar.gz → 1.4.2__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.
Potentially problematic release.
This version of bayesianflow-for-chem might be problematic. Click here for more details.
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/PKG-INFO +2 -1
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/__init__.py +1 -1
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/model.py +18 -8
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/tool.py +25 -2
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem.egg-info/PKG-INFO +2 -1
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem.egg-info/requires.txt +1 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/setup.py +1 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/LICENSE +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/README.md +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/data.py +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/scorer.py +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/train.py +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/vocab.txt +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem.egg-info/SOURCES.txt +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem.egg-info/dependency_links.txt +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem.egg-info/top_level.txt +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/pyproject.toml +0 -0
- {bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bayesianflow_for_chem
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.2
|
|
4
4
|
Summary: Bayesian flow network framework for Chemistry
|
|
5
5
|
Home-page: https://augus1999.github.io/bayesian-flow-network-for-chemistry/
|
|
6
6
|
Author: Nianze A. Tao
|
|
@@ -23,6 +23,7 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
License-File: LICENSE
|
|
24
24
|
Requires-Dist: rdkit>=2023.9.6
|
|
25
25
|
Requires-Dist: torch>=2.3.1
|
|
26
|
+
Requires-Dist: torchao>=0.12
|
|
26
27
|
Requires-Dist: numpy>=1.26.4
|
|
27
28
|
Requires-Dist: loralib>=0.1.2
|
|
28
29
|
Requires-Dist: lightning>=2.2.0
|
{bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem/__init__.py
RENAMED
|
@@ -7,5 +7,5 @@ from . import data, tool, train, scorer
|
|
|
7
7
|
from .model import ChemBFN, MLP, EnsembleChemBFN
|
|
8
8
|
|
|
9
9
|
__all__ = ["data", "tool", "train", "scorer", "ChemBFN", "MLP", "EnsembleChemBFN"]
|
|
10
|
-
__version__ = "1.4.
|
|
10
|
+
__version__ = "1.4.2"
|
|
11
11
|
__author__ = "Nianze A. Tao (Omozawa Sueno)"
|
|
@@ -54,9 +54,19 @@ class Linear(nn.Linear):
|
|
|
54
54
|
:return:
|
|
55
55
|
:rtype: None
|
|
56
56
|
"""
|
|
57
|
+
from torchao.dtypes.affine_quantized_tensor import AffineQuantizedTensor
|
|
58
|
+
|
|
57
59
|
assert r > 0, "Rank should be larger than 0."
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
if isinstance(self.weight, AffineQuantizedTensor):
|
|
61
|
+
self.lora_A = nn.Parameter(
|
|
62
|
+
torch.zeros((r, self.in_features), device=self.weight.device)
|
|
63
|
+
)
|
|
64
|
+
self.lora_B = nn.Parameter(
|
|
65
|
+
torch.zeros((self.out_features, r), device=self.weight.device)
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
self.lora_A = nn.Parameter(self.weight.new_zeros((r, self.in_features)))
|
|
69
|
+
self.lora_B = nn.Parameter(self.weight.new_zeros((self.out_features, r)))
|
|
60
70
|
self.scaling = lora_alpha / r
|
|
61
71
|
self.lora_dropout = lora_dropout
|
|
62
72
|
self.lora_enabled = True
|
|
@@ -1207,23 +1217,23 @@ class EnsembleChemBFN(ChemBFN):
|
|
|
1207
1217
|
)
|
|
1208
1218
|
|
|
1209
1219
|
def quantise(
|
|
1210
|
-
self, quantise_method: Optional[Callable[[ChemBFN],
|
|
1220
|
+
self, quantise_method: Optional[Callable[[ChemBFN], None]] = None
|
|
1211
1221
|
) -> None:
|
|
1212
1222
|
"""
|
|
1213
1223
|
Quantise the submodels. \n
|
|
1214
1224
|
This method should be called, if necessary, before `torch.compile()`.
|
|
1215
1225
|
|
|
1216
|
-
:param quantise_method: quantisation method; default is `bayesianflow_for_chem.tool.
|
|
1226
|
+
:param quantise_method: quantisation method; default is `bayesianflow_for_chem.tool.quantise_model_`
|
|
1217
1227
|
:type quantise_method: callable | None
|
|
1218
1228
|
:return:
|
|
1219
1229
|
:rtype: None
|
|
1220
1230
|
"""
|
|
1221
1231
|
if quantise_method is None:
|
|
1222
|
-
from bayesianflow_for_chem.tool import
|
|
1232
|
+
from bayesianflow_for_chem.tool import quantise_model_
|
|
1223
1233
|
|
|
1224
|
-
quantise_method =
|
|
1225
|
-
for
|
|
1226
|
-
|
|
1234
|
+
quantise_method = quantise_model_
|
|
1235
|
+
for _, v in self.models.items():
|
|
1236
|
+
quantise_method(v)
|
|
1227
1237
|
|
|
1228
1238
|
def jit(self, freeze: bool = False) -> None:
|
|
1229
1239
|
"""
|
|
@@ -13,9 +13,8 @@ import torch
|
|
|
13
13
|
import numpy as np
|
|
14
14
|
import torch.nn as nn
|
|
15
15
|
from torch import cuda, Tensor, softmax
|
|
16
|
-
from torch.ao import quantization
|
|
17
16
|
from torch.utils.data import DataLoader
|
|
18
|
-
from typing_extensions import Self
|
|
17
|
+
from typing_extensions import Self, deprecated
|
|
19
18
|
from rdkit.Chem import (
|
|
20
19
|
rdDetermineBonds,
|
|
21
20
|
GetFormalCharge,
|
|
@@ -386,6 +385,11 @@ def inpaint(
|
|
|
386
385
|
]
|
|
387
386
|
|
|
388
387
|
|
|
388
|
+
@deprecated(
|
|
389
|
+
"Eager mode quantization from `torch.ao` is deprecated and will be remove in version 2.10, "
|
|
390
|
+
"so this fuction will stop working since that time. "
|
|
391
|
+
"Please use `quantise_model_` instead."
|
|
392
|
+
)
|
|
389
393
|
def quantise_model(model: ChemBFN) -> nn.Module:
|
|
390
394
|
"""
|
|
391
395
|
Dynamic quantisation of the trained model to `torch.qint8` data type.
|
|
@@ -395,6 +399,7 @@ def quantise_model(model: ChemBFN) -> nn.Module:
|
|
|
395
399
|
:return: quantised model
|
|
396
400
|
:rtype: torch.nn.Module
|
|
397
401
|
"""
|
|
402
|
+
from torch.ao import quantization
|
|
398
403
|
from torch.ao.nn.quantized import dynamic
|
|
399
404
|
from torch.ao.nn.quantized.modules.utils import _quantize_weight
|
|
400
405
|
from torch.ao.quantization.qconfig import default_dynamic_qconfig
|
|
@@ -527,6 +532,24 @@ def quantise_model(model: ChemBFN) -> nn.Module:
|
|
|
527
532
|
return quantised_model
|
|
528
533
|
|
|
529
534
|
|
|
535
|
+
def quantise_model_(model: ChemBFN) -> None:
|
|
536
|
+
"""
|
|
537
|
+
In-place dynamic quantisation of the trained model to `int8` data type. \n
|
|
538
|
+
Due to some limitations of `torchao` module, it is slower than method previded by `torch.ao`.
|
|
539
|
+
|
|
540
|
+
:param model: trained ChemBFN model
|
|
541
|
+
:type model: bayesianflow_for_chem.model.ChemBFN
|
|
542
|
+
:return:
|
|
543
|
+
:rtype: None
|
|
544
|
+
"""
|
|
545
|
+
from torchao.quantization.quant_api import (
|
|
546
|
+
quantize_,
|
|
547
|
+
Int8DynamicActivationInt8WeightConfig,
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
quantize_(model, Int8DynamicActivationInt8WeightConfig())
|
|
551
|
+
|
|
552
|
+
|
|
530
553
|
class GeometryConverter:
|
|
531
554
|
"""
|
|
532
555
|
Converting between different 2D/3D molecular representations.
|
{bayesianflow_for_chem-1.4.1 → bayesianflow_for_chem-1.4.2}/bayesianflow_for_chem.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bayesianflow_for_chem
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.2
|
|
4
4
|
Summary: Bayesian flow network framework for Chemistry
|
|
5
5
|
Home-page: https://augus1999.github.io/bayesian-flow-network-for-chemistry/
|
|
6
6
|
Author: Nianze A. Tao
|
|
@@ -23,6 +23,7 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
License-File: LICENSE
|
|
24
24
|
Requires-Dist: rdkit>=2023.9.6
|
|
25
25
|
Requires-Dist: torch>=2.3.1
|
|
26
|
+
Requires-Dist: torchao>=0.12
|
|
26
27
|
Requires-Dist: numpy>=1.26.4
|
|
27
28
|
Requires-Dist: loralib>=0.1.2
|
|
28
29
|
Requires-Dist: lightning>=2.2.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|