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

Fixed PyTorch version check in sparse module #1136

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

Mystic-Slice
Copy link
Collaborator

Description

The earlier check for torch version fails in the new major version. This fix solves the issue.

Type of change

Bug fix

Does this change modify the behaviour of other functions? If so, which?

no

@ghost
Copy link

ghost commented Mar 31, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@github-actions
Copy link
Contributor

Thank you for the PR!

1 similar comment
@github-actions
Copy link
Contributor

Thank you for the PR!

@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Merging #1136 (9edfaea) into main (1e1bd1e) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1136   +/-   ##
=======================================
  Coverage   91.77%   91.77%           
=======================================
  Files          72       72           
  Lines       10485    10485           
=======================================
  Hits         9623     9623           
  Misses        862      862           
Flag Coverage Δ
unit 91.77% <100.00%> (ø)

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

Impacted Files Coverage Δ
heat/sparse/factories.py 95.74% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -94,7 +94,7 @@ def sparse_csr_matrix(
(indptr: tensor([0, 1, 3, 4]), indices: tensor([2, 0, 2, 2]), data: tensor([1, 1, 2, 3]), dtype=ht.int64, device=cpu:0, split=None)
"""
# version check
if int(torch.__version__.split(".")[1]) < 10:
if torch.__version__ < "1.10":
Copy link
Contributor

Choose a reason for hiding this comment

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

oh, I didn't know this was possible!

I had to go and time these two methods. We do many many checks, and those millionths of seconds pile up. 🤭

Turns out the string check (this PR) is about 10 times slower than the int check (previous solution) even after having to manually split the string. The int check is even faster for torch >=2, as the first condition is sufficient to make the decision.

Summary: I'd go for

if int(torch.__version__.split(".")[0]) <= 1 and int(torch.__version__.split(".")[1]) < 10

solution in factories as well. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting to know that it is soo much slower.
I have reverted back to the older method of version checking.

Copy link
Contributor

@ClaudiaComito ClaudiaComito left a comment

Choose a reason for hiding this comment

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

Thanks a lot @Mystic-Slice for addressing this so soon!

@github-actions
Copy link
Contributor

github-actions bot commented Apr 1, 2023

Thank you for the PR!

@github-actions
Copy link
Contributor

Thank you for the PR!

@ClaudiaComito ClaudiaComito changed the title Fixed version check in sparse module Fixed PyTorch version check in sparse module Apr 17, 2023
@ClaudiaComito ClaudiaComito added the bug Something isn't working label Apr 17, 2023
@ClaudiaComito ClaudiaComito merged commit cb46e2c into main Apr 17, 2023
@ClaudiaComito ClaudiaComito deleted the sparse_module-version_check_fix branch April 17, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants