Skip to content

Commit 9b22217

Browse files
author
Han Wang
committed
docs(dpa4): final-review fix batch — stale docstrings, dead param, error-site wording
Six cosmetic/doc/dead-code fixes, zero behavior change: - test_dpa4_call_graph.py: reword build_sparse_edges_from_nlist docstring to describe the graph-route edge contract instead of the deleted DescrptDPA4.call_with_edges API. - edge_cache.py: drop the dead atype_flat parameter from _edge_cache_from_arrays (unused in the body); update both call sites (dpa4.py::_call_graph_impl, test_dpa4_dpmodel_parity.py). - dpa4.py: correct _call_graph_impl's Returns docstring to the actual (n_out_nodes, 1, 1, channels) shape (callers flatten the SO(3) singleton axes), matching _call_graph_common's docstring. - test_lammps_dpa4_pt2.py: reword the stale 'with-comm dispatch exercised at single-rank level' paragraph — DPA4 has no with-comm artifact at all. - doc/model/dpa4.md: correct three occurrences of 'raises an error at pair-style setup' to 'raises an error at the first force evaluation' (the C++ raise fires in the compute dispatch, not at setup time). - main.py: update --lower-kind help text from the stale 'currently dpa1 with attn_layer=0' to a generic graph-eligible-models description.
1 parent fd76e45 commit 9b22217

7 files changed

Lines changed: 22 additions & 22 deletions

File tree

deepmd/dpmodel/descriptor/dpa4.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,8 +1391,10 @@ def _call_graph_impl(
13911391
Returns
13921392
-------
13931393
tuple[Array, Array]
1394-
Flat ``(n_out_nodes, channels)`` read-out in global precision and
1395-
the full multipole feature tensor ``x``.
1394+
Read-out with the SO(3) singleton axes still attached, shape
1395+
``(n_out_nodes, 1, 1, channels)``, in global precision, and the
1396+
full multipole feature tensor ``x``. Callers (``_call_graph_common``
1397+
and its callers in turn) flatten the singleton axes.
13961398
"""
13971399
xp = array_api_compat.array_namespace(edge_vec)
13981400
device = array_api_compat.device(edge_vec)
@@ -1421,7 +1423,6 @@ def _call_graph_impl(
14211423
# === Step 3. Build edge cache once (sparse edges) ===
14221424
edge_cache = _edge_cache_from_arrays(
14231425
type_ebed=type_ebed,
1424-
atype_flat=atype_flat,
14251426
edge_index=edge_index,
14261427
edge_vec=edge_vec,
14271428
edge_mask=edge_mask,

deepmd/dpmodel/descriptor/dpa4_nn/edge_cache.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ def compute_edge_src_gate(
230230
def _edge_cache_from_arrays(
231231
*,
232232
type_ebed: Any,
233-
atype_flat: Any,
234233
edge_index: Any,
235234
edge_vec: Any,
236235
edge_mask: Any,
@@ -258,8 +257,6 @@ def _edge_cache_from_arrays(
258257
----------
259258
type_ebed
260259
Per-node type embedding with shape (N, C), where N=nf*nloc.
261-
atype_flat
262-
Flattened local atom types with shape (N,).
263260
edge_index
264261
Edge indices with shape (2, E).
265262
edge_vec

deepmd/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,9 @@ def main_parser() -> argparse.ArgumentParser:
363363
choices=["nlist", "graph"],
364364
help="(Supported backend: PyTorch Exportable) Lower-level export form of the "
365365
"frozen .pt2: 'nlist' (default, dense neighbor-list lower) or 'graph' "
366-
"(NeighborGraph edge-list lower; only for graph-eligible models, currently "
367-
"dpa1 with attn_layer=0). 'graph' selects the C++ graph inference path.",
366+
"(NeighborGraph edge-list lower; only for graph-eligible models, i.e. "
367+
"descriptors implementing the NeighborGraph lower, e.g. DPA1/DPA2/DPA4). "
368+
"'graph' selects the C++ graph inference path.",
368369
)
369370

370371
# * test script ********************************************************************

doc/model/dpa4.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ pair_coeff * * O H
437437
features at every interaction block, but no export path (dense or
438438
graph-native) implements the cross-rank ghost-feature exchange yet, so no
439439
`.pt2` archive carries a with-comm artifact. A multi-rank LAMMPS run raises an
440-
error at pair-style setup instead of silently running without the cross-rank
441-
exchange. Use a single MPI rank (one process, optionally with one GPU) for
440+
error at the first force evaluation instead of silently running without the
441+
cross-rank exchange. Use a single MPI rank (one process, optionally with one GPU) for
442442
DPA4/SeZM until cross-rank support ships. The remainder of this subsection
443443
describes the intended multi-rank workflow for when that support lands.
444444
:::
@@ -504,8 +504,8 @@ error at freeze time instead of exporting a silently-dense-only artifact.
504504
Like the dense route (see [Multi-GPU (MPI)
505505
inference](#multi-gpu-mpi-inference) above), the graph route does not
506506
implement cross-rank ghost exchange, so a graph-frozen `.pt2` is single-rank
507-
only; multi-rank LAMMPS runs raise an error at pair-style setup for both
508-
lower kinds.
507+
only; multi-rank LAMMPS runs raise an error at the first force evaluation for
508+
both lower kinds.
509509

510510
## Embedding extraction
511511

@@ -623,7 +623,7 @@ closed over the one-hop neighbor shell.
623623
- Export uses `.pt2` (AOTInductor); the TorchScript freeze path is not used.
624624
- Model compression is not supported.
625625
- Multi-rank (multi-GPU/MPI) LAMMPS inference is not currently supported and
626-
fails fast at pair-style setup; run on a single MPI rank. See
626+
fails fast at the first force evaluation; run on a single MPI rank. See
627627
[Multi-GPU (MPI) inference](#multi-gpu-mpi-inference).
628628
- The pt_expt graph-native inference route (`--lower-kind graph`) is
629629
single-rank only and unavailable for spin, charge/spin conditioning, or ZBL

source/lmp/tests/test_lammps_dpa4_pt2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
- virial / type_map / real-units / si-units variants mirror the dpa3
2828
single-rank set.
2929
30-
Deferred (NOT covered): live multi-rank parity. DPA4 multi-rank
31-
inference is out of PR-3 scope and has no mpi runner script. The C++
32-
with-comm dispatch is exercised for DPA4 only at the single-rank level
33-
here; multi-rank DPA4 is left to a follow-up.
30+
Deferred (NOT covered): live multi-rank parity. DPA4's ``.pt2`` archive
31+
carries no with-comm artifact, so multi-rank LAMMPS inference fails fast
32+
at the first force evaluation instead of running (see the module-level
33+
note); there is no with-comm dispatch to exercise here, and no mpi runner
34+
script. Multi-rank DPA4 support is left to a follow-up.
3435
3536
Tolerances match test_lammps_dpa3_pt2.py exactly (pytest.approx defaults
3637
for pe/forces; per-atom virial compared with pytest.approx).

source/tests/common/dpmodel/test_dpa4_call_graph.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ def build_sparse_edges_from_nlist(coord, nlist):
5252
"""Extract the valid physical edges of a padded neighbor list.
5353
5454
The padded layout keeps one slot per neighbor (``-1`` marks padding). The
55-
sparse contract for :meth:`DescrptDPA4.call_with_edges` is one explicit edge
56-
per kept slot, indexing the flattened frame-major node axis
57-
(``node = f * nloc + i``). The edge vector points from the center toward the
58-
neighbor, matching the padded path's ``r_j - r_i``.
55+
graph-route edge contract -- edges packed into a :class:`NeighborGraph`
56+
and consumed by ``call_graph`` -- is one explicit edge per kept slot,
57+
indexing the flattened frame-major node axis (``node = f * nloc + i``).
58+
The edge vector points from the center toward the neighbor, matching the
59+
padded path's ``r_j - r_i``.
5960
6061
Parameters
6162
----------

source/tests/pt/model/test_dpa4_dpmodel_parity.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,6 @@ def _dp_cache_from_padded(
28902890
edge_mask = np.asarray(graph.edge_mask) & pair_keep_mask.reshape(-1)
28912891
cache = _edge_cache_from_arrays(
28922892
type_ebed=type_ebed,
2893-
atype_flat=np.zeros(nf * nloc, dtype=np.int64),
28942893
edge_index=graph.edge_index,
28952894
edge_vec=graph.edge_vec,
28962895
edge_mask=edge_mask,

0 commit comments

Comments
 (0)