Skip to content

Commit f9a769c

Browse files
committed
Update on "Remove old QAT APIs"
**Summary:** As a follow-up to #2641, which deprecated the old QAT APIs in 0.13.0, we remove them now in the next release 0.15.0. Fixes #2630. **Test Plan:** CI [ghstack-poisoned]
2 parents b7f32ae + deb8bb9 commit f9a769c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

torchao/utils.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
import itertools
99
import re
1010
import time
11+
import warnings
1112
from functools import reduce
1213
from importlib.metadata import version
1314
from math import gcd
14-
from typing import Any, Callable, Optional
15+
from typing import Any, Callable, Optional, Type
1516

1617
import torch
1718
import torch.nn.utils.parametrize as parametrize
@@ -367,6 +368,25 @@ def torch_version_at_least(min_version):
367368
return parse_version(torch.__version__) >= parse_version(min_version)
368369

369370

371+
class _ConfigDeprecationWrapper:
372+
"""
373+
A deprecation wrapper that directs users from a deprecated "config function"
374+
(e.g. `int4_weight_only`) to the replacement config class.
375+
"""
376+
377+
def __init__(self, deprecated_name: str, config_cls: Type):
378+
self.deprecated_name = deprecated_name
379+
self.config_cls = config_cls
380+
381+
def __call__(self, *args, **kwargs):
382+
warnings.warn(
383+
f"`{self.deprecated_name}` is deprecated and will be removed in a future release. "
384+
f"Please use `{self.config_cls.__name__}` instead. Example usage:\n"
385+
f" quantize_(model, {self.config_cls.__name__}(...))"
386+
)
387+
return self.config_cls(*args, **kwargs)
388+
389+
370390
"""
371391
Helper function for implementing aten op or torch function dispatch
372392
and dispatching to these implementations.

0 commit comments

Comments
 (0)