deepmodeling / deepmodeling/deepmd-kit

[BUG] DeepMD LAMMPS pair styles misinterpret comm_style tiled as CommBrick

Open
#5,995 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
2k
Forks
649
Avg merge
6d 18h
Merged PRs (30d)
15

Description

### Summary

The DeepMD LAMMPS pair styles accept `comm_style tiled` but unconditionally cast the active communicator to a `CommBrick`-derived helper and read brick-only protected fields. `CommTiled` stores the same concepts with different pointer ranks and layout, so the model receives invalid communication metadata.

This is present on `origin/master` at `8cfd46e37448`.

### Evidence

Examples of the unchecked casts are:

```cpp
commdata_ = (CommBrickDeepMD*)comm;
commdata_ = (CommBrickDPA4Spin*)comm;
```

in `source/lmp/pair_deepmd.cpp` and `source/lmp/pair_dpa4spin.cpp`. The Kokkos message-passing path reaches the same data through `PairDeepMD::make_comm_nlist()`.

`CommBrick` exposes one-dimensional swap arrays such as `int *sendnum`, `int *recvnum`, `int *firstrecv`, and `int **sendlist`. `CommTiled` instead stores per-swap/per-peer layouts such as `int **sendnum`, `int **recvnum`, `int **firstrecv`, and `int ***sendlist`. Reinterpreting a `CommTiled` object as `CommBrick` therefore yields garbage pointers rather than equivalent metadata.

### Trigger and impact

Use two or more ranks with:

```text
comm_style tiled
pair_style deepmd/kk
```

The with-communication artifact receives invalid send/receive lists. Host `deepmd`, `deepspin`, and `dpa4spin` also use the brick-only cast when constructing their neighbor-list communication metadata.

This can crash, fail inside the backend, or communicate incorrect features depending on the interpreted pointer values.

### Expected behavior

Until tiled metadata is explicitly flattened into the backend's `InputNlist` representation, these pair styles should detect and reject non-brick communication in `init_style()` with a clear error. A multi-rank regression should cover `comm_style tiled`.

---

Coding agent: Codex
Codex version: codex-cli 0.149.0
Model: gpt-5.6-sol
Reasoning effort: xhigh

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.