Skip to content

Commit 1fbc364

Browse files
authored
Add deprecation warnings for various inference configs (#3294)
* Update [ghstack-poisoned] * Update [ghstack-poisoned] * Update [ghstack-poisoned]
1 parent 6815e57 commit 1fbc364

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

test/quantization/test_quant_api.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -826,19 +826,25 @@ def test_config_deprecation(self):
826826
uintx_weight_only: (torch.uint4,),
827827
}
828828

829-
with warnings.catch_warnings(record=True) as _warnings:
830-
# Call each deprecated API twice
831-
for cls, args in deprecated_apis_to_args.items():
829+
# Call each deprecated API twice
830+
for cls, args in deprecated_apis_to_args.items():
831+
with warnings.catch_warnings(record=True) as _warnings:
832832
cls(*args)
833833
cls(*args)
834834

835-
# Each call should trigger the warning only once
836-
self.assertEqual(len(_warnings), len(deprecated_apis_to_args))
837-
for w in _warnings:
838-
self.assertIn(
839-
"is deprecated and will be removed in a future release",
840-
str(w.message),
841-
)
835+
# Each call should have at least one warning.
836+
# Some of them can have two warnings - one for deprecation,
837+
# one for moving to prototype
838+
# 1 warning - just deprecation
839+
# 2 warnings - deprecation and prototype warnings
840+
self.assertTrue(len(_warnings) in (1, 2))
841+
found_deprecated = False
842+
for w in _warnings:
843+
if "is deprecated and will be removed in a future release" in str(
844+
w.message
845+
):
846+
found_deprecated = True
847+
self.assertTrue(found_deprecated)
842848

843849

844850
common_utils.instantiate_parametrized_tests(TestQuantFlow)

torchao/quantization/quant_api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,9 @@ def __post_init__(self):
594594
torch._C._log_api_usage_once(
595595
"torchao.quantization.Int8DynamicActivationInt4WeightConfig"
596596
)
597+
warnings.warn(
598+
"`Int8DynamicActivationInt4WeightConfig` will be moving to prototype in a future release of torchao. Please see https://github.com/pytorch/ao/issues/2752 for more details."
599+
)
597600

598601

599602
# for BC
@@ -965,6 +968,9 @@ def __post_init__(self):
965968
torch._C._log_api_usage_once(
966969
"torchao.quantization.Int4DynamicActivationInt4WeightConfig"
967970
)
971+
warnings.warn(
972+
"`Int4DynamicActivationInt4WeightConfig` will be moving to prototype in a future release of torchao. Please see https://github.com/pytorch/ao/issues/2752 for more details."
973+
)
968974

969975

970976
# for bc
@@ -1028,6 +1034,9 @@ def __post_init__(self):
10281034
torch._C._log_api_usage_once(
10291035
"torchao.quantization.GemliteUIntXWeightOnlyConfig"
10301036
)
1037+
warnings.warn(
1038+
"`GemliteUIntXWeightOnlyConfig` will be moving to prototype in a future release of torchao. Please see https://github.com/pytorch/ao/issues/2752 for more details."
1039+
)
10311040

10321041

10331042
# for BC
@@ -1981,6 +1990,9 @@ def __post_init__(self):
19811990
torch._C._log_api_usage_once(
19821991
"torchao.quantization.Float8StaticActivationFloat8WeightConfig"
19831992
)
1993+
warnings.warn(
1994+
"`Float8StaticActivationFloat8WeightConfig` will be moving to prototype in a future release of torchao. Please see https://github.com/pytorch/ao/issues/2752 for more details."
1995+
)
19841996

19851997

19861998
# for bc
@@ -2069,6 +2081,9 @@ class UIntXWeightOnlyConfig(AOBaseConfig):
20692081

20702082
def __post_init__(self):
20712083
torch._C._log_api_usage_once("torchao.quantization.UIntXWeightOnlyConfig")
2084+
warnings.warn(
2085+
"`UIntXWeightOnlyConfig` will be moving to prototype in a future release of torchao. Please see https://github.com/pytorch/ao/issues/2752 for more details."
2086+
)
20722087

20732088

20742089
# for BC
@@ -2353,6 +2368,9 @@ class FPXWeightOnlyConfig(AOBaseConfig):
23532368

23542369
def __post_init__(self):
23552370
torch._C._log_api_usage_once("torchao.quantization.FPXWeightOnlyConfig")
2371+
warnings.warn(
2372+
"`FPXWeightOnlyConfig` will be moving to prototype in a future release of torchao. Please see https://github.com/pytorch/ao/issues/2752 for more details."
2373+
)
23562374

23572375

23582376
# for BC

0 commit comments

Comments
 (0)