Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking(pt): drop PyTorch 2.0 support #4383

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Nov 19, 2024

Fix #4382. See pytorch/pytorch@7e0c26d.

Summary by CodeRabbit

  • New Features

    • Updated minimum version requirement for PyTorch to "torch>=2.1.0" to ensure compatibility.
  • Documentation

    • Revised backend documentation to reflect the updated PyTorch version requirement from "2.0 or above" to "2.1 or above."

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.

@github-actions github-actions bot added the Docs label Nov 19, 2024
Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces updates to the find_pytorch.py file, specifically modifying the get_pt_requirement function to enforce a minimum version requirement of "torch>=2.1.0" for the PyTorch library. Additionally, the documentation in doc/backend.md is updated to reflect this new version requirement, changing it from "PyTorch 2.0 or above" to "PyTorch 2.1 or above". The overall structure and error handling of the functions remain unchanged.

Changes

File Change Summary
backend/find_pytorch.py Updated get_pt_requirement function to enforce a minimum version requirement of "torch>=2.1.0".
doc/backend.md Updated PyTorch version requirement from "2.0 or above" to "2.1 or above" in the documentation.

Possibly related PRs

  • docs: document plugin mechanisms and deepmd-gnn #4345: The changes in the documentation for the backend support in DeePMD-kit regarding the PyTorch version requirement are directly related to the updates made in the main PR, which also modifies the version requirement for PyTorch in the backend/find_pytorch.py file.

Suggested reviewers

  • wanghan-iapcm

Warning

Rate limit exceeded

@njzjz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f3c0442 and 44f9cbd.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f3c0442 and 44f9cbd.

📒 Files selected for processing (1)
  • backend/find_pytorch.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/find_pytorch.py

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

@njzjz njzjz added the breaking change Breaking changes that should notify users. label Nov 19, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
doc/backend.md (1)

23-23: LGTM! Consider adding migration notes.

The version requirement update aligns with the PR objective to drop PyTorch 2.0 support. Since this is a breaking change, consider adding migration instructions for users currently on PyTorch 2.0.

Add a note like:

[PyTorch](https://pytorch.org/) 2.1 or above is required.
+> **Note**: Support for PyTorch 2.0 has been dropped. If you're using PyTorch 2.0, please upgrade to PyTorch 2.1 or above.
While `.pth` and `.pt` are the same in the PyTorch package...
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between db2bc94 and f3c0442.

📒 Files selected for processing (2)
  • backend/find_pytorch.py (1 hunks)
  • doc/backend.md (1 hunks)

doc/backend.md Show resolved Hide resolved
backend/find_pytorch.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
doc/backend.md (1)

23-23: LGTM! Consider adding migration notes.

The version requirement update from PyTorch 2.0 to 2.1 is clearly documented. However, since this is a breaking change, consider adding migration notes to help users currently using PyTorch 2.0.

Add a note explaining:

  • Why PyTorch 2.0 support was dropped
  • Steps for users to upgrade their environment
  • Any potential compatibility issues to watch out for
backend/find_pytorch.py (1)

136-137: Consider enhancing the commit reference comment

The comment references a PyTorch commit but doesn't explain its significance. Consider adding a brief explanation of why this commit necessitates dropping PyTorch 2.0 support.

-# https://github.com/pytorch/pytorch/commit/7e0c26d4d80d6602aed95cb680dfc09c9ce533bc
+# PyTorch 2.1+ required due to [brief explanation] 
+# See: https://github.com/pytorch/pytorch/commit/7e0c26d4d80d6602aed95cb680dfc09c9ce533bc
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between db2bc94 and 44f9cbd.

📒 Files selected for processing (2)
  • backend/find_pytorch.py (1 hunks)
  • doc/backend.md (1 hunks)
🔇 Additional comments (2)
backend/find_pytorch.py (2)

Line range hint 89-138: Implementation looks good!

The get_pt_requirement function:

  • Handles CI builds with different CUDA versions appropriately
  • Uses PEP 440 version matching correctly
  • Has proper error handling and version parsing

137-137: Verify the impact of dropping PyTorch 2.0 support

The change from torch>=2a to torch>=2.1.0 is a breaking change that drops support for PyTorch 2.0. Let's verify the impact on the codebase.

✅ Verification successful

Let me analyze the PyTorch usage in the codebase further to understand version-specific dependencies.


PyTorch 2.1+ requirement is compatible with codebase

Based on the analysis of the codebase:

  • The code primarily uses PyTorch 2.x features, with version checks like if torch.__version__.startswith("2") for importing torch._dynamo
  • No specific PyTorch 2.0-only APIs or features are used
  • The codebase is already tested with PyTorch 2.2.0 as seen in third-party dependencies
  • Version-specific code is properly guarded with version checks

The change to require PyTorch 2.1+ is safe and aligns with the codebase's existing PyTorch usage patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for PyTorch version-specific code and imports that might need updates

# Search for PyTorch version checks or conditionals
echo "Searching for PyTorch version checks..."
rg -l "torch\.(version|__version__|cuda|backends)" 

# Search for PyTorch imports and usage
echo "Searching for PyTorch imports and usage..."
ast-grep --pattern 'import torch'
ast-grep --pattern 'from torch import'

# Search for any PyTorch version specifications in requirements or setup files
echo "Searching for PyTorch version specifications in requirements..."
fd -e txt -e cfg -e ini -e toml -e yaml -e yml -g "*require*" | xargs rg "torch"

Length of output: 9942


Script:

#!/bin/bash
# Check for PyTorch version-specific features or APIs
echo "Checking PyTorch version-specific features..."
rg -A 5 "torch\.__version__" 

# Check for any version-specific imports or features in PyTorch files
echo "Checking version-specific imports in PyTorch files..."
rg -A 3 "if torch\." 

# Check setup files and requirements for any PyTorch version constraints
echo "Checking setup files for PyTorch version..."
fd "setup.py|pyproject.toml" | xargs rg "torch"

# Check for any PyTorch version-specific documentation
echo "Checking documentation for PyTorch version requirements..."
fd -e md -e rst | xargs rg "torch.*[0-9]+\.[0-9]+\.[0-9]+"

Length of output: 6090

doc/backend.md Show resolved Hide resolved
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.50%. Comparing base (db2bc94) to head (44f9cbd).
Report is 3 commits behind head on devel.

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #4383   +/-   ##
=======================================
  Coverage   84.50%   84.50%           
=======================================
  Files         604      604           
  Lines       56944    56945    +1     
  Branches     3486     3487    +1     
=======================================
+ Hits        48120    48121    +1     
- Misses       7697     7698    +1     
+ Partials     1127     1126    -1     

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


🚨 Try these New Features:

@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue Nov 20, 2024
Merged via the queue into deepmodeling:devel with commit f9976dd Nov 20, 2024
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Breaking changes that should notify users. Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants