Skip to content

feat: enable PyTorch custom ops by default#5578

Open
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:openclaw/default-enable-pytorch
Open

feat: enable PyTorch custom ops by default#5578
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:openclaw/default-enable-pytorch

Conversation

@njzjz-bot

@njzjz-bot njzjz-bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • change the DP_ENABLE_PYTORCH build-time default from 0 to 1 in the build backend
  • update the install-from-source docs to describe PyTorch customized C++ OPs as enabled by default
  • adjust related model/compression docs so they no longer tell users to set DP_ENABLE_PYTORCH=1 explicitly

Tests

  • python3 -m py_compile backend/find_pytorch.py backend/read_env.py deepmd/pt/cxx_op.py
  • git diff --check
  • uv run --no-project --with dependency-groups --with packaging python smoke checks for default -DENABLE_PYTORCH=ON and explicit DP_ENABLE_PYTORCH=0 -> -DENABLE_PYTORCH=OFF

Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)

Summary by CodeRabbit

  • New Features

    • PyTorch backend customized C++ OPs now enabled by default when building from source.
  • Bug Fixes

    • Corrected error messages and installation guidance for PyTorch backend issues.
  • Documentation

    • Updated installation and model documentation to reflect PyTorch backend enabled by default.

Set the DP_ENABLE_PYTORCH build-time default to 1 so source builds include PyTorch customized C++ OPs unless explicitly disabled. Update the installation and model docs to describe the new default without over-emphasizing opt-out instructions.\n\nAuthored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4bc3bb60-d8fc-4e4f-8729-3465763315ac

📥 Commits

Reviewing files that changed from the base of the PR and between 95fa690 and 5ef0601.

📒 Files selected for processing (7)
  • backend/find_pytorch.py
  • backend/read_env.py
  • deepmd/pt/cxx_op.py
  • doc/freeze/compress.md
  • doc/install/install-from-source.md
  • doc/model/dpa2.md
  • doc/model/dpa3.md

📝 Walkthrough

Walkthrough

DP_ENABLE_PYTORCH default changed from "0" to "1" in find_pytorch.py and read_env.py, making PyTorch C++ OP discovery enabled by default during source builds. A runtime error message and four documentation files are updated accordingly to remove the explicit DP_ENABLE_PYTORCH=1 requirement.

Changes

PyTorch Enabled by Default

Layer / File(s) Summary
Build-time default change
backend/find_pytorch.py, backend/read_env.py
DP_ENABLE_PYTORCH default changed from "0" to "1" in both find_pytorch() (docstring fix included) and get_argument_from_env, enabling PyTorch discovery and CMake argument injection when the variable is unset.
Runtime error message
deepmd/pt/cxx_op.py
load_library's OSError rebuild guidance removes the DP_ENABLE_PYTORCH=1 prefix and corrects the pip command to pip install deepmd-kit --no-binary deepmd-kit.
Documentation updates
doc/install/install-from-source.md, doc/freeze/compress.md, doc/model/dpa2.md, doc/model/dpa3.md
All four docs replace instructions to set DP_ENABLE_PYTORCH=1 with a statement that the customized OP library is installed by default when building from source; the documented default value for the variable is updated from 0 to 1.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • deepmodeling/deepmd-kit#5263: Adds and clarifies DP_ENABLE_PYTORCH guidance in doc/model/dpa2.md, directly overlapping with the installation instructions modified in this PR.

Suggested labels

build, Docs

Suggested reviewers

  • wanghan-iapcm
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and accurately summarizes the main change: enabling PyTorch custom operators by default. It directly reflects the primary objective of changing the DP_ENABLE_PYTORCH default from 0 to 1 across build system, code, and documentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.14%. Comparing base (95fa690) to head (5ef0601).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5578      +/-   ##
==========================================
- Coverage   82.15%   82.14%   -0.01%     
==========================================
  Files         900      900              
  Lines      104140   104141       +1     
  Branches     4470     4470              
==========================================
- Hits        85553    85546       -7     
- Misses      17181    17186       +5     
- Partials     1406     1409       +3     

☔ 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant