Skip to content

[BUG] deepmd/kk silently ignores spin atoms instead of rejecting them #5996

Open

Description

@njzjz-bot

Summary

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:

atom_style spin/kk
pair_style deepmd/kk <ordinary-model.pt2>

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.


Coding agent: Codex
Codex version: codex-cli 0.149.0
Model: gpt-5.6-sol
Reasoning effort: xhigh

Activity

  1. dosubot commented on Aug 23, 2026

    @dosubot

    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.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about deepmd-kit with Dosu Add Dosu to your team

  2. added 2 commits that reference this issue on Sep 18, 2026
    4cba7be
    6f5031f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions