Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
962399b
feat(dpmodel): segment_max + numerically-stable mask-aware segment_so…
Jul 2, 2026
d3132d5
feat(dpmodel): center_edge_pairs primitive (shared by attention/angles)
Jul 2, 2026
05fbd8f
feat(dpmodel): graph-native se_atten transformer attention (attn_laye…
Jul 2, 2026
61285c6
test(pt_expt): graph attention make_fx (merge gate) + model force/vir…
Jul 2, 2026
298518e
test: binding-sel audit for graph-default attention models
Jul 2, 2026
ccefbbc
test(pt_expt): pin smooth off in neighbor-list dpa1 fixture (route pa…
Jul 2, 2026
1c28aa5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 2, 2026
9ab2f38
feat(dpmodel): make compact center_edge_pairs traceable via unbacked …
Jul 3, 2026
397c405
feat(pt_expt): graph-form .pt2 export for dpa1 attention (attn_layer …
Jul 3, 2026
67d140d
fix(dpmodel): cast edge_vec to descriptor precision in dpa1 call_graph
Jul 3, 2026
bf09b85
fix(dpmodel): shift masked values in segment_softmax to prevent segme…
Jul 3, 2026
7bf56b6
docs(pt_expt): document sel-independent smooth graph attention; refre…
Jul 4, 2026
d49b9cb
fix(pt_expt): fail fast on torch < 2.6 for graph attention tracing
Jul 4, 2026
7c65935
docs(pt_expt): numpydoc sections for check_graph_trace_torch_version
Jul 4, 2026
6fc45bd
test+docs: pin smooth-attention graph-vs-dense divergence; document t…
Jul 4, 2026
84aaef5
test(pt_expt): make CUDA graph-path tests device-robust
Jul 5, 2026
7dce94d
feat(dpmodel): canonical apply_pair_exclusion graph transform (decisi…
Jul 4, 2026
b6de180
fix(dpmodel): raise NotImplementedError in apply_pair_exclusion(compa…
Jul 4, 2026
fb5abdd
refactor(dpmodel): atomic-model pair exclusion via apply_pair_exclusion
Jul 4, 2026
d5a6b59
feat(dpmodel): dpa1 graph path supports exclude_types via apply_pair_…
Jul 4, 2026
f86eaa5
test(dpmodel/dpa1): parametrize exclude_types graph parity over attn_…
Jul 4, 2026
e402fb0
docs: remove stale exclude_types graph-ineligibility claims
Jul 4, 2026
3d84eec
feat(neighbor_graph): dispatcher-level pair_excl post-process (task 3b)
Jul 4, 2026
04b1f88
test(pt_expt): pair_exclude_types graph-vs-legacy parity + vacuity check
Jul 4, 2026
fe86dfe
docs: add notes on nv_graph_builder pair_excl oracle gap
Jul 4, 2026
1163175
test(pt_expt): graph-route exclude_types coverage (parity + make_fx)
Jul 4, 2026
7d97be2
test(pt_expt): descriptor-level exclude_types export + graph-vs-legac…
Jul 4, 2026
0e6243e
fix: add reduced-virial parity assertion in descriptor exclude_types …
Jul 4, 2026
0c1106c
fix(neighbor_graph): use logical_and+bool cast in apply_pair_exclusio…
Jul 4, 2026
5ba3b8a
feat(dpmodel): apply_pair_exclusion_nlist helper + pair_excl on build…
Jul 4, 2026
6569579
fix(dpmodel): guard edges+pair_excl, fix base docstring (A4 review)
Jul 4, 2026
875bda8
feat(pt_expt): serialize pair_exclude_types into .pt2 metadata + C++ …
Jul 4, 2026
73797ce
feat(api_cc): C++ pair-exclusion twins at the pt_expt ingestion seam
Jul 4, 2026
c192594
test(api_cc): gtest + gen script for C++ pair-exclusion seam (dpa1)
Jul 4, 2026
a0791a4
docs: exclude_types is graph-native; fix stale comments in _call_dens…
Jul 4, 2026
9eb787c
fix(spin): force legacy dense routing in SpinModel.call_common
Jul 4, 2026
9536220
fix(spin): explicit graph-lower opt-out on backbone descriptor
Jul 4, 2026
7108292
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2026
9f2c31a
fix(docs+review): numpydoc See Also->Notes for C++ cross-refs; addres…
Jul 5, 2026
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
19 changes: 19 additions & 0 deletions deepmd/dpmodel/array_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,25 @@ def xp_add_at(x: Array, indices: Array, values: Array) -> Array:
return x


def xp_hint_dynamic_size(x: Array) -> None:
"""Mark a data-dependent leading dimension as a valid size for torch.export.

Under symbolic tracing (``make_fx`` / ``torch.export``) the length of a
data-dependent array (e.g. the output of ``nonzero`` or a tensor-``repeat``)
is an UNBACKED SymInt; guarding Python control flow or allocations on it
raises ``GuardOnDataDependentSymNode``. ``torch._check_is_size`` registers
the ``>= 0`` size hint that lets the tracer treat it as a proper dimension
(recorded as a ``sym_constrain_range_for_size`` node, preserved by AOTI).

No-op for numpy / jax / eager-torch concrete shapes — safe to call
unconditionally from dpmodel code (torch imported lazily, torch arrays only).
"""
if array_api_compat.is_torch_array(x):
import torch

torch._check_is_size(x.shape[0])


def xp_maximum_at(x: Array, indices: Array, values: Array) -> Array:
"""Segment max-assign of values into x at the specified indices.

Expand Down
24 changes: 10 additions & 14 deletions deepmd/dpmodel/atomic_model/base_atomic_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import dataclasses
import functools
import math
from collections.abc import (
Expand All @@ -10,6 +9,10 @@
Any,
)

from deepmd.dpmodel.utils.neighbor_graph import (
apply_pair_exclusion,
)

if TYPE_CHECKING:
from deepmd.dpmodel.utils.neighbor_graph import (
NeighborGraph,
Expand All @@ -33,6 +36,7 @@
from deepmd.dpmodel.utils import (
AtomExcludeMask,
PairExcludeMask,
apply_pair_exclusion_nlist,
)
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
Expand Down Expand Up @@ -294,10 +298,9 @@ def forward_common_atomic(
xp = array_api_compat.array_namespace(extended_coord, extended_atype, nlist)
_, nloc, _ = nlist.shape
atype = xp_take_first_n(extended_atype, 1, nloc)
if self.pair_excl is not None:
pair_mask = self.pair_excl.build_type_exclude_mask(nlist, extended_atype)
# exclude neighbors in the nlist
nlist = xp.where(pair_mask == 1, nlist, -1)
# idempotent backstop: externally-supplied nlists (C++/LAMMPS, call_lower
# users) bypass the in-tree builders and land here still unfiltered.
nlist = apply_pair_exclusion_nlist(nlist, extended_atype, self.pair_excl)

ext_atom_mask = self.make_atom_mask(extended_atype)
ret_dict = self.forward_atomic(
Expand Down Expand Up @@ -330,7 +333,7 @@ def forward_common_atomic_graph(
``self.pair_excl is not None``, an edge-keep mask is ANDed into
``graph.edge_mask`` before the descriptor forward, so excluded type-pairs
contribute zero to the segment_sum. Descriptor-level ``exclude_types`` is
gated by ``uses_graph_lower()==False``.
handled inside the descriptor's ``call_graph`` (graph-native).

Parameters
----------
Expand All @@ -356,14 +359,7 @@ def forward_common_atomic_graph(
atype = xp.asarray(atype, device=array_api_compat.device(graph.edge_vec))
atom_mask = self.make_atom_mask(atype) # (N,) bool
atype_clamped = xp.where(atom_mask, atype, xp.zeros_like(atype))
if self.pair_excl is not None:
keep = self.pair_excl.build_edge_exclude_mask(
graph.edge_index, atype_clamped
)
graph = dataclasses.replace(
graph,
edge_mask=graph.edge_mask * xp.astype(keep, graph.edge_mask.dtype),
)
graph = apply_pair_exclusion(graph, atype_clamped, self.pair_excl)
ret_dict = self.forward_atomic_graph(
graph,
atype_clamped,
Expand Down
Loading
Loading