You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(lammps): load models on the GPU selected by Kokkos - #6154
Use the CUDA device selected by Kokkos when loading a model for deepmd/kk or dpa4spin/kk. This honors an explicit device selection even when it differs from the node-local MPI rank.
Tested on a two-A800 node with a single rank explicitly selecting GPU 1. Both styles loaded on the selected device. Two regression tests passed, including energy and force comparisons on devices 0 and 1.
No actionable comments were generated in the recent review.
Walkthrough
The LAMMPS pair styles now pass a selected model device during model initialization. Kokkos CUDA styles select the active CUDA device. A two-device integration test covers deepmd/kk and dpa4spin/kk.
The base pair styles default to the node rank. Kokkos CUDA overrides return the active CUDA device.
Pass the selected device to model initialization source/lmp/pair_deepmd.cpp, source/lmp/pair_dpa4spin.cpp
DeepMD single-model and ensemble initialization, and DPA4Spin initialization, now use model_device().
Two-device test and LAMMPS test setup source/lmp/tests/test_kokkos_model_device.py, source/install/test_lammps_kokkos.sh
The integration test checks GPU assignment and compares energies and forces for both Kokkos styles. The test setup builds the lmp target and prepends the build directory to PATH for the spin-test pytest invocation.
This change makes the Kokkos CUDA pair styles load the model on the GPU that Kokkos actually selected, instead of the node-local MPI rank's GPU. Other pair styles behave as before. No actionable merge-blocking risk was found, and a two-GPU integration test covers both Kokkos styles.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix(lammps): load models on the GPU selected by Kokkos" matches the main change. The diff makes DeePMD and DPA4Spin models initialize on the device Kokkos selects (via a new model_device() …
Linked Issues check
Issue #5994 requires that deepmd/kk and dpa4spin/kk load the model on the Kokkos-selected device. It also requires a two-GPU regression with an explicit nonzero Kokkos device for both styles. At the r…
Out of Scope Changes check
All changed files relate to #5994. The source changes in pair_deepmd.cpp/.h, pair_deepmd_kokkos.cpp/.h, pair_dpa4spin.cpp/.h, and pair_dpa4spin_kokkos.cpp/.h add model_device() and use it for model in…
Full details: Title check
Explanation
The title "fix(lammps): load models on the GPU selected by Kokkos" matches the main change. The diff makes DeePMD and DPA4Spin models initialize on the device Kokkos selects (via a new model_device() hook) instead of the node-local MPI rank's device. The title is short, specific, and names the affected component (lammps) and the behavior change. It does not name the dpa4spin/kk path explicitly, but that is a minor omission.
Full details: Linked Issues check
Explanation
Issue #5994 requires that deepmd/kk and dpa4spin/kk load the model on the Kokkos-selected device. It also requires a two-GPU regression with an explicit nonzero Kokkos device for both styles. At the reviewed head, source/lmp/pair_deepmd_kokkos.cpp defines PairDeepMDKokkos::model_device(). Under KOKKOS_ENABLE_CUDA with DeviceType equal to LMPDeviceType, it returns Kokkos::Cuda().cuda_device(). The PR summary states that PairDeepMD::settings and PairDPA4Spin::settings pass model_device() instead of get_node_rank() to model initialization. The PR summary also describes the matching override in pair_dpa4spin_kokkos.cpp. The issue states that PT-experimental loading computes gpu_id = gpu_rank % device_count. Passing the selected device index therefore loads the model on that device, which matches the accepted fix. The new test test_kokkos_model_device.py covers both styles on devices 0 and 1 and checks the device report, nonzero forces, and cross-device energy and force agreement. Limitations: the incremental diff from the previous reviewed head could not be read, so changes since the prior review were checked only through head file reads. The settings() call sites and DeepPotPTExpt.cc / NativeSpinPTExpt.cc were not read directly. The modulo mapping means a model_device() value at or above device_count would wrap. The Kokkos device comes from visible devices, so this does not affect the reported case.
Full details: Out of Scope Changes check
Explanation
All changed files relate to #5994. The source changes in pair_deepmd.cpp/.h, pair_deepmd_kokkos.cpp/.h, pair_dpa4spin.cpp/.h, and pair_dpa4spin_kokkos.cpp/.h add model_device() and use it for model initialization, which implements the issue. The change to source/install/test_lammps_kokkos.sh (lmp target and PATH for the spin pytest) supports the new regression test. The new file test_kokkos_model_device.py is the requested two-GPU regression. The summary reports no unrelated functional changes. The incremental diff could not be read, so the assessment relies on the PR summary and head file reads.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 341381e2-2530-4090-98c3-8b31d78a2bba
Commits
Reviewing files that changed from the base of the PR and between 5f3ea59 and 22d0c30.
Files selected for processing: 1
source/lmp/tests/test_kokkos_model_device.py
Files skipped from review as they are similar to previous changes: 1
source/lmp/tests/test_kokkos_model_device.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the CUDA device selected by Kokkos when loading a model for
deepmd/kkordpa4spin/kk. This honors an explicit device selection even when it differs from the node-local MPI rank.Tested on a two-A800 node with a single rank explicitly selecting GPU 1. Both styles loaded on the selected device. Two regression tests passed, including energy and force comparisons on devices 0 and 1.
Closes #5994.
Summary by CodeRabbit