Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ source/ # C++ source code and tests
- **Configuration**: Use `input_torch.json` format typically
- **Training**: `dp --pt train input_torch.json`
- **Requirements**: `torch` package
- **DPA4C-LR long-range variant**: model type `dpa4c_lr` with fitting type `dpa4c_lr` adds a non-periodic long-range term on top of the compact DPA4C descriptor (`deepmd/pt_expt/model/dpa4c_lr_model.py`, `deepmd/pt_expt/fitting/dpa4c_lr.py`). Two kernels are available: `les` (`erf(alpha*r)/r`, the default) and a trainable sum-of-Gaussians `sog` with multi-channel latent charges. Only non-periodic systems are supported — `box=None` or an all-zero box is accepted, while nonzero periodic cells are rejected — and only the `pt_expt` backend. The long-range all-pairs graph is built outside the compiled region and passed into the graph lower alongside the short-range graph, so `torch.compile` sees no data-dependent neighbor construction; it is built ragged-native with unordered pairs (`i < j`, `build_all_pairs_unordered_graph` in `deepmd/pt_expt/utils/graph_builder.py`) straight from the per-frame node counts — no cutoff search, no padding to the batch max width, and half the directed pair storage (`Σ_f n_f(n_f-1)/2`). `.pt2`/`.pte` freeze is not yet implemented. Tests: `pytest source/tests/pt_expt/model/test_dpa4c_lr.py`.

### JAX Backend

Expand Down
11 changes: 6 additions & 5 deletions deepmd/dpmodel/descriptor/dpa4c.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,11 +1452,12 @@ def compute_input_stats(
for frame in self._calibration_frames(system):
coord = xp.asarray(frame["coord"], dtype=dtype, device=device)
atype = xp.asarray(frame["atype"], device=device)
box = (
None
if frame["box"] is None
else xp.asarray(frame["box"], dtype=dtype, device=device)
)
if frame["box"] is None:
box = None
else:
box = xp.asarray(frame["box"], dtype=dtype, device=device)
if xp.all(box == 0):
box = None
spin = (
None
if frame["spin"] is None
Expand Down
4 changes: 4 additions & 0 deletions deepmd/dpmodel/fitting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from .dpa4_ener import (
SeZMEnergyFittingNet,
)
from .dpa4c_lr import (
DPA4CLRFitting,
)
from .ener_fitting import (
EnergyFittingNet,
)
Expand All @@ -26,6 +29,7 @@

__all__ = [
"DOSFittingNet",
"DPA4CLRFitting",
"DipoleFitting",
"EnergyFittingNet",
"InvarFitting",
Expand Down
Loading
Loading