Skip to content

Conversation

@SigureMo
Copy link
Contributor

@SigureMo SigureMo commented Mar 21, 2025

In PaddlePaddle 3.0, we recommend to use backend option to instead of build_strategy.build_cinn_pass to enable our compiler CINN.

cc @HydrogenSulfate

Summary by CodeRabbit

  • Refactor
    • Streamlined the internal process for selecting the backend during training, reducing complexity while retaining functionality.

Copilot AI review requested due to automatic review settings March 21, 2025 02:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the API call in the training module to replace the deprecated build_strategy option with the backend option, aligning with PaddlePaddle 3.0 recommendations.

  • Removed instantiation of static.BuildStrategy and the use of build_cinn_pass
  • Introduced conditional assignment of the backend parameter when calling jit.to_static
Comments suppressed due to low confidence (1)

deepmd/pd/train/training.py:642

  • Ensure that passing None as the backend parameter correctly disables the CINN compilation, as intended in the new design.
backend = "CINN" if CINN else None

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 21, 2025

📝 Walkthrough

Walkthrough

The update simplifies the configuration of the JIT compilation backend within the Trainer.run method. The previous approach used a BuildStrategy object from a now-removed static import, whereas the updated implementation directly sets a backend variable based on the CINN flag. If CINN is enabled, the backend is assigned "CINN"; otherwise, it is set to None. This variable is then passed to jit.to_static when wrapping self.wrapper.forward. There are no changes to public entity declarations.

Changes

File Change Summary
deepmd/.../training.py Modified the run method in Trainer to remove the static import and BuildStrategy usage, instead directly setting the backend variable based on the CINN flag and passing it to jit.to_static.

Sequence Diagram(s)

sequenceDiagram
    participant T as Trainer.run
    participant B as Backend Decision
    participant J as jit.to_static
    participant W as Wrapper.forward

    T->>B: Check if CINN flag is enabled
    B-->>T: Return backend ("CINN" or None)
    T->>J: Call jit.to_static(wrapper.forward, backend)
    J->>W: Invoke wrapped forward method
    W-->>J: Return execution result
    J-->>T: Return wrapped outcome
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb06e4f and 76a0008.

📒 Files selected for processing (1)
  • deepmd/pd/train/training.py (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
deepmd/pd/train/training.py (5)
deepmd/pd/model/descriptor/se_a.py (2) (2)
  • forward (257-308)
  • forward (679-788)
deepmd/pd/model/descriptor/dpa1.py (1) (1)
  • forward (589-657)
deepmd/pd/train/wrapper.py (1) (1)
  • forward (138-184)
deepmd/pd/loss/ener.py (1) (1)
  • forward (125-349)
deepmd/pd/model/model/make_model.py (1) (1)
  • forward (596-613)
🔇 Additional comments (1)
deepmd/pd/train/training.py (1)

637-644: Simplified CINN configuration for JIT compilation.

The update aligns with PaddlePaddle 3.0's recommended approach by replacing the BuildStrategy object with a direct backend parameter. This is cleaner and follows current best practices.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@SigureMo SigureMo changed the title chore(pd): replace build_strategy with backend option in to_static API refactor(pd): replace build_strategy with backend option in to_static API Mar 21, 2025
@codecov
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.81%. Comparing base (bb06e4f) to head (76a0008).
Report is 79 commits behind head on devel.

Files with missing lines Patch % Lines
deepmd/pd/train/training.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #4664      +/-   ##
==========================================
- Coverage   84.81%   84.81%   -0.01%     
==========================================
  Files         692      692              
  Lines       66361    66360       -1     
  Branches     3539     3539              
==========================================
- Hits        56282    56281       -1     
+ Misses       8938     8937       -1     
- Partials     1141     1142       +1     

☔ View full report in Codecov by Sentry.
📢 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.

@njzjz
Copy link
Member

njzjz commented Mar 21, 2025

@HydrogenSulfate could you take a review?

@HydrogenSulfate
Copy link
Collaborator

LGTM

@njzjz njzjz enabled auto-merge March 21, 2025 04:46
@njzjz njzjz added this pull request to the merge queue Mar 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2025
@njzjz njzjz added this pull request to the merge queue Mar 21, 2025
github-merge-queue bot pushed a commit that referenced this pull request Mar 21, 2025
…tatic` API (#4664)

In PaddlePaddle 3.0, we recommend to use `backend` option to instead of
`build_strategy.build_cinn_pass` to enable our compiler `CINN`.

cc @HydrogenSulfate 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Streamlined the internal process for selecting the backend during
training, reducing complexity while retaining functionality.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2025
@njzjz njzjz added this pull request to the merge queue Mar 21, 2025
Merged via the queue into deepmodeling:devel with commit c9bfa79 Mar 21, 2025
60 checks passed
@SigureMo SigureMo deleted the replace-build-strategy-with-backend branch March 21, 2025 11:58
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