Skip to content

Deprecate old TORCH_VERSION variables #2719

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

Open
wants to merge 5 commits into
base: gh/andrewor14/19/base
Choose a base branch
from

Conversation

andrewor14
Copy link
Contributor

@andrewor14 andrewor14 commented Aug 8, 2025

Stack from ghstack (oldest at bottom):

Summary: This commit deprecates the following variables in favor of simply calling torch_version_at_least.

TORCH_VERSION_AT_LEAST_2_8
TORCH_VERSION_AT_LEAST_2_7
TORCH_VERSION_AT_LEAST_2_6
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2

Test Plan:

python test/test_utils.py -k torch_version_deprecation

**Summary:** This commit deprecates the following variables:

```
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8,
which means we can drop support for 2.5 and before since we only
support 3 of the latest releases.

The next commit will remove usages of all of these variables
from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Aug 8, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 2b74165 with merge base 6cfa477 (image):
💚 Looks good so far! There are no failures yet. 💚

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

andrewor14 added a commit that referenced this pull request Aug 8, 2025
**Summary:** This commit deprecates the following variables:

```
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8,
which means we can drop support for 2.5 and before since we only
support 3 of the latest releases.

The next commit will remove usages of all of these variables
from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

ghstack-source-id: 376113e
Pull Request resolved: #2719
@meta-cla meta-cla 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 8, 2025
@andrewor14 andrewor14 added the topic: deprecation Use this tag if this PR deprecates a feature label Aug 8, 2025
**Summary:** This commit deprecates the following variables:

```
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8,
which means we can drop support for 2.5 and before since we only
support 3 of the latest releases.

The next commit will remove usages of all of these variables
from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 8, 2025
**Summary:** This commit deprecates the following variables:

```
# Always True
TORCH_VERSION_AT_LEAST_2_6
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
# TORCH_VERSION_AFTER* was confusing to users
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8,
which means the oldest pytorch version we support is now 2.6
since we only support 3 of the latest releases.

The next commit will remove usages of all of these variables
from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

ghstack-source-id: 2db5800
Pull Request resolved: #2719
**Summary:** This commit deprecates the following variables:

```
# Always True
TORCH_VERSION_AT_LEAST_2_6
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
# TORCH_VERSION_AFTER* was confusing to users
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8, which means the oldest pytorch version we support is now 2.6 since we only support 3 of the latest releases.

The next commit will remove usages of all of these variables from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

[ghstack-poisoned]
**Summary:** This commit deprecates the following variables:

```
# Always True
TORCH_VERSION_AT_LEAST_2_6
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
# TORCH_VERSION_AFTER* was confusing to users
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8, which means the oldest pytorch version we support is now 2.6 since we only support 3 of the latest releases.

The next commit will remove usages of all of these variables from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

[ghstack-poisoned]
Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

another thing we could fix, is that TORCH_VERSION_AT_LEAST does not match our common understanding of version naming, since:

e.g. for TORCH_VERSION_AT_LEAST("2.7.0"), commonly we might expect this to be 2.7.0 stable and 2.8.0.dev and above, and 2.7.0.dev is not greater than 2.7.0 (because after 2.6.0 release, the version will be 2.7.0.dev until 2.7.0 is released)
but currently, 2.7.0 and 2.7.0.dev will return True

version_str_var_name = "_".join(version_str.split(".")[:2])
deprecation_msg = f"TORCH_VERSION_AT_LEAST_{version_str_var_name} is deprecated and will be removed in torchao 0.14.0"
return _BoolDeprecationWrapper(
torch_version_at_least(version_str),
Copy link
Contributor

Choose a reason for hiding this comment

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

why is current torch version related to this? this is talking about deprecation of these variables right? if so, then these variables should be deprecated now, regardless of what the system torch version is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I can deprecate them all. I think these variables exist so we don't keep calling this function, but yeah we definitely don't need to expose them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok just deprecated them all

Copy link
Contributor

@jerryzh168 jerryzh168 Aug 8, 2025

Choose a reason for hiding this comment

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

OK thanks, also the deprecation doesn't need to depend on the current pytorch version I think

we could also add a cache for torch_version_at_least as well I think

Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

we need to check if these variables are used outside of torchao as well, TBH I'm not exactly sure if we want to deprecate these variables, also we should probably stop defining these variables, since these can be achieved by passing args to torch_version_at_least when we want to use them

@andrewor14
Copy link
Contributor Author

e.g. for TORCH_VERSION_AT_LEAST("2.7.0"), commonly we might expect this to be 2.7.0 stable and 2.8.0.dev and above, and 2.7.0.dev is not greater than 2.7.0 (because after 2.6.0 release, the version will be 2.7.0.dev until 2.7.0 is released)
but currently, 2.7.0 and 2.7.0.dev will return True

You mean 2.7.0.dev should not be True because of the following ordering?

2.6.0 (stable) < 2.7.0.dev < 2.7.0 (stable)

But currently the code thinks:

# current state, but this is wrong
2.6.0 (stable) < 2.7.0 (stable) <= 2.7.0.dev

Is that right?

**Summary:** This commit deprecates the following variables:

```
# Always True
TORCH_VERSION_AT_LEAST_2_6
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
# TORCH_VERSION_AFTER* was confusing to users
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8, which means the oldest pytorch version we support is now 2.6 since we only support 3 of the latest releases.

The next commit will remove usages of all of these variables from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

[ghstack-poisoned]
@andrewor14
Copy link
Contributor Author

Filed an issue here: #2722. I think we should fix that separately because this PR doesn't change any semantics in its current state.

@jerryzh168
Copy link
Contributor

e.g. for TORCH_VERSION_AT_LEAST("2.7.0"), commonly we might expect this to be 2.7.0 stable and 2.8.0.dev and above, and 2.7.0.dev is not greater than 2.7.0 (because after 2.6.0 release, the version will be 2.7.0.dev until 2.7.0 is released)
but currently, 2.7.0 and 2.7.0.dev will return True

You mean 2.7.0.dev should not be True because of the following ordering?

2.6.0 (stable) < 2.7.0.dev < 2.7.0 (stable)

But currently the code thinks:

# current state, but this is wrong
2.6.0 (stable) < 2.7.0 (stable) <= 2.7.0.dev

Is that right?

yeah exactly

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. topic: deprecation Use this tag if this PR deprecates a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants