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

⚡️Add torch.compile Functionality #716

Draft
wants to merge 82 commits into
base: develop
Choose a base branch
from
Draft

Conversation

Abdol
Copy link
Collaborator

@Abdol Abdol commented Sep 29, 2023

This draft PR involves integrating PyTorch 2.0's torch.compile functionality to demonstrate performance improvements in torch code. This PR focuses on adding torch.compile to PatchPredictor.

Notes:

  • According to the documentation, noticeable performance can be achieved when using modern NVIDIA GPUs (H100, A100, or V100)
  • Python 3.11+ is not yet supported for torch.compile UPDATE: Python 3.11 support was added in PyTorch 2.1

@Abdol Abdol changed the title Add torch.compile functionality ⚡️Add torch.compile functionality Sep 29, 2023
@shaneahmed shaneahmed added the enhancement New feature or request label Sep 29, 2023
@shaneahmed shaneahmed added this to the Release v1.5.0 milestone Sep 29, 2023
@Abdol Abdol modified the milestones: Release v1.5.0, Release v2.0.0 Sep 29, 2023
Returns:
A tuple containing the result of the function
and the time taken to execute it in seconds.
"""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""
"""

@@ -21,10 +23,32 @@
RNG = np.random.default_rng() # Numpy Random Generator


def test_extract_features(dfbr_features: Path) -> None:
def test_extract_features_time(dfbr_features: Path, test_count: int = 25) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Is this the right place to add this test?

@shaneahmed
Copy link
Member

https://github.com/pytorch/pytorch/releases/tag/v2.1.0 PyTorch 2.1 now supports torch.compile in Python 3.11

@shaneahmed shaneahmed changed the title ⚡️Add torch.compile functionality ⚡️Add torch.compile Functionality Oct 6, 2023
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.86%. Comparing base (6ef915d) to head (8cc2fb4).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #716   +/-   ##
========================================
  Coverage    99.86%   99.86%           
========================================
  Files           69       69           
  Lines         8656     8675   +19     
  Branches      1653     1655    +2     
========================================
+ Hits          8644     8663   +19     
  Misses           4        4           
  Partials         8        8           

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

Abdol and others added 2 commits March 19, 2024 17:49
* ⚡️ Add `torch.compile` to `PatchPredictor`

* 🚨 Remove unused imports

* 🐛 Add `rcParam` import

* ✅ Add `torch.compile` tests

* ✅ Change to a more generic test

* 📝 Update test docstring

* ⚡️ Reset `TorchDynamo` when changing `torch.compile` mode

* 👷 Enable CI checks

* 👷 Add python package checks

* 🚑 Disable `torch.compile` in Python 3.12+

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* 🔥 Remove `compile_model` decorator mode for now

* 🐛 Fix a bug where a compatbility warning is shown if torch.compile is disabled

* 🚸 Check if model is compiled before compiling

* 🚨 Disable protected member access check

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* 🚨 Fix `pre-commit.ci` linting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* 🚨 Fix another linter error

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* 📝 Add comment above version check for `torch.compile`

* 🚨 Remove unnecessary noqa

* ✅ Add test to check if model is already compiled

* ✅ Skip test coverage for for checking for python 3.12

---------

Co-authored-by: Abdol A <u2271662@live.warwick.ac.uk>
Co-authored-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Abdol and others added 3 commits March 22, 2024 14:59
@shaneahmed
Copy link
Member

Updating PR to fix issues with codecov integration.

@shaneahmed
Copy link
Member

@Abdol With PyTorch 2.3 release, please can you check if it is compatible with Python 3.12?

@Abdol
Copy link
Collaborator Author

Abdol commented Jun 24, 2024

@shaneahmed according to release notes, PyTorch 2.3 still does not fully support Python 3.12 including torch.compile. They plan to support it in 2.4.

@GeorgeBatch
Copy link
Contributor

@Abdol @shaneahmed, PyTorch 2.4 now supports Python 3.12 for torch.compile(): https://github.com/pytorch/pytorch/releases/tag/v2.4.0

@Abdol
Copy link
Collaborator Author

Abdol commented Sep 20, 2024

Will get back to this PR from next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants