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

feat: add Python implementation of accelerated OP #67

Merged
merged 10 commits into from
Nov 29, 2022
Merged

Conversation

XuehaiPan
Copy link
Member

@XuehaiPan XuehaiPan commented Aug 30, 2022

Description

Resolves #36
Resolves #66

Motivation and Context

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • New feature (non-breaking change which adds core functionality)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format (required)
  • I have checked the code using make lint (required)
  • I have ensured make test pass. (required)

@XuehaiPan XuehaiPan added enhancement New feature or request feature New feature cxx / cuda Something related to the CXX / CUDA extension labels Aug 30, 2022
@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2022

Codecov Report

Base: 64.46% // Head: 63.57% // Decreases project coverage by -0.88% ⚠️

Coverage data is based on head (2a08697) compared to base (5a4d206).
Patch coverage: 10.41% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
- Coverage   64.46%   63.57%   -0.89%     
==========================================
  Files          66       68       +2     
  Lines        2842     2883      +41     
==========================================
+ Hits         1832     1833       +1     
- Misses       1010     1050      +40     
Flag Coverage Δ
unittests 63.57% <10.41%> (-0.89%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
torchopt/accelerated_op/_src/__init__.py 0.00% <0.00%> (ø)
torchopt/accelerated_op/_src/adam_op.py 0.00% <0.00%> (ø)
torchopt/accelerated_op/adam_op.py 74.68% <50.00%> (-1.64%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@XuehaiPan XuehaiPan marked this pull request as draft September 1, 2022 14:50
@Benjamin-eecs Benjamin-eecs added this to the 0.6.0 milestone Sep 5, 2022
@XuehaiPan XuehaiPan force-pushed the cross-platform branch 4 times, most recently from 47ddf71 to e4cc211 Compare September 8, 2022 11:54
@XuehaiPan XuehaiPan force-pushed the cross-platform branch 2 times, most recently from a005547 to 42a6a80 Compare October 13, 2022 11:28
@XuehaiPan XuehaiPan force-pushed the cross-platform branch 2 times, most recently from 13828d6 to 4e0f36e Compare October 26, 2022 11:23
@XuehaiPan XuehaiPan force-pushed the cross-platform branch 2 times, most recently from 84a2f9e to 09946f1 Compare November 1, 2022 09:08
@Benjamin-eecs Benjamin-eecs removed this from the 0.6.0 milestone Nov 3, 2022
@XuehaiPan XuehaiPan force-pushed the cross-platform branch 2 times, most recently from cd4cd7b to 1183487 Compare November 9, 2022 08:23
@XuehaiPan XuehaiPan force-pushed the cross-platform branch 2 times, most recently from 0aee719 to e0c7e9c Compare November 24, 2022 14:57
@XuehaiPan XuehaiPan force-pushed the cross-platform branch 2 times, most recently from 1da6716 to 4d30221 Compare November 24, 2022 18:16
Copy link
Member

@Benjamin-eecs Benjamin-eecs left a comment

Choose a reason for hiding this comment

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

LGTM!

torchopt/accelerated_op/_src/adam_op.py Outdated Show resolved Hide resolved
torchopt/accelerated_op/_src/adam_op.py Show resolved Hide resolved
dmu: torch.Tensor, updates: torch.Tensor, mu: torch.Tensor, b1: float
) -> Tuple[torch.Tensor, torch.Tensor]:
"""Adam backward mu."""
dupdates = dmu.mul(1.0 - b1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

1.0 -> double or float or?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will be cast to the same floating point type as dmu.dtype, usually torch.float32.

@XuehaiPan XuehaiPan force-pushed the cross-platform branch 2 times, most recently from 3cea69d to 044ffd7 Compare November 29, 2022 09:39
Benjamin-eecs
Benjamin-eecs previously approved these changes Nov 29, 2022
Copy link
Member

@Benjamin-eecs Benjamin-eecs left a comment

Choose a reason for hiding this comment

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

LGTM

@XuehaiPan XuehaiPan changed the title feat: add Python implementation of accelerated OP and pure-Python wheels feat: add Python implementation of accelerated OP Nov 29, 2022
@XuehaiPan XuehaiPan merged commit b0cdd00 into main Nov 29, 2022
@XuehaiPan XuehaiPan deleted the cross-platform branch November 29, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cxx / cuda Something related to the CXX / CUDA extension enhancement New feature or request feature New feature
Projects
None yet
4 participants