Skip to content

fix(lammps): register built-in KOKKOS styles - #6054

Open
Zhang-pchao wants to merge 1 commit into
deepmodeling:masterfrom
Zhang-pchao:codex/deepmd-kokkos-styles
Open

Zhang-pchao wants to merge 1 commit into
deepmodeling:masterfrom
Zhang-pchao:codex/deepmd-kokkos-styles

Conversation

@Zhang-pchao

@Zhang-pchao Zhang-pchao commented Oct 6, 2026 •

Copy link
Copy Markdown

Summary

Fix built-in DeePMD integration with LAMMPS versions that generate style registration source files as well as headers.

  • Place the PAIR_CLASS branch before the LMP_KOKKOS guard so LAMMPS style discovery finds both KOKKOS pair styles.
  • Keep the implementations and registrations conditional on the KOKKOS package.
  • Regenerate style source files when the LAMMPS CMake helper is available. Older versions retain their header-only path.

Validation

  • Built the native built-in integration against current LAMMPS develop (b7ad70cf956c), with MPI and the CPU KOKKOS Serial backend.
  • Verified lmp -h lists deepmd/kk, deepmd/kk/device, deepmd/kk/host, and the corresponding dpa4spin styles.
  • All applicable pre-commit hooks passed, including clang-format and cmake-format.

The build used an existing compatible DeePMD C library. This change affects style discovery and registration; it does not modify pair calculations. CUDA execution and a complete new DeePMD backend build were not part of this focused test.

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility when building with LAMMPS, including configurations that use Kokkos.
    • Style source files are now generated automatically when the build environment supports it.

CI follow-up (2026-10-07)

The exact-head Read the Docs build fails while installing doc/requirements.txt, before Sphinx runs: the selected PyTorch headers require C++20, while the current target baseline selects C++17. The same build-standard mismatch appears on all five related contribution heads (#6051 through #6055). Existing issue #6048 and PR #6049 already address this compatibility problem; this PR leaves that repair in its independent upstream review. The Read the Docs check remains failed until that dependency is resolved and the build is rerun. The exact-head pre-commit.ci check passes; GitHub Actions still require maintainer approval.

@github-actions github-actions Bot added the LAMMPS label Oct 6, 2026
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d9ffa14a-1b64-4936-9894-9367054a384c
📥 Commits

Reviewing files that changed from the base of the PR and between 7a9510d and 7d93082.

📒 Files selected for processing (3)
  • source/lmp/builtin.cmake
  • source/lmp/pair_deepmd_kokkos.h
  • source/lmp/pair_dpa4spin_kokkos.h

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The LAMMPS build configuration conditionally invokes generatestylesources with LAMMPS_STYLE_HEADERS_DIR. The DeepMD and DPA4Spin Kokkos headers adjust style-registration and implementation guards while retaining the implementation branches’ version-number check.

Changes

LAMMPS style integration

Layer / File(s) Summary
Kokkos pair-style registration and implementation guards
source/lmp/pair_deepmd_kokkos.h, source/lmp/pair_dpa4spin_kokkos.h
The headers keep pair-style registrations conditional on Kokkos. The implementation branches retain the LAMMPS_VERSION_NUMBER check.
Conditional style-source generation
source/lmp/builtin.cmake
CMake calls generatestylesources with LAMMPS_STYLE_HEADERS_DIR when the command is available.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: outisli

Merge Risk: ⚪ Minimal · up to 7d930

The change exposes the Kokkos pair styles to LAMMPS style discovery while keeping them guarded for KOKKOS builds. No concrete merge-blocking issue is established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: registering built-in KOKKOS styles with LAMMPS.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@njzjz-bot njzjz-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agent: dot

Reviewed exact head 7d93082. No blocking findings in the style-registration change.

Checked both header guard layouts against LAMMPS's current StyleHeaderUtils.cmake marker parser and the generated-style source integration in its CMakeLists.txt. PAIR_CLASS remains the registration branch, nested LMP_KOKKOS guards protect all six markers, and the implementation/version checks remain in the non-registration branch. Regenerating the style source files after RegisterStyles updates the same generated translation units already attached to the LAMMPS target; the COMMAND guard retains the older header-generation-only path.

Local validation: preprocessed both exact-head headers with PAIR_CLASS/LMP_KOKKOS enabled and observed the expected three registrations per header. With KOKKOS disabled, both registration and implementation branches preprocess to empty output. I did not rebuild LAMMPS, run pair calculations, or validate CUDA here; the author's Serial build is distinct from these focused checks.

@Zhang-pchao Zhang-pchao changed the title fix(lammps): register built-in KOKKOS styles with generated sources fix(lammps): register built-in KOKKOS styles Oct 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants