From a119bd050de6d3841319f5691906e6f911d3a1be Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" <48687836+njzjz-bot@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:03:14 +0800 Subject: [PATCH 1/2] fix(lammps): support 2025 Kokkos API Backport conda-forge/deepmd-kit-feedstock patch 0002 at d02138263b0b30629fe28c68c8bcecc2b8644513. Agent: ChatGPT Model: GPT-5.6 Sol --- source/lmp/pair_deepmd_kokkos.cpp | 4 ++-- source/lmp/pair_deepmd_kokkos.h | 18 ++++++++++++++++-- source/lmp/pair_dpa4spin_kokkos.cpp | 4 ++-- source/lmp/pair_dpa4spin_kokkos.h | 18 ++++++++++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/source/lmp/pair_deepmd_kokkos.cpp b/source/lmp/pair_deepmd_kokkos.cpp index fe02503576..f54873dbe1 100644 --- a/source/lmp/pair_deepmd_kokkos.cpp +++ b/source/lmp/pair_deepmd_kokkos.cpp @@ -113,7 +113,7 @@ void PairDeepMDKokkos::unpack_reverse_comm(int n, template int PairDeepMDKokkos::pack_reverse_comm_kokkos( - int n, int first, DAT::tdual_double_1d& buf) { + int n, int first, DeepMDKokkosCommBuffer& buf) { auto d_buf = buf.template view(); if (reverse_virial) { auto reverse_virial_data = k_reverse_virial.template view(); @@ -141,7 +141,7 @@ int PairDeepMDKokkos::pack_reverse_comm_kokkos( template void PairDeepMDKokkos::unpack_reverse_comm_kokkos( - int n, DAT::tdual_int_1d list, DAT::tdual_double_1d& buf) { + int n, DAT::tdual_int_1d list, DeepMDKokkosCommBuffer& buf) { auto d_buf = buf.template view(); auto d_list = list.template view(); if (reverse_virial) { diff --git a/source/lmp/pair_deepmd_kokkos.h b/source/lmp/pair_deepmd_kokkos.h index 4a620d19d9..3e6b977ced 100644 --- a/source/lmp/pair_deepmd_kokkos.h +++ b/source/lmp/pair_deepmd_kokkos.h @@ -28,6 +28,14 @@ PairStyle(deepmd/kk/host,PairDeepMDKokkos); namespace LAMMPS_NS { +// LAMMPS 22Jul2025 exposes reverse-communication buffers as X_FLOAT; newer +// releases use a fixed double buffer for Kokkos pair styles. +#if LAMMPS_VERSION_NUMBER < 20260704 +using DeepMDKokkosCommBuffer = DAT::tdual_xfloat_1d; +#else +using DeepMDKokkosCommBuffer = DAT::tdual_double_1d; +#endif + // GPU-resident inference for exported ``.pt2`` models whose forward consumes // an explicit edge graph: both the graph-input form (a compact, unpadded // neighbor graph) and the edge-input form. Both are dispatched through @@ -64,10 +72,10 @@ class PairDeepMDKokkos : public PairDeepMD, public KokkosBase { // host-staged path. int pack_reverse_comm(int, int, double*) override; void unpack_reverse_comm(int, int*, double*) override; - int pack_reverse_comm_kokkos(int, int, DAT::tdual_double_1d&) override; + int pack_reverse_comm_kokkos(int, int, DeepMDKokkosCommBuffer&) override; void unpack_reverse_comm_kokkos(int, DAT::tdual_int_1d, - DAT::tdual_double_1d&) override; + DeepMDKokkosCommBuffer&) override; // Build the device edge graph of the edge-input schema from the Kokkos full // neighbor list, returning the edge count. Public because it launches @@ -101,8 +109,14 @@ class PairDeepMDKokkos : public PairDeepMD, public KokkosBase { // Per-atom energy accumulator (aliases the base Pair ``eatom`` host array so // downstream per-atom computes/dumps see it after the device-to-host sync). + // The transformed accumulator view was added after the 22Jul2025 release. +#if LAMMPS_VERSION_NUMBER < 20260704 + DAT::tdual_double_1d k_eatom; + typename AT::t_double_1d d_eatom; +#else DAT::ttransform_kkacc_1d k_eatom; typename AT::t_kkacc_1d d_eatom; +#endif int edge_capacity; // allocated edges in d_edge_index / d_edge_vec bool edge_vec_fp32; // model graph ABI consumes edge vectors in fp32 diff --git a/source/lmp/pair_dpa4spin_kokkos.cpp b/source/lmp/pair_dpa4spin_kokkos.cpp index 8ae618e752..f479b27559 100644 --- a/source/lmp/pair_dpa4spin_kokkos.cpp +++ b/source/lmp/pair_dpa4spin_kokkos.cpp @@ -115,7 +115,7 @@ void PairDPA4SpinKokkos::unpack_reverse_comm(int n, template int PairDPA4SpinKokkos::pack_reverse_comm_kokkos( - int n, int first, DAT::tdual_double_1d& buf) { + int n, int first, DPA4SpinKokkosCommBuffer& buf) { auto d_buf = buf.template view(); if (reverse_virial) { auto reverse_virial_data = k_reverse_virial.template view(); @@ -147,7 +147,7 @@ int PairDPA4SpinKokkos::pack_reverse_comm_kokkos( template void PairDPA4SpinKokkos::unpack_reverse_comm_kokkos( - int n, DAT::tdual_int_1d list, DAT::tdual_double_1d& buf) { + int n, DAT::tdual_int_1d list, DPA4SpinKokkosCommBuffer& buf) { auto d_buf = buf.template view(); auto d_list = list.template view(); if (reverse_virial) { diff --git a/source/lmp/pair_dpa4spin_kokkos.h b/source/lmp/pair_dpa4spin_kokkos.h index d4506693f0..0ea52af98b 100644 --- a/source/lmp/pair_dpa4spin_kokkos.h +++ b/source/lmp/pair_dpa4spin_kokkos.h @@ -28,6 +28,14 @@ PairStyle(dpa4spin/kk/host,PairDPA4SpinKokkos); namespace LAMMPS_NS { +// LAMMPS 22Jul2025 exposes reverse-communication buffers as X_FLOAT; newer +// releases use a fixed double buffer for Kokkos pair styles. +#if LAMMPS_VERSION_NUMBER < 20260704 +using DPA4SpinKokkosCommBuffer = DAT::tdual_xfloat_1d; +#else +using DPA4SpinKokkosCommBuffer = DAT::tdual_double_1d; +#endif + // GPU-resident inference for exported native-spin ``.pt2`` models whose forward // consumes the compact canonical graph: a dual-CSR neighbor topology with // uint32 indices and float32 edge vectors, plus the per-node magnetic moment. @@ -64,10 +72,10 @@ class PairDPA4SpinKokkos : public PairDPA4Spin, public KokkosBase { // overrides serve the host-staged path. int pack_reverse_comm(int, int, double*) override; void unpack_reverse_comm(int, int*, double*) override; - int pack_reverse_comm_kokkos(int, int, DAT::tdual_double_1d&) override; + int pack_reverse_comm_kokkos(int, int, DPA4SpinKokkosCommBuffer&) override; void unpack_reverse_comm_kokkos(int, DAT::tdual_int_1d, - DAT::tdual_double_1d&) override; + DPA4SpinKokkosCommBuffer&) override; // Gather the per-node magnetic moment from the Kokkos ``sp`` array. Public // because it launches an extended device lambda, which CUDA forbids inside @@ -94,8 +102,14 @@ class PairDPA4SpinKokkos : public PairDPA4Spin, public KokkosBase { // Per-atom energy accumulator (aliases the base Pair ``eatom`` host array so // downstream per-atom computes/dumps see it after the device-to-host sync). + // The transformed accumulator view was added after the 22Jul2025 release. +#if LAMMPS_VERSION_NUMBER < 20260704 + DAT::tdual_double_1d k_eatom; + typename AT::t_double_1d d_eatom; +#else DAT::ttransform_kkacc_1d k_eatom; typename AT::t_kkacc_1d d_eatom; +#endif bool reverse_virial; // reverse communication operates on centroid virial bool reverse_used_host; // force reverse communication selected host staging From 044d75b4e4119b0bb268a112bc7b1f86f0d7b24a Mon Sep 17 00:00:00 2001 From: njzjz-bot Date: Sun, 23 Aug 2026 21:09:53 +0800 Subject: [PATCH 2/2] fix(lammps): correct Kokkos API cutoff Use the 10Sep2025 release as the boundary for the double reverse-communication buffer and transformed energy accumulator APIs. Coding-Agent: Codex Codex-Version: codex-cli 0.149.0 Model: gpt-5.6-sol Reasoning-Effort: xhigh --- source/lmp/pair_deepmd_kokkos.h | 10 +++++----- source/lmp/pair_dpa4spin_kokkos.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/lmp/pair_deepmd_kokkos.h b/source/lmp/pair_deepmd_kokkos.h index 3e6b977ced..bd3689aedf 100644 --- a/source/lmp/pair_deepmd_kokkos.h +++ b/source/lmp/pair_deepmd_kokkos.h @@ -28,9 +28,9 @@ PairStyle(deepmd/kk/host,PairDeepMDKokkos); namespace LAMMPS_NS { -// LAMMPS 22Jul2025 exposes reverse-communication buffers as X_FLOAT; newer -// releases use a fixed double buffer for Kokkos pair styles. -#if LAMMPS_VERSION_NUMBER < 20260704 +// LAMMPS 22Jul2025 exposes reverse-communication buffers as X_FLOAT; starting +// with 10Sep2025, Kokkos pair styles use a fixed double buffer. +#if LAMMPS_VERSION_NUMBER < 20250910 using DeepMDKokkosCommBuffer = DAT::tdual_xfloat_1d; #else using DeepMDKokkosCommBuffer = DAT::tdual_double_1d; @@ -109,8 +109,8 @@ class PairDeepMDKokkos : public PairDeepMD, public KokkosBase { // Per-atom energy accumulator (aliases the base Pair ``eatom`` host array so // downstream per-atom computes/dumps see it after the device-to-host sync). - // The transformed accumulator view was added after the 22Jul2025 release. -#if LAMMPS_VERSION_NUMBER < 20260704 + // The transformed accumulator view was added in the 10Sep2025 release. +#if LAMMPS_VERSION_NUMBER < 20250910 DAT::tdual_double_1d k_eatom; typename AT::t_double_1d d_eatom; #else diff --git a/source/lmp/pair_dpa4spin_kokkos.h b/source/lmp/pair_dpa4spin_kokkos.h index 0ea52af98b..1485e6e336 100644 --- a/source/lmp/pair_dpa4spin_kokkos.h +++ b/source/lmp/pair_dpa4spin_kokkos.h @@ -28,9 +28,9 @@ PairStyle(dpa4spin/kk/host,PairDPA4SpinKokkos); namespace LAMMPS_NS { -// LAMMPS 22Jul2025 exposes reverse-communication buffers as X_FLOAT; newer -// releases use a fixed double buffer for Kokkos pair styles. -#if LAMMPS_VERSION_NUMBER < 20260704 +// LAMMPS 22Jul2025 exposes reverse-communication buffers as X_FLOAT; starting +// with 10Sep2025, Kokkos pair styles use a fixed double buffer. +#if LAMMPS_VERSION_NUMBER < 20250910 using DPA4SpinKokkosCommBuffer = DAT::tdual_xfloat_1d; #else using DPA4SpinKokkosCommBuffer = DAT::tdual_double_1d; @@ -102,8 +102,8 @@ class PairDPA4SpinKokkos : public PairDPA4Spin, public KokkosBase { // Per-atom energy accumulator (aliases the base Pair ``eatom`` host array so // downstream per-atom computes/dumps see it after the device-to-host sync). - // The transformed accumulator view was added after the 22Jul2025 release. -#if LAMMPS_VERSION_NUMBER < 20260704 + // The transformed accumulator view was added in the 10Sep2025 release. +#if LAMMPS_VERSION_NUMBER < 20250910 DAT::tdual_double_1d k_eatom; typename AT::t_double_1d d_eatom; #else