Skip to content

build: enable PyTorch ops by default#5577

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

build: enable PyTorch ops by default#5577
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:oc-dp-enable-pytorch-default

Conversation

@njzjz-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • Change the Python build backend so DP_ENABLE_PYTORCH defaults to 1.
  • Update the source-installation docs and related PyTorch OP guidance to describe the new default and the DP_ENABLE_PYTORCH=0 opt-out.
  • Adjust the PyTorch runtime rebuild hint now that source builds enable PyTorch C++ OPs by default.

Tests

  • python3 static assertions for the updated default and docs
  • python3 mocked backend.read_env.get_argument_from_env() check for default -DENABLE_PYTORCH=ON and explicit DP_ENABLE_PYTORCH=0 opt-out
  • python3 backend.find_pytorch() opt-out check
  • git diff --check

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

Summary by CodeRabbit

Release Notes

  • New Features

    • PyTorch customized C++ operations now enabled by default during source installation.
  • Documentation

    • Updated installation guides to reflect new default PyTorch behavior.
    • Users can disable PyTorch customized operations via environment variable if needed.
    • Updated error messages with revised installation guidance.

Set DP_ENABLE_PYTORCH to default to 1 in the Python build backend and update related installation guidance accordingly.

Authored 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: 0fbd651c-a535-483e-9983-2ff324591f0d

📥 Commits

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

📒 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 value is flipped from "0" to "1" in find_pytorch.py and read_env.py, making PyTorch C++ OP discovery and CMake flag generation enabled by default when the variable is unset. The version-mismatch error message in cxx_op.py and multiple documentation files are updated to match.

Changes

DP_ENABLE_PYTORCH enabled by default

Layer / File(s) Summary
Backend default flip and error message update
backend/find_pytorch.py, backend/read_env.py, deepmd/pt/cxx_op.py
find_pytorch() and get_argument_from_env() change the DP_ENABLE_PYTORCH fallback default from "0" to "1", enabling PyTorch when the variable is unset. The load_library() version-mismatch RuntimeError message replaces DP_ENABLE_PYTORCH=1 pip install ... guidance with pip install deepmd-kit --no-binary deepmd-kit.
Documentation aligned to new default
doc/install/install-from-source.md, doc/freeze/compress.md, doc/model/dpa2.md, doc/model/dpa3.md
All installation and model docs updated to state customized C++ OPs are enabled by default, instruct users to set DP_ENABLE_PYTORCH=0 to disable them, and change the documented default from 0 to 1.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

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 title 'build: enable PyTorch ops by default' accurately and concisely summarizes the main change in the pull request: modifying the build system to enable PyTorch operations by default.
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 (9292367).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5577      +/-   ##
==========================================
- 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