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
[BUG] deepmd/kk silently ignores spin atoms instead of rejecting them #5996
The host deepmd pair style rejects spin atoms and tells the user to select a spin-aware pair style. The deepmd/kk compute override omits that guard, so an ordinary model can run with atom_style spin/kk while silently ignoring every atom's spin state.
This is present on origin/master at 8cfd46e37448.
Evidence
PairDeepMD::compute() contains:
if (atom->sp_flag) {
error->all(FLERR,
"Pair style 'deepmd' does not support spin atoms, please use ""pair style 'deepspin' instead.");
}
PairDeepMDKokkos::compute() overrides the entire host compute path and never performs this check. Its device graph is built only from coordinates and atom types; it neither consumes atom->sp nor produces atom->fm.
Trigger and impact
Run an ordinary edge-, graph-, or canonical-input .pt2 model with:
Unlike pair_style deepmd, initialization and compute proceed. Changing magnetic moments has no effect, and no magnetic force is produced, which can silently yield invalid spin dynamics.
Expected behavior
PairDeepMDKokkos::init_style() or compute() should apply the same atom->sp_flag rejection as the host path. A regression should compare deepmd and deepmd/kk behavior for a spin atom style.
I confirmed the bug by reading pair_deepmd_kokkos.cpp on master directly.
The PairDeepMDKokkos::compute() method (web_page:5494d20d) begins with:
ev_init(eflag, vflag);
if (vflag_atom) {
error->all(FLERR, "6-element atomic virial is not supported ...");
}
There is no atom->sp_flag check anywhere in compute() or init_style(). By contrast, PairDeepMD::compute() checks at the very top :
if (atom->sp_flag) {
error->all(FLERR,
"Pair style 'deepmd' does not support spin atoms, please use ""pair style 'deepspin' instead.");
}
The same guard also exists in pack_reverse_comm() and unpack_reverse_comm() of the host path, but PairDeepMDKokkos overrides both methods with its own Kokkos device/virial logic and neither copy includes the sp_flag check [1].
The fix is straightforward — add the guard near the top of PairDeepMDKokkos::compute(), right after ev_init:
if (atom->sp_flag) {
error->all(FLERR,
"Pair style 'deepmd/kk' does not support spin atoms, please ""use pair style 'deepspin' instead.");
}
Optionally the same check can be added to init_style() so it fails at setup time rather than at the first step. Note that init_style() calls PairDeepMD::init_style() which does not contain the spin guard either — that guard only lives in compute() — so adding it to init_style() would be a net improvement for both paths.
This is one of several parity gaps between deepmd and deepmd/kk that have surfaced recently (e.g. the vflag_global vs vflag_either virial issue in #5983 and the GPU device mismatch in #5994), all traceable to the Kokkos path introduced in PR #5758.
Activity
dosubot commentedon Aug 23, 2026
I confirmed the bug by reading
pair_deepmd_kokkos.cppon master directly.The
PairDeepMDKokkos::compute()method (web_page:5494d20d) begins with:There is no
atom->sp_flagcheck anywhere incompute()orinit_style(). By contrast,PairDeepMD::compute()checks at the very top :The same guard also exists in
pack_reverse_comm()andunpack_reverse_comm()of the host path, butPairDeepMDKokkosoverrides both methods with its own Kokkos device/virial logic and neither copy includes thesp_flagcheck [1].The fix is straightforward — add the guard near the top of
PairDeepMDKokkos::compute(), right afterev_init:Optionally the same check can be added to
init_style()so it fails at setup time rather than at the first step. Note thatinit_style()callsPairDeepMD::init_style()which does not contain the spin guard either — that guard only lives incompute()— so adding it toinit_style()would be a net improvement for both paths.This is one of several parity gaps between
deepmdanddeepmd/kkthat have surfaced recently (e.g. thevflag_globalvsvflag_eithervirial issue in #5983 and the GPU device mismatch in #5994), all traceable to the Kokkos path introduced in PR #5758.To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
Refuse spin atoms on deepmd/kk at init_style.
Add host/Kokkos spin-rejection parity for ordinary deepmd models.