Skip to content

Clarifying the meaning of VERSION in AOBaseConfig #2635

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

Merged
merged 1 commit into from
Jul 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,19 @@ def test_version_mismatch():
config_from_dict(reconstructable)


def test_default_version():
"""Making sure the default version for a new config inheriting from AOBaseConfig is always 1
because it's the default VERSION that all children has when they haven't explicitly
defined a VERSION class variable
"""

@dataclass
class DummyConfig(AOBaseConfig):
pass

config = DummyConfig()
assert config.VERSION == 1, "Default version must be 1"


if __name__ == "__main__":
pytest.main([__file__])
15 changes: 13 additions & 2 deletions torchao/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"ALLOWED_AO_MODULES",
]

# the default version for all configs, should never change
_DEFAULT_VERSION = 1


class AOBaseConfig(abc.ABC):
"""
Expand All @@ -46,8 +49,16 @@ def _transform(

"""

# Base Version of a config
VERSION: ClassVar[int] = 1
"""
Note: this is not the version of AOBaseConfig, but the default version for all child configs
inheriting from AOBaseConfig, and it should be `_DEFAULT_VERSION` and never change
this is making sure all configs has a version defined, when they need to bump the version
they have to define a class variable VERSION for the child config to overwrite the default VERSION
that's defined here. Different child configs will maintain their own VERSION.

default Version of a config, should never change
"""
VERSION: ClassVar[int] = _DEFAULT_VERSION


class VersionMismatchError(Exception):
Expand Down
Loading