File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -1946,5 +1946,32 @@ def test_benchmark_model_cpu(self):
19461946 assert self .run_benchmark_model ("cpu" ) is not None
19471947
19481948
1949+ # TODO: Remove this test once the deprecated API has been removed
1950+ def test_cutlass_int4_packed_layout_deprecated ():
1951+ import sys
1952+ import warnings
1953+
1954+ # We need to clear the cache to force re-importing and trigger the warning again.
1955+ modules_to_clear = [
1956+ "torchao.dtypes.uintx.cutlass_int4_packed_layout" ,
1957+ "torchao.dtypes" ,
1958+ ]
1959+ for mod in modules_to_clear :
1960+ if mod in sys .modules :
1961+ del sys .modules [mod ]
1962+
1963+ with warnings .catch_warnings (record = True ) as w :
1964+ from torchao .dtypes import CutlassInt4PackedLayout # noqa: F401
1965+
1966+ warnings .simplefilter ("always" ) # Ensure all warnings are captured
1967+ assert any (
1968+ issubclass (warning .category , DeprecationWarning )
1969+ and "CutlassInt4PackedLayout" in str (warning .message )
1970+ for warning in w
1971+ ), (
1972+ f"Expected deprecation warning for CutlassInt4PackedLayout, got: { [str (warning .message ) for warning in w ]} "
1973+ )
1974+
1975+
19491976if __name__ == "__main__" :
19501977 unittest .main ()
Original file line number Diff line number Diff line change @@ -282,7 +282,8 @@ def test_sparse_deprecated(self):
282282 del sys .modules [mod ]
283283
284284 with warnings .catch_warnings (record = True ) as w :
285- from torchao .dtypes import BlockSparseLayout
285+ from torchao .dtypes import BlockSparseLayout # noqa: F401
286+
286287 warnings .simplefilter ("always" ) # Ensure all warnings are captured
287288 self .assertTrue (
288289 any (
Original file line number Diff line number Diff line change 1010warnings .warn (
1111 "Importing from torchao.dtypes is deprecated. "
1212 "Please use 'from torchao.prototype.dtypes import CutlassInt4PackedLayout' instead. "
13- "This import path will be removed in torchao v0.16.0." ,
13+ "This import path will be removed in torchao v0.16.0. "
14+ "Please check issue: https://github.com/pytorch/ao/issues/2752 for more details. " ,
1415 DeprecationWarning ,
1516 stacklevel = 2 ,
1617)
You can’t perform that action at this time.
0 commit comments