From 0198c0fb2df4265343b3146443c42f34310431e5 Mon Sep 17 00:00:00 2001 From: luozijian Date: Tue, 8 Sep 2026 17:53:04 +0800 Subject: [PATCH 1/2] fix(lammps): register native-spin host pair style in plugin --- source/lmp/plugin/deepmdplugin.cpp | 9 +++++++++ .../test_lammps_dpa4spin_registration.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 source/lmp/tests/test_lammps_dpa4spin_registration.py diff --git a/source/lmp/plugin/deepmdplugin.cpp b/source/lmp/plugin/deepmdplugin.cpp index 9bc0b685d2..bda880df88 100644 --- a/source/lmp/plugin/deepmdplugin.cpp +++ b/source/lmp/plugin/deepmdplugin.cpp @@ -13,6 +13,7 @@ #endif #include "pair_deepmd.h" #include "pair_deepspin.h" +#include "pair_dpa4spin.h" #include "version.h" #if LAMMPS_VERSION_NUMBER >= 20220328 #include "pppm_dplr.h" @@ -22,6 +23,7 @@ using namespace LAMMPS_NS; static Pair* pairdeepmd(LAMMPS* lmp) { return new PairDeepMD(lmp); } static Pair* pairdeepspin(LAMMPS* lmp) { return new PairDeepSpin(lmp); } +static Pair* pairdpa4spin(LAMMPS* lmp) { return new PairDPA4Spin(lmp); } #ifdef LMP_KOKKOS // Runtime plugins do not consume the PairStyle declarations used by LAMMPS' @@ -109,6 +111,13 @@ extern "C" void lammpsplugin_init(void* lmp, void* handle, void* regfunc) { plugin.handle = handle; (*register_plugin)(&plugin, lmp); + plugin.style = "pair"; + plugin.name = "dpa4spin"; + plugin.info = "dpa4spin pair style " STR_GIT_SUMM; + plugin.author = "Tiancheng Li"; + plugin.creator.v1 = (lammpsplugin_factory1*)&pairdpa4spin; + (*register_plugin)(&plugin, lmp); + plugin.style = "compute"; plugin.name = "deeptensor/atom"; plugin.info = "compute deeptensor/atom " STR_GIT_SUMM; diff --git a/source/lmp/tests/test_lammps_dpa4spin_registration.py b/source/lmp/tests/test_lammps_dpa4spin_registration.py new file mode 100644 index 0000000000..b2bd14390b --- /dev/null +++ b/source/lmp/tests/test_lammps_dpa4spin_registration.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +"""Native-spin host registration does not require a model artifact.""" + +import os + +from lammps import ( + lammps, +) + + +def test_native_spin_host_style_is_registered() -> None: + """The plugin must expose the host style, not only Kokkos aliases.""" + lmp = lammps(cmdargs=["-log", "none", "-screen", "none"]) + try: + if plugin := os.environ.get("DEEPMD_TEST_PLUGIN"): + lmp.command(f"plugin load {plugin}") + assert lmp.has_style("pair", "dpa4spin") + finally: + lmp.close() From ab5b5a4b45513ab2a8a9fc225b4ce3ad6141d2bb Mon Sep 17 00:00:00 2001 From: LOGO127 Date: Wed, 16 Sep 2026 10:51:30 +0800 Subject: [PATCH 2/2] test(lammps): verify dpa4spin plugin provenance --- .../lmp/tests/test_lammps_dpa4spin_registration.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/lmp/tests/test_lammps_dpa4spin_registration.py b/source/lmp/tests/test_lammps_dpa4spin_registration.py index b2bd14390b..3e44940dfb 100644 --- a/source/lmp/tests/test_lammps_dpa4spin_registration.py +++ b/source/lmp/tests/test_lammps_dpa4spin_registration.py @@ -3,17 +3,24 @@ import os +import pytest from lammps import ( lammps, ) def test_native_spin_host_style_is_registered() -> None: - """The plugin must expose the host style, not only Kokkos aliases.""" + """The runtime plugin, rather than the host binary, must expose dpa4spin.""" + plugin = os.environ.get("DEEPMD_TEST_PLUGIN") + if not plugin: + pytest.skip("DEEPMD_TEST_PLUGIN is required to validate plugin registration") + lmp = lammps(cmdargs=["-log", "none", "-screen", "none"]) try: - if plugin := os.environ.get("DEEPMD_TEST_PLUGIN"): - lmp.command(f"plugin load {plugin}") + assert not lmp.has_style("pair", "dpa4spin"), ( + "host LAMMPS already provides dpa4spin; plugin provenance is ambiguous" + ) + lmp.command(f"plugin load {plugin}") assert lmp.has_style("pair", "dpa4spin") finally: lmp.close()