kernelforge 0.3.1.dev51__cp315-cp315-macosx_26_0_arm64.whl
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.
- kernelforge/.dylibs/libomp.dylib +0 -0
- kernelforge/__init__.py +73 -0
- kernelforge/_cuda_hints.py +10 -0
- kernelforge/ase_calculator.py +174 -0
- kernelforge/cli.py +2259 -0
- kernelforge/cuda_fchl18_kernel.pyi +454 -0
- kernelforge/cuda_fchl18_repr.pyi +32 -0
- kernelforge/cuda_fchl19_repr.pyi +103 -0
- kernelforge/cuda_global_kernels.pyi +177 -0
- kernelforge/cuda_invdist_repr.pyi +51 -0
- kernelforge/cuda_local_kernels.pyi +376 -0
- kernelforge/cuda_rff_features.pyi +173 -0
- kernelforge/cuda_solvers.pyi +73 -0
- kernelforge/fchl18_kernel.cpython-315-darwin.so +0 -0
- kernelforge/fchl18_kernel.pyi +400 -0
- kernelforge/fchl18_repr.cpython-315-darwin.so +0 -0
- kernelforge/fchl18_repr.pyi +35 -0
- kernelforge/fchl19_repr.cpython-315-darwin.so +0 -0
- kernelforge/fchl19_repr.pyi +36 -0
- kernelforge/fchl19v2_repr.cpython-315-darwin.so +0 -0
- kernelforge/fchl19v2_repr.pyi +67 -0
- kernelforge/global_kernels.cpython-315-darwin.so +0 -0
- kernelforge/global_kernels.pyi +85 -0
- kernelforge/invdist_repr.cpython-315-darwin.so +0 -0
- kernelforge/invdist_repr.pyi +9 -0
- kernelforge/kernelcli.py +1034 -0
- kernelforge/kernelmath.cpython-315-darwin.so +0 -0
- kernelforge/kernelmath.pyi +46 -0
- kernelforge/kernelmd.py +255 -0
- kernelforge/kitchen_sinks.cpython-315-darwin.so +0 -0
- kernelforge/kitchen_sinks.pyi +146 -0
- kernelforge/local_kernels.cpython-315-darwin.so +0 -0
- kernelforge/local_kernels.pyi +218 -0
- kernelforge/md.py +189 -0
- kernelforge/models/__init__.py +60 -0
- kernelforge/models/base.py +424 -0
- kernelforge/models/cuda_fchl18_krr.py +407 -0
- kernelforge/models/cuda_global_krr.py +564 -0
- kernelforge/models/cuda_global_rff.py +377 -0
- kernelforge/models/cuda_local_krr.py +1085 -0
- kernelforge/models/cuda_local_rff.py +889 -0
- kernelforge/models/fchl18_krr.py +295 -0
- kernelforge/models/global_krr.py +313 -0
- kernelforge/models/global_rff.py +248 -0
- kernelforge/models/krr.py +324 -0
- kernelforge/models/representations.py +201 -0
- kernelforge/models/rff.py +299 -0
- kernelforge/py.typed +0 -0
- kernelforge-0.3.1.dev51.dist-info/METADATA +318 -0
- kernelforge-0.3.1.dev51.dist-info/RECORD +53 -0
- kernelforge-0.3.1.dev51.dist-info/WHEEL +6 -0
- kernelforge-0.3.1.dev51.dist-info/entry_points.txt +5 -0
- kernelforge-0.3.1.dev51.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
"""Type stubs for cuda_fchl18_kernel.
|
|
2
|
+
|
|
3
|
+
Current scope:
|
|
4
|
+
- fp32 and fp64
|
|
5
|
+
- rectangular energy-only kernel_gaussian
|
|
6
|
+
- symmetric energy-only kernel_gaussian_symm
|
|
7
|
+
- symmetric RFP kernel_gaussian_symm_rfp (TRANSR='N', UPLO='U')
|
|
8
|
+
- Jacobian kernel_gaussian_jacobian (dK/dR of the query molecules)
|
|
9
|
+
- Jacobian-T kernel_gaussian_jacobian_t (transposed store)
|
|
10
|
+
- Gradient kernel_gaussian_gradient (single-query, CPU G layout)
|
|
11
|
+
- Hessian kernel_gaussian_hessian (d2K/dR_A dR_B)
|
|
12
|
+
- Symmetric Hessian kernel_gaussian_hessian_symm / _symm_rfp
|
|
13
|
+
- Full combined kernel_gaussian_full / _symm / _symm_rfp
|
|
14
|
+
- inputs are precomputed FCHL18 representations on CUDA
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import torch
|
|
18
|
+
|
|
19
|
+
def kernel_gaussian(
|
|
20
|
+
x1: torch.Tensor,
|
|
21
|
+
x2: torch.Tensor,
|
|
22
|
+
n1: torch.Tensor,
|
|
23
|
+
n2: torch.Tensor,
|
|
24
|
+
nn1: torch.Tensor,
|
|
25
|
+
nn2: torch.Tensor,
|
|
26
|
+
sigma: float,
|
|
27
|
+
two_body_scaling: float = 2.0,
|
|
28
|
+
two_body_width: float = 0.1,
|
|
29
|
+
two_body_power: float = 6.0,
|
|
30
|
+
three_body_scaling: float = 2.0,
|
|
31
|
+
three_body_width: float = 3.0,
|
|
32
|
+
three_body_power: float = 3.0,
|
|
33
|
+
cut_start: float = 0.5,
|
|
34
|
+
cut_distance: float = 1e6,
|
|
35
|
+
fourier_order: int = 2,
|
|
36
|
+
use_atm: bool = True,
|
|
37
|
+
) -> torch.Tensor:
|
|
38
|
+
"""Compute the rectangular FCHL18 Gaussian kernel matrix on GPU.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
x1, x2 : torch.Tensor, shape (nm, max_size, 5, max_size), float32 or float64, CUDA
|
|
43
|
+
Precomputed FCHL18 representations. Dtypes must match.
|
|
44
|
+
n1, n2 : torch.Tensor, shape (nm,), int32, CUDA
|
|
45
|
+
Number of real atoms per molecule.
|
|
46
|
+
nn1, nn2 : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
47
|
+
Number of neighbors per atom.
|
|
48
|
+
sigma : float
|
|
49
|
+
Gaussian kernel length-scale.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
torch.Tensor, shape (nm1, nm2), same dtype as x1, CUDA
|
|
54
|
+
Rectangular energy-only kernel matrix.
|
|
55
|
+
"""
|
|
56
|
+
...
|
|
57
|
+
|
|
58
|
+
def kernel_gaussian_symm(
|
|
59
|
+
x: torch.Tensor,
|
|
60
|
+
n: torch.Tensor,
|
|
61
|
+
nn: torch.Tensor,
|
|
62
|
+
sigma: float,
|
|
63
|
+
two_body_scaling: float = 2.0,
|
|
64
|
+
two_body_width: float = 0.1,
|
|
65
|
+
two_body_power: float = 6.0,
|
|
66
|
+
three_body_scaling: float = 2.0,
|
|
67
|
+
three_body_width: float = 3.0,
|
|
68
|
+
three_body_power: float = 3.0,
|
|
69
|
+
cut_start: float = 0.5,
|
|
70
|
+
cut_distance: float = 1e6,
|
|
71
|
+
fourier_order: int = 2,
|
|
72
|
+
use_atm: bool = True,
|
|
73
|
+
) -> torch.Tensor:
|
|
74
|
+
"""Compute the symmetric FCHL18 Gaussian kernel matrix on GPU.
|
|
75
|
+
|
|
76
|
+
Only upper-triangle molecule pairs (a <= b) are evaluated; K[b,a] is mirrored.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
x : torch.Tensor, shape (nm, max_size, 5, max_size), float32 or float64, CUDA
|
|
81
|
+
Precomputed FCHL18 representations.
|
|
82
|
+
n : torch.Tensor, shape (nm,), int32, CUDA
|
|
83
|
+
Number of real atoms per molecule.
|
|
84
|
+
nn : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
85
|
+
Number of neighbors per atom.
|
|
86
|
+
sigma : float
|
|
87
|
+
Gaussian kernel length-scale.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
torch.Tensor, shape (nm, nm), same dtype as x, CUDA
|
|
92
|
+
Symmetric energy-only kernel matrix.
|
|
93
|
+
"""
|
|
94
|
+
...
|
|
95
|
+
|
|
96
|
+
def kernel_gaussian_symm_rfp(
|
|
97
|
+
x: torch.Tensor,
|
|
98
|
+
n: torch.Tensor,
|
|
99
|
+
nn: torch.Tensor,
|
|
100
|
+
sigma: float,
|
|
101
|
+
two_body_scaling: float = 2.0,
|
|
102
|
+
two_body_width: float = 0.1,
|
|
103
|
+
two_body_power: float = 6.0,
|
|
104
|
+
three_body_scaling: float = 2.0,
|
|
105
|
+
three_body_width: float = 3.0,
|
|
106
|
+
three_body_power: float = 3.0,
|
|
107
|
+
cut_start: float = 0.5,
|
|
108
|
+
cut_distance: float = 1e6,
|
|
109
|
+
fourier_order: int = 2,
|
|
110
|
+
use_atm: bool = True,
|
|
111
|
+
) -> torch.Tensor:
|
|
112
|
+
"""Compute the symmetric FCHL18 Gaussian kernel in RFP packed format on GPU.
|
|
113
|
+
|
|
114
|
+
Only upper-triangle molecule pairs (a <= b) are evaluated. Layout is
|
|
115
|
+
TRANSR='N', UPLO='U' (kf::rfp_index_upper_N). Compatible with
|
|
116
|
+
kernelmath.cho_solve_rfp. Unpack with:
|
|
117
|
+
kernelmath.rfp_to_full(K_rfp, nm, uplo='L', transr='N').
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
x : torch.Tensor, shape (nm, max_size, 5, max_size), float32 or float64, CUDA
|
|
122
|
+
Precomputed FCHL18 representations.
|
|
123
|
+
n : torch.Tensor, shape (nm,), int32, CUDA
|
|
124
|
+
Number of real atoms per molecule.
|
|
125
|
+
nn : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
126
|
+
Number of neighbors per atom.
|
|
127
|
+
sigma : float
|
|
128
|
+
Gaussian kernel length-scale.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
torch.Tensor, shape (nm*(nm+1)//2,), same dtype as x, CUDA
|
|
133
|
+
Upper-triangle RFP-packed energy-only kernel.
|
|
134
|
+
"""
|
|
135
|
+
...
|
|
136
|
+
|
|
137
|
+
def kernel_gaussian_jacobian(
|
|
138
|
+
x1: torch.Tensor,
|
|
139
|
+
x2: torch.Tensor,
|
|
140
|
+
n1: torch.Tensor,
|
|
141
|
+
n2: torch.Tensor,
|
|
142
|
+
nn1: torch.Tensor,
|
|
143
|
+
nn2: torch.Tensor,
|
|
144
|
+
coords1: torch.Tensor,
|
|
145
|
+
z1: torch.Tensor,
|
|
146
|
+
sigma: float,
|
|
147
|
+
two_body_scaling: float = 2.0,
|
|
148
|
+
two_body_width: float = 0.1,
|
|
149
|
+
two_body_power: float = 6.0,
|
|
150
|
+
three_body_scaling: float = 2.0,
|
|
151
|
+
three_body_width: float = 3.0,
|
|
152
|
+
three_body_power: float = 3.0,
|
|
153
|
+
cut_start: float = 0.5,
|
|
154
|
+
cut_distance: float = 1e6,
|
|
155
|
+
fourier_order: int = 2,
|
|
156
|
+
use_atm: bool = True,
|
|
157
|
+
) -> torch.Tensor:
|
|
158
|
+
"""Compute the FCHL18 Jacobian kernel dK/dR_A on GPU.
|
|
159
|
+
|
|
160
|
+
J[row, b] = dK(A_a, B_b) / dR_{A_a}[alpha, mu] with
|
|
161
|
+
row = row_offset[a] + alpha*3 + mu and row_offset[a] = 3 * sum_{a' < a} n1[a'].
|
|
162
|
+
Matches CPU ``kernelforge.fchl18_kernel.kernel_gaussian_jacobian``.
|
|
163
|
+
|
|
164
|
+
Unlike the CPU function, which takes raw coordinate lists and builds the query
|
|
165
|
+
representation internally, this takes a precomputed ``x1`` (as
|
|
166
|
+
``kernel_gaussian`` does) plus ``coords1``/``z1``. The coordinates are needed to
|
|
167
|
+
map each neighbour slot of the representation back to an atom index for the
|
|
168
|
+
chain rule; they must be the same padded coordinates the representation was
|
|
169
|
+
generated from.
|
|
170
|
+
|
|
171
|
+
Parameters
|
|
172
|
+
----------
|
|
173
|
+
x1, x2 : torch.Tensor, shape (nm, max_size, 5, max_size), float32 or float64, CUDA
|
|
174
|
+
Precomputed FCHL18 representations. Dtypes must match.
|
|
175
|
+
n1, n2 : torch.Tensor, shape (nm,), int32, CUDA
|
|
176
|
+
Number of real atoms per molecule.
|
|
177
|
+
nn1, nn2 : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
178
|
+
Number of neighbors per atom.
|
|
179
|
+
coords1 : torch.Tensor, shape (nm1, max_size1, 3), same dtype as x1, CUDA
|
|
180
|
+
Padded Cartesian coordinates of the query molecules.
|
|
181
|
+
z1 : torch.Tensor, shape (nm1, max_size1), int32, CUDA
|
|
182
|
+
Padded nuclear charges of the query molecules.
|
|
183
|
+
sigma : float
|
|
184
|
+
Gaussian kernel length-scale.
|
|
185
|
+
|
|
186
|
+
Returns
|
|
187
|
+
-------
|
|
188
|
+
torch.Tensor, shape (3 * sum(n1), nm2), same dtype as x1, CUDA
|
|
189
|
+
Jacobian of the energy kernel with respect to the query coordinates.
|
|
190
|
+
"""
|
|
191
|
+
...
|
|
192
|
+
|
|
193
|
+
def kernel_gaussian_jacobian_t(
|
|
194
|
+
x1: torch.Tensor,
|
|
195
|
+
x2: torch.Tensor,
|
|
196
|
+
n1: torch.Tensor,
|
|
197
|
+
n2: torch.Tensor,
|
|
198
|
+
nn1: torch.Tensor,
|
|
199
|
+
nn2: torch.Tensor,
|
|
200
|
+
coords1: torch.Tensor,
|
|
201
|
+
z1: torch.Tensor,
|
|
202
|
+
sigma: float,
|
|
203
|
+
two_body_scaling: float = 2.0,
|
|
204
|
+
two_body_width: float = 0.1,
|
|
205
|
+
two_body_power: float = 6.0,
|
|
206
|
+
three_body_scaling: float = 2.0,
|
|
207
|
+
three_body_width: float = 3.0,
|
|
208
|
+
three_body_power: float = 3.0,
|
|
209
|
+
cut_start: float = 0.5,
|
|
210
|
+
cut_distance: float = 1e6,
|
|
211
|
+
fourier_order: int = 2,
|
|
212
|
+
use_atm: bool = True,
|
|
213
|
+
) -> torch.Tensor:
|
|
214
|
+
"""Compute the FCHL18 Jacobian-T kernel on GPU.
|
|
215
|
+
|
|
216
|
+
Same computation as ``kernel_gaussian_jacobian``, but stores
|
|
217
|
+
``Jt[b, row] = dK(A_a, B_b) / dR_{A_a}[...]`` with shape ``(nm2, 3*sum(n1))``.
|
|
218
|
+
Matches CPU ``kernelforge.fchl18_kernel.kernel_gaussian_jacobian_t``.
|
|
219
|
+
"""
|
|
220
|
+
...
|
|
221
|
+
|
|
222
|
+
def kernel_gaussian_gradient(
|
|
223
|
+
x1: torch.Tensor,
|
|
224
|
+
x2: torch.Tensor,
|
|
225
|
+
n1: torch.Tensor,
|
|
226
|
+
n2: torch.Tensor,
|
|
227
|
+
nn1: torch.Tensor,
|
|
228
|
+
nn2: torch.Tensor,
|
|
229
|
+
coords1: torch.Tensor,
|
|
230
|
+
z1: torch.Tensor,
|
|
231
|
+
sigma: float,
|
|
232
|
+
two_body_scaling: float = 2.0,
|
|
233
|
+
two_body_width: float = 0.1,
|
|
234
|
+
two_body_power: float = 6.0,
|
|
235
|
+
three_body_scaling: float = 2.0,
|
|
236
|
+
three_body_width: float = 3.0,
|
|
237
|
+
three_body_power: float = 3.0,
|
|
238
|
+
cut_start: float = 0.5,
|
|
239
|
+
cut_distance: float = 1e6,
|
|
240
|
+
fourier_order: int = 2,
|
|
241
|
+
use_atm: bool = True,
|
|
242
|
+
) -> torch.Tensor:
|
|
243
|
+
"""Compute the FCHL18 gradient kernel for a single query molecule on GPU.
|
|
244
|
+
|
|
245
|
+
Requires ``nm1 == 1``. Returns ``G`` with shape ``(n_atoms_A, 3, nm2)`` matching
|
|
246
|
+
CPU ``kernelforge.fchl18_kernel.kernel_gaussian_gradient``.
|
|
247
|
+
"""
|
|
248
|
+
...
|
|
249
|
+
|
|
250
|
+
def kernel_gaussian_hessian(
|
|
251
|
+
x1: torch.Tensor,
|
|
252
|
+
x2: torch.Tensor,
|
|
253
|
+
n1: torch.Tensor,
|
|
254
|
+
n2: torch.Tensor,
|
|
255
|
+
nn1: torch.Tensor,
|
|
256
|
+
nn2: torch.Tensor,
|
|
257
|
+
coords1: torch.Tensor,
|
|
258
|
+
z1: torch.Tensor,
|
|
259
|
+
coords2: torch.Tensor,
|
|
260
|
+
z2: torch.Tensor,
|
|
261
|
+
sigma: float,
|
|
262
|
+
two_body_scaling: float = 2.0,
|
|
263
|
+
two_body_width: float = 0.1,
|
|
264
|
+
two_body_power: float = 6.0,
|
|
265
|
+
three_body_scaling: float = 2.0,
|
|
266
|
+
three_body_width: float = 3.0,
|
|
267
|
+
three_body_power: float = 3.0,
|
|
268
|
+
cut_start: float = 1.0,
|
|
269
|
+
cut_distance: float = 1e6,
|
|
270
|
+
fourier_order: int = 1,
|
|
271
|
+
use_atm: bool = False,
|
|
272
|
+
) -> torch.Tensor:
|
|
273
|
+
"""Compute the FCHL18 Hessian kernel d2K/dR_A dR_B on GPU.
|
|
274
|
+
|
|
275
|
+
``H[row, col] = d2K(A_a, B_b) / dR_{A_a}[alpha, mu] dR_{B_b}[beta, nu]`` with
|
|
276
|
+
``row = row_offset[a] + alpha*3 + mu``, ``col = col_offset[b] + beta*3 + nu``,
|
|
277
|
+
``row_offset[a] = 3 * sum_{a' < a} n1[a']`` and
|
|
278
|
+
``col_offset[b] = 3 * sum_{b' < b} n2[b']``.
|
|
279
|
+
Matches CPU ``kernelforge.fchl18_kernel.kernel_gaussian_hessian``.
|
|
280
|
+
|
|
281
|
+
Like ``kernel_gaussian_jacobian``, both sides take a precomputed representation
|
|
282
|
+
plus the padded coordinates and nuclear charges the representation was generated
|
|
283
|
+
from; those are needed to map neighbour slots back to atom indices for the chain
|
|
284
|
+
rule.
|
|
285
|
+
|
|
286
|
+
The underlying cross-Hessian is only exact when the cutoff is inactive
|
|
287
|
+
(``cut_start >= 1`` or ``cut_distance`` far beyond every interatomic distance)
|
|
288
|
+
and ``use_atm`` is False, matching the CPU implementation.
|
|
289
|
+
|
|
290
|
+
Parameters
|
|
291
|
+
----------
|
|
292
|
+
x1, x2 : torch.Tensor, shape (nm, max_size, 5, max_size), float32 or float64, CUDA
|
|
293
|
+
Precomputed FCHL18 representations. Dtypes must match.
|
|
294
|
+
n1, n2 : torch.Tensor, shape (nm,), int32, CUDA
|
|
295
|
+
Number of real atoms per molecule.
|
|
296
|
+
nn1, nn2 : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
297
|
+
Number of neighbors per atom.
|
|
298
|
+
coords1, coords2 : torch.Tensor, shape (nm, max_size, 3), same dtype as x1, CUDA
|
|
299
|
+
Padded Cartesian coordinates of each side's molecules.
|
|
300
|
+
z1, z2 : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
301
|
+
Padded nuclear charges of each side's molecules.
|
|
302
|
+
sigma : float
|
|
303
|
+
Gaussian kernel length-scale.
|
|
304
|
+
|
|
305
|
+
Returns
|
|
306
|
+
-------
|
|
307
|
+
torch.Tensor, shape (3 * sum(n1), 3 * sum(n2)), same dtype as x1, CUDA
|
|
308
|
+
Force-force block matrix, one dense (3*n1[a], 3*n2[b]) block per molecule pair.
|
|
309
|
+
"""
|
|
310
|
+
...
|
|
311
|
+
|
|
312
|
+
def kernel_gaussian_hessian_symm(
|
|
313
|
+
x: torch.Tensor,
|
|
314
|
+
n: torch.Tensor,
|
|
315
|
+
nn: torch.Tensor,
|
|
316
|
+
coords: torch.Tensor,
|
|
317
|
+
z: torch.Tensor,
|
|
318
|
+
sigma: float,
|
|
319
|
+
two_body_scaling: float = 2.0,
|
|
320
|
+
two_body_width: float = 0.1,
|
|
321
|
+
two_body_power: float = 6.0,
|
|
322
|
+
three_body_scaling: float = 2.0,
|
|
323
|
+
three_body_width: float = 3.0,
|
|
324
|
+
three_body_power: float = 3.0,
|
|
325
|
+
cut_start: float = 1.0,
|
|
326
|
+
cut_distance: float = 1e6,
|
|
327
|
+
fourier_order: int = 1,
|
|
328
|
+
use_atm: bool = False,
|
|
329
|
+
) -> torch.Tensor:
|
|
330
|
+
"""Compute the symmetric FCHL18 Hessian kernel on GPU.
|
|
331
|
+
|
|
332
|
+
Shape ``(D, D)`` with ``D = 3*sum(n)``. Matches CPU
|
|
333
|
+
``kernelforge.fchl18_kernel.kernel_gaussian_hessian_symm``.
|
|
334
|
+
"""
|
|
335
|
+
...
|
|
336
|
+
|
|
337
|
+
def kernel_gaussian_hessian_symm_rfp(
|
|
338
|
+
x: torch.Tensor,
|
|
339
|
+
n: torch.Tensor,
|
|
340
|
+
nn: torch.Tensor,
|
|
341
|
+
coords: torch.Tensor,
|
|
342
|
+
z: torch.Tensor,
|
|
343
|
+
sigma: float,
|
|
344
|
+
two_body_scaling: float = 2.0,
|
|
345
|
+
two_body_width: float = 0.1,
|
|
346
|
+
two_body_power: float = 6.0,
|
|
347
|
+
three_body_scaling: float = 2.0,
|
|
348
|
+
three_body_width: float = 3.0,
|
|
349
|
+
three_body_power: float = 3.0,
|
|
350
|
+
cut_start: float = 1.0,
|
|
351
|
+
cut_distance: float = 1e6,
|
|
352
|
+
fourier_order: int = 1,
|
|
353
|
+
use_atm: bool = False,
|
|
354
|
+
) -> torch.Tensor:
|
|
355
|
+
"""Compute the symmetric FCHL18 Hessian kernel in RFP format on GPU.
|
|
356
|
+
|
|
357
|
+
``TRANSR='N'``, ``UPLO='U'``. Length ``D*(D+1)/2`` with ``D = 3*sum(n)``.
|
|
358
|
+
Unpack with ``kernelmath.rfp_to_full(..., uplo='L', transr='N')``.
|
|
359
|
+
"""
|
|
360
|
+
...
|
|
361
|
+
|
|
362
|
+
def kernel_gaussian_full(
|
|
363
|
+
x1: torch.Tensor,
|
|
364
|
+
x2: torch.Tensor,
|
|
365
|
+
n1: torch.Tensor,
|
|
366
|
+
n2: torch.Tensor,
|
|
367
|
+
nn1: torch.Tensor,
|
|
368
|
+
nn2: torch.Tensor,
|
|
369
|
+
coords1: torch.Tensor,
|
|
370
|
+
z1: torch.Tensor,
|
|
371
|
+
coords2: torch.Tensor,
|
|
372
|
+
z2: torch.Tensor,
|
|
373
|
+
sigma: float,
|
|
374
|
+
two_body_scaling: float = 2.0,
|
|
375
|
+
two_body_width: float = 0.1,
|
|
376
|
+
two_body_power: float = 6.0,
|
|
377
|
+
three_body_scaling: float = 2.0,
|
|
378
|
+
three_body_width: float = 3.0,
|
|
379
|
+
three_body_power: float = 3.0,
|
|
380
|
+
cut_start: float = 1.0,
|
|
381
|
+
cut_distance: float = 1e6,
|
|
382
|
+
fourier_order: int = 1,
|
|
383
|
+
use_atm: bool = False,
|
|
384
|
+
) -> torch.Tensor:
|
|
385
|
+
"""Compute the full FCHL18 energy+force kernel matrix on GPU.
|
|
386
|
+
|
|
387
|
+
Block layout (``N_A=nm1``, ``N_B=nm2``, ``D_A=3*sum(n1)``, ``D_B=3*sum(n2)``):
|
|
388
|
+
``K[0:N_A, 0:N_B]`` scalar
|
|
389
|
+
``K[0:N_A, N_B:]`` jacobian_t (dK/dR_B)
|
|
390
|
+
``K[N_A:, 0:N_B]`` jacobian (dK/dR_A)
|
|
391
|
+
``K[N_A:, N_B:]`` hessian
|
|
392
|
+
|
|
393
|
+
Returns
|
|
394
|
+
-------
|
|
395
|
+
torch.Tensor, shape (N_A+D_A, N_B+D_B), same dtype as x1, CUDA
|
|
396
|
+
"""
|
|
397
|
+
...
|
|
398
|
+
|
|
399
|
+
def kernel_gaussian_full_symm(
|
|
400
|
+
x: torch.Tensor,
|
|
401
|
+
n: torch.Tensor,
|
|
402
|
+
nn: torch.Tensor,
|
|
403
|
+
coords: torch.Tensor,
|
|
404
|
+
z: torch.Tensor,
|
|
405
|
+
sigma: float,
|
|
406
|
+
two_body_scaling: float = 2.0,
|
|
407
|
+
two_body_width: float = 0.1,
|
|
408
|
+
two_body_power: float = 6.0,
|
|
409
|
+
three_body_scaling: float = 2.0,
|
|
410
|
+
three_body_width: float = 3.0,
|
|
411
|
+
three_body_power: float = 3.0,
|
|
412
|
+
cut_start: float = 1.0,
|
|
413
|
+
cut_distance: float = 1e6,
|
|
414
|
+
fourier_order: int = 1,
|
|
415
|
+
use_atm: bool = False,
|
|
416
|
+
) -> torch.Tensor:
|
|
417
|
+
"""Compute the symmetric full FCHL18 energy+force kernel on GPU.
|
|
418
|
+
|
|
419
|
+
Returns
|
|
420
|
+
-------
|
|
421
|
+
torch.Tensor, shape (N+D, N+D), same dtype as x, CUDA
|
|
422
|
+
with ``N=nm`` and ``D=3*sum(n)``.
|
|
423
|
+
"""
|
|
424
|
+
...
|
|
425
|
+
|
|
426
|
+
def kernel_gaussian_full_symm_rfp(
|
|
427
|
+
x: torch.Tensor,
|
|
428
|
+
n: torch.Tensor,
|
|
429
|
+
nn: torch.Tensor,
|
|
430
|
+
coords: torch.Tensor,
|
|
431
|
+
z: torch.Tensor,
|
|
432
|
+
sigma: float,
|
|
433
|
+
two_body_scaling: float = 2.0,
|
|
434
|
+
two_body_width: float = 0.1,
|
|
435
|
+
two_body_power: float = 6.0,
|
|
436
|
+
three_body_scaling: float = 2.0,
|
|
437
|
+
three_body_width: float = 3.0,
|
|
438
|
+
three_body_power: float = 3.0,
|
|
439
|
+
cut_start: float = 1.0,
|
|
440
|
+
cut_distance: float = 1e6,
|
|
441
|
+
fourier_order: int = 1,
|
|
442
|
+
use_atm: bool = False,
|
|
443
|
+
) -> torch.Tensor:
|
|
444
|
+
"""Compute the symmetric full FCHL18 kernel in RFP packed format on GPU.
|
|
445
|
+
|
|
446
|
+
TRANSR='N', UPLO='U'. Unpack with
|
|
447
|
+
``kernelmath.rfp_to_full(..., uplo='L', transr='N')``.
|
|
448
|
+
|
|
449
|
+
Returns
|
|
450
|
+
-------
|
|
451
|
+
torch.Tensor, shape (BIG*(BIG+1)//2,), same dtype as x, CUDA
|
|
452
|
+
with ``BIG = nm + 3*sum(n)``.
|
|
453
|
+
"""
|
|
454
|
+
...
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Type stubs for cuda_fchl18_repr — GPU FCHL18 representation generation."""
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
|
|
5
|
+
def generate(
|
|
6
|
+
coords: torch.Tensor,
|
|
7
|
+
z: torch.Tensor,
|
|
8
|
+
n: torch.Tensor,
|
|
9
|
+
cut_distance: float = 5.0,
|
|
10
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
11
|
+
"""Generate FCHL18 representations on the GPU.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
coords : torch.Tensor, shape (nm, max_size, 3), float32 or float64, CUDA
|
|
16
|
+
Padded Cartesian coordinates.
|
|
17
|
+
z : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
18
|
+
Padded nuclear charges.
|
|
19
|
+
n : torch.Tensor, shape (nm,), int32, CUDA
|
|
20
|
+
Active atom counts per molecule.
|
|
21
|
+
cut_distance : float, default 5.0
|
|
22
|
+
Neighbour cutoff radius in Angstrom.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
x : torch.Tensor, shape (nm, max_size, 5, max_size), same dtype as coords, CUDA
|
|
27
|
+
Representation. Layout per atom: [distances, Z-neighbours, dx, dy, dz].
|
|
28
|
+
Unused slots are filled with 1e100 (fp64) or 1e30 (fp32).
|
|
29
|
+
nn : torch.Tensor, shape (nm, max_size), int32, CUDA
|
|
30
|
+
Number of neighbours within cut_distance per atom (self at index 0).
|
|
31
|
+
"""
|
|
32
|
+
...
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Type stubs for cuda_fchl19_repr — GPU FCHL19 ACSF representation (FP32)."""
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
|
|
5
|
+
def generate_fchl_acsf(
|
|
6
|
+
coords: torch.Tensor,
|
|
7
|
+
Q: torch.Tensor,
|
|
8
|
+
N: torch.Tensor,
|
|
9
|
+
nelements: int,
|
|
10
|
+
nRs2: int = 24,
|
|
11
|
+
nRs3: int = 20,
|
|
12
|
+
nFourier: int = 1,
|
|
13
|
+
eta2: float = 0.32,
|
|
14
|
+
eta3: float = 2.7,
|
|
15
|
+
zeta: float = ...,
|
|
16
|
+
rcut: float = 8.0,
|
|
17
|
+
acut: float = 8.0,
|
|
18
|
+
two_body_decay: float = 1.8,
|
|
19
|
+
three_body_decay: float = 0.57,
|
|
20
|
+
three_body_weight: float = 13.4,
|
|
21
|
+
deterministic: bool = False,
|
|
22
|
+
) -> torch.Tensor:
|
|
23
|
+
"""Generate FCHL19 ACSF representations on the GPU (FP32).
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
coords : torch.Tensor, shape (nm, max_atoms, 3), float32, CUDA
|
|
28
|
+
Batched padded Cartesian coordinates.
|
|
29
|
+
Q : torch.Tensor, shape (nm, max_atoms), int32, CUDA
|
|
30
|
+
Element indices in [0, nelements).
|
|
31
|
+
N : torch.Tensor, shape (nm,), int32, CUDA
|
|
32
|
+
Active atom counts per molecule.
|
|
33
|
+
nelements : int
|
|
34
|
+
Number of distinct element types.
|
|
35
|
+
nRs2 : int, default 24
|
|
36
|
+
nRs3 : int, default 20
|
|
37
|
+
nFourier : int, default 1
|
|
38
|
+
eta2 : float, default 0.32
|
|
39
|
+
eta3 : float, default 2.7
|
|
40
|
+
zeta : float, default pi
|
|
41
|
+
rcut : float, default 8.0
|
|
42
|
+
acut : float, default 8.0
|
|
43
|
+
two_body_decay : float, default 1.8
|
|
44
|
+
three_body_decay : float, default 0.57
|
|
45
|
+
three_body_weight : float, default 13.4
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
rep : torch.Tensor, shape (nm, max_atoms, rep_size), float32, CUDA
|
|
50
|
+
Per-atom representations. Padded slots (i >= N[m]) are zeroed.
|
|
51
|
+
"""
|
|
52
|
+
...
|
|
53
|
+
|
|
54
|
+
def generate_fchl_acsf_and_gradients(
|
|
55
|
+
coords: torch.Tensor,
|
|
56
|
+
Q: torch.Tensor,
|
|
57
|
+
N: torch.Tensor,
|
|
58
|
+
nelements: int,
|
|
59
|
+
nRs2: int = 24,
|
|
60
|
+
nRs3: int = 20,
|
|
61
|
+
nFourier: int = 1,
|
|
62
|
+
eta2: float = 0.32,
|
|
63
|
+
eta3: float = 2.7,
|
|
64
|
+
zeta: float = ...,
|
|
65
|
+
rcut: float = 8.0,
|
|
66
|
+
acut: float = 8.0,
|
|
67
|
+
two_body_decay: float = 1.8,
|
|
68
|
+
three_body_decay: float = 0.57,
|
|
69
|
+
three_body_weight: float = 13.4,
|
|
70
|
+
deterministic: bool = False,
|
|
71
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
72
|
+
"""Generate FCHL19 ACSF representations and Jacobians on the GPU (FP32).
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
rep : torch.Tensor, shape (nm, max_atoms, rep_size), float32, CUDA
|
|
77
|
+
grad : torch.Tensor, shape (nm, max_atoms, rep_size, max_atoms, 3), float32, CUDA
|
|
78
|
+
"""
|
|
79
|
+
...
|
|
80
|
+
|
|
81
|
+
def generate_fchl_acsf_and_gradients_md_single(
|
|
82
|
+
coords: torch.Tensor,
|
|
83
|
+
Q: torch.Tensor,
|
|
84
|
+
N: torch.Tensor,
|
|
85
|
+
nelements: int,
|
|
86
|
+
nRs2: int = 24,
|
|
87
|
+
nRs3: int = 20,
|
|
88
|
+
nFourier: int = 1,
|
|
89
|
+
eta2: float = 0.32,
|
|
90
|
+
eta3: float = 2.7,
|
|
91
|
+
zeta: float = ...,
|
|
92
|
+
rcut: float = 8.0,
|
|
93
|
+
acut: float = 8.0,
|
|
94
|
+
two_body_decay: float = 1.8,
|
|
95
|
+
three_body_decay: float = 0.57,
|
|
96
|
+
three_body_weight: float = 13.4,
|
|
97
|
+
deterministic: bool = False,
|
|
98
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
99
|
+
"""Generate FCHL19 ACSF representations and Jacobians on the GPU (FP32).
|
|
100
|
+
|
|
101
|
+
This specialized path is intended for ``nm == 1`` inference workloads.
|
|
102
|
+
"""
|
|
103
|
+
...
|