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

Fix source version check #684

Merged
merged 2 commits into from
Aug 15, 2024
Merged

Fix source version check #684

merged 2 commits into from
Aug 15, 2024

Conversation

msaroufim
Copy link
Member

@msaroufim msaroufim commented Aug 15, 2024

@crcrpar can you try this instead?

Fixes #679 (comment)

This just basically takes advantage of the fact that every PyTorch version has the format X.Y.Z and then some stuff

# Test cases
import torch
from torchao.utils import torch_version_at_least

torch.__version__ = "2.5.0a0+git9f17037"
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True


torch.__version__ = "2.5.0.dev20240708+cu121"
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True


torch.__version__ = "2.5.0"
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be True

torch.__version__ = "2.4.0"
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be False

Copy link

pytorch-bot bot commented Aug 15, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/684

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit b943bc1 with merge base 5998389 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 15, 2024
@jerryzh168
Copy link
Contributor

@crcrpar can you try this instead?

Fixes #679 (comment)

This just basically takes advantage of the fact that every PyTorch version has the format X.Y.Z and then some stuff

# Test cases
import torch
from torchao.utils import torch_version_at_least

torch.__version__ = "2.5.0a0+git9f17037"
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True


torch.__version__ = "2.5.0.dev20240708+cu121"
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True


torch.__version__ = "2.5.0"
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be True

torch.__version__ = "2.4.0"
print(f"{torch.__version__}: {torch_version_at_least('2.4.0')}")  # Should be True
print(f"{torch.__version__}: {torch_version_at_least('2.5.0')}")  # Should be False

maybe add these examples to tests?

class TestTorchVersionAtLeast(unittest.TestCase):
def test_torch_version_at_least(self):
test_cases = [
("2.5.0a0+git9f17037", "2.5.0", True),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, as I thought this should be False instead.
shouldn't 2.5.0a0 and 2.5.0.dev be <2.5.0 but >2.4?
I might misunderstand torch_version_at_least usage though

Copy link
Member Author

Choose a reason for hiding this comment

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

Strictly speaking this is an internal only utility that we leverage in case torch makes certain breaking changes or adds new features upstream. So I can't think of many cases where we'd do one thing with 2.5 nightlies vs 2.5 official releases.

Copy link
Contributor

Choose a reason for hiding this comment

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

understood.

@msaroufim msaroufim merged commit 0b0192e into main Aug 15, 2024
14 checks passed
@felipemello1
Copy link

@msaroufim , when do you guys plan to make a new release? Is it monthly?

@msaroufim
Copy link
Member Author

msaroufim commented Aug 15, 2024

We do monthly, next one branch cut is Sep 5 and release a few days later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants