Skip to content

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

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

Zhang-pchao wants to merge 3 commits into
deepmodeling:masterfrom
Zhang-pchao:codex/deepmd-kokkos-styles

Conversation

@Zhang-pchao

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

Copy link
Copy Markdown
Contributor

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 build compatibility with LAMMPS, including configurations that use Kokkos. Pair styles can now be registered in supported Kokkos configurations, while implementation compilation remains subject to the required version check.
    • Style source files are generated automatically when the build environment supports it, helping ensure they are available during compatible builds.

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

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The LAMMPS build configuration conditionally calls generatestylesources. The DeepMD and DPA4Spin Kokkos headers separate pair-style registration guards from implementation guards. The test workflow configures Kokkos styles and checks their registrations.

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
Pair-style registration remains conditional on LMP_KOKKOS. The implementation branches retain the LAMMPS_VERSION_NUMBER requirement.
Conditional style-source generation
source/lmp/builtin.cmake
CMake calls generatestylesources with LAMMPS_STYLE_HEADERS_DIR when the command is available.
Kokkos registration workflow checks
.github/workflows/test_cc.yml
When PyTorch is enabled and memory-leak checking is disabled, the workflow checks out a pinned LAMMPS revision, configures Kokkos, preprocesses both pair-style headers, and checks the generated registrations.

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

Change: Bug fix

Merge Risk: Minimal · up to dd3c4

This change fixes discovery and registration of the built-in KOKKOS pair styles with newer LAMMPS versions, and adds a CI check for it. No merge-blocking issue was found. The remaining step is for maintainers to approve and run the pending CI checks.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(lammps): register built-in KOKKOS styles" matches the main change. The PR makes the PAIR_CLASS registration of the deepmd/kk and dpa4spin KOKKOS pair styles independent of the LMP_KOKKO…
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.
Full details: Title check

Explanation

The title "fix(lammps): register built-in KOKKOS styles" matches the main change. The PR makes the PAIR_CLASS registration of the deepmd/kk and dpa4spin KOKKOS pair styles independent of the LMP_KOKKOS guard, and it regenerates style sources when the LAMMPS CMake helper exists. The title names the fix and the affected component. It omits the source-generation change and the new CI job, but the PR objectives describe those as supporting parts of the same registration fix.

Finishing Touches

Generate unit tests (beta)

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2b69801d-7778-43c6-8f13-1889af026a14
Commits

Reviewing files that changed from the base of the PR and between 3327b87 and dd3c476.

Files selected for processing: 1

  • .github/workflows/test_cc.yml

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

@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
@Zhang-pchao

Copy link
Copy Markdown
Contributor Author

The CI run expired while waiting for approval, before any jobs started. Could you help approve and restart the checks when you have a chance? Thanks!

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.78%. Comparing base (5fac80e) to head (dd3c476).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6054      +/-   ##
==========================================
- Coverage   78.08%   77.78%   -0.30%     
==========================================
  Files        1213     1213              
  Lines      147712   147713       +1     
  Branches     5245     5240       -5     
==========================================
- Hits       115343   114905     -438     
- Misses      30390    30829     +439     
  Partials     1979     1979              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wanghan-iapcm wanghan-iapcm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR adapts the built-in LAMMPS Kokkos pair-style headers to the style-registry build and adds the generatestylesources hook to source/lmp/builtin.cmake. The mechanism is right — with the real LAMMPS generators, the previous layout emits the Kokkos registrations unguarded while the new one nests them correctly — but the built-in path this change targets has no automated coverage today, and that is what the inline comment is about.

Details inline.

Comment thread source/lmp/builtin.cmake Resolved

@wanghan-iapcm wanghan-iapcm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The built-in Kokkos registration fix is correct on every path I could verify. The reordered PAIR_CLASS / LMP_KOKKOS guards keep the class-definition branch and the LAMMPS_VERSION_NUMBER check intact for all four macro combinations, generatestylesources is invoked at the right point for LAMMPS versions that generate style sources (and skipped where the helper does not exist), and the new configure-only CI job reproduces the documented install step and rejects both regressions it names: a missing generator call and a reverted header layout.

My earlier objection about the built-in path having no CI coverage is addressed. The remaining observations are non-blocking coverage gaps, not defects: the assertions cover the six Kokkos keys only, the generated registration source is not compiled, and the older-LAMMPS fallback branch is not exercised. None of them affect the correctness of this change.

@wanghan-iapcm
wanghan-iapcm added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 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.

3 participants