Skip to content

fix: pass MDCell ghost communication plan to DeePMD - #8143

Merged
mohanchen merged 6 commits into
deepmodeling:developfrom
19hello:fix/issue-8108-mdcell-deepmd-comm
Oct 15, 2026
Merged

mohanchen merged 6 commits into
deepmodeling:developfrom
19hello:fix/issue-8108-mdcell-deepmd-comm

Conversation

@19hello

@19hello 19hello commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and case tests.
  • I have listed the exact verification commands and results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact.
  • No governance exception is requested.

Linked Issue

Fix #8108

Unit Tests and/or Case Tests for my changes

Configuration and build

cmake -S . -B /tmp/abacus-issue8108-deepmd-c-build2 \
  -DENABLE_MPI=ON \
  -DENABLE_LCAO=OFF \
  -DBUILD_TESTING=ON \
  -DDeePMD_DIR=/home/fy19/00_software/deepmd-kit-c \
  -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined

Result:

DeePMD_HAS_COMM_NLIST - Success

cmake --build /tmp/abacus-issue8108-deepmd-c-build2 \
  --target abacus_pw_para -j4

Result:

Built target abacus_pw_para

#### Domain decomposition tests

env LD_PRELOAD=/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblas.so.0 \
  /home/fy19/abacus-develop/toolchain/install/openmpi-5.0.10/bin/mpiexec \
  -n 4 \
  /tmp/abacus-issue8108-deepmd-c-build2/source/source_cell/module_neighlist/test/MODULE_CELL_NEIGHBOR_mdcell_migrate_mpi \
  --gtest_filter=DomainDecompositionTest.*

Result:

12 tests passed on 4 MPI ranks.

The focused GhostExchangePlanMatchesGhostLayout test also passed on 1 and 4 MPI ranks.

#### DeePMD MD case

Case:

md_test/test_for_XZC

Model:

B_graph_compress_new_op.pth

1-rank command:

env OMP_NUM_THREADS=1 \
  LD_PRELOAD=/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblas.so.0 \
  LD_LIBRARY_PATH=/home/fy19/00_software/deepmd-kit-c/lib:$LD_LIBRARY_PATH \
  /home/fy19/abacus-develop/toolchain/install/openmpi-5.0.10/bin/mpiexec \
  -n 1 \
  /tmp/abacus-issue8108-deepmd-c-build2/abacus_pw_para

4-rank command:

env OMP_NUM_THREADS=1 \
  LD_PRELOAD=/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblas.so.0 \
  LD_LIBRARY_PATH=/home/fy19/00_software/deepmd-kit-c/lib:$LD_LIBRARY_PATH \
  /home/fy19/abacus-develop/toolchain/install/openmpi-5.0.10/bin/mpiexec \
  -n 4 \
  /tmp/abacus-issue8108-deepmd-c-build2/abacus_pw_para

Result:

Both 1-rank and 4-rank MD cases completed 5 MD steps successfully.
The first-step energies agreed between 1-rank and 4-rank runs.
No ghost mapping or MPI communication error occurred.

Additional checks:

git diff --check

Result:

Passed

python3 tools/03_code_analysis/agent_governance_check.py --staged

Result:

No blocking findings.

#### Checks not run

- No explicit DPA-2/repformers model was available in the test case, so a model-specific regression was not run.
- The complete repository test suite was not run; focused module tests and the relevant DeePMD MD case were run instead.
- CI checks remain to be executed by the pull request workflow.

The MPI runs used OMP_NUM_THREADS=1 and an OpenBLAS preload to work around the host BLAS alternatives environment, which otherwise caused a gotoblas lookup failure.

### What's changed?

- Add GhostExchangePlan to describe the ghost communication metadata required by DeePMD.
- Make DomainDecomposition build the plan from its internal ghost exchange slots.
- Store the current plan in MDCell.
- Pass the communication metadata from MDCell to ESolver_DP.
- Construct the 13-argument communication-capable DeePMD InputNlist when supported.
- Preserve the original 4-argument InputNlist fallback for older DeePMD-kit APIs.
- Use mapping only for the single-rank path where periodic ghost atoms are folded onto local real atoms.
- Use the communication plan without local mapping for multi-rank runs.
- Reduce DeePMD API preprocessor duplication with the DPInputNlist type alias.
- Rename the interfaces to build_ghost_exchange_plan() and get_ghost_exchange_plan().
- Add unit coverage for the generated ghost exchange plan.

### Governance Notes

- INPUT/docs changes: None. No INPUT parameters or user-facing INPUT behavior were changed.
- Core module impact: This change affects ESolver_DP, MDCell, and DomainDecomposition. It does not modify HSolver, ElecState, Hamilt, Operator, or Psi.
- Header dependencies: GhostExchangePlan is kept in a small dedicated header so MDCell and DomainDecomposition can share the communication data type without including each other’s full headers.
- Exceptions requested: None.

Comment thread source/source_esolver/esolver_dp.cpp

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of ffd66c4: three API/build compatibility issues and two nonblocking follow-ups below. No builds or model runs were performed; CI diagnostics were unavailable through the selected-account connector.

Comment thread cmake/modules/FindDeePMD.cmake Outdated
Comment thread source/source_esolver/esolver_dp.cpp
Comment thread source/CMakeLists.txt Outdated
Comment thread source/source_cell/domain_decomposition.h Outdated
Comment thread source/source_cell/module_neighlist/test/test_domain_decomposition.cpp Outdated
@mohanchen
mohanchen merged commit 8ae37fc into deepmodeling:develop Oct 15, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes

Projects

None yet

3 participants