Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
27 changes: 27 additions & 0 deletions test/quantization/test_da8w4_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,32 @@ def forward(self, x):
common_utils.instantiate_parametrized_tests(TestDa8w4Cpu)


# TODO: Remove this test once the deprecated API has been removed
def test_int8_dynamic_act_int4_weight_cpu_layout_deprecated():
import sys
import warnings

# We need to clear the cache to force re-importing and trigger the warning again.
modules_to_clear = [
"torchao.dtypes.uintx.dyn_int8_act_int4_wei_cpu_layout",
"torchao.dtypes",
]
for mod in modules_to_clear:
if mod in sys.modules:
del sys.modules[mod]

with warnings.catch_warnings(record=True) as w:
from torchao.dtypes import Int8DynamicActInt4WeightCPULayout # noqa: F401

warnings.simplefilter("always") # Ensure all warnings are captured
assert any(
issubclass(warning.category, DeprecationWarning)
and "Int8DynamicActInt4WeightCPULayout" in str(warning.message)
for warning in w
), (
f"Expected deprecation warning for Int8DynamicActInt4WeightCPULayout, got: {[str(warning.message) for warning in w]}"
)


if __name__ == "__main__":
run_tests()
2 changes: 1 addition & 1 deletion torchao/dtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from .uintx import (
Int4CPULayout,
Int4XPULayout,
Int8DynamicActInt4WeightCPULayout,
MarlinQQQLayout,
MarlinQQQTensor,
MarlinSparseLayout,
Expand All @@ -29,6 +28,7 @@
)
from .uintx.block_sparse_layout import BlockSparseLayout
from .uintx.cutlass_int4_packed_layout import CutlassInt4PackedLayout
from .uintx.dyn_int8_act_int4_wei_cpu_layout import Int8DynamicActInt4WeightCPULayout
from .utils import (
Layout,
PlainLayout,
Expand Down
8 changes: 4 additions & 4 deletions torchao/dtypes/affine_quantized_tensor_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
_linear_f16_bf16_act_floatx_weight_check,
_linear_f16_bf16_act_floatx_weight_impl,
)
from torchao.dtypes.uintx.dyn_int8_act_int4_wei_cpu_layout import (
_linear_int8_act_int4_weight_cpu_check,
_linear_int8_act_int4_weight_cpu_impl,
)
from torchao.dtypes.uintx.gemlite_layout import (
_linear_fp_act_int4_weight_gemlite_check,
_linear_fp_act_int4_weight_gemlite_impl,
Expand Down Expand Up @@ -94,6 +90,10 @@
_linear_int8_act_int4_weight_cutlass_check,
_linear_int8_act_int4_weight_cutlass_impl,
)
from torchao.prototype.dtypes.uintx.dyn_int8_act_int4_wei_cpu_layout import (
_linear_int8_act_int4_weight_cpu_check,
_linear_int8_act_int4_weight_cpu_impl,
)
from torchao.quantization.quant_primitives import (
ZeroPointDomain,
_dequantize_affine_no_zero_point,
Expand Down
Loading
Loading