Skip to content
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
6 changes: 6 additions & 0 deletions test/prototype/safetensors/test_safetensors_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
from torchao.quantization.quant_api import (
Float8DynamicActivationFloat8WeightConfig,
Int4WeightOnlyConfig,
Int8DynamicActivationInt8WeightConfig,
Int8DynamicActivationIntxWeightConfig,
Int8WeightOnlyConfig,
IntxWeightOnlyConfig,
)
from torchao.utils import is_sm_at_least_89
Expand Down Expand Up @@ -50,6 +52,8 @@ class TestSafeTensors(TestCase):
(Int4WeightOnlyConfig(int4_packing_format="tile_packed_to_4d"), False),
(IntxWeightOnlyConfig(), False),
(Int8DynamicActivationIntxWeightConfig(), False),
(Int8WeightOnlyConfig(version=2), False),
(Int8DynamicActivationInt8WeightConfig(version=2), False),
],
)
def test_safetensors(self, config, act_pre_scale=False):
Expand Down Expand Up @@ -95,6 +99,8 @@ def test_safetensors(self, config, act_pre_scale=False):
(Int4WeightOnlyConfig(int4_packing_format="tile_packed_to_4d"), False),
(IntxWeightOnlyConfig(), False),
(Int8DynamicActivationIntxWeightConfig(), False),
(Int8WeightOnlyConfig(version=2), False),
(Int8DynamicActivationInt8WeightConfig(version=2), False),
],
)
def test_safetensors_sharded(self, config, act_pre_scale=False):
Expand Down
11 changes: 10 additions & 1 deletion torchao/prototype/safetensors/safetensors_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,37 @@
Float8Tensor,
Int4Tensor,
Int4TilePackedTo4dTensor,
Int8Tensor,
IntxUnpackedToInt8Tensor,
MappingType,
)
from torchao.quantization.quantize_.common import KernelPreference
from torchao.quantization.quantize_.workflows import QuantizeTensorToFloat8Kwargs
from torchao.quantization.quantize_.workflows import (
QuantizeTensorToFloat8Kwargs,
QuantizeTensorToInt8Kwargs,
)

ALLOWED_CLASSES = {
"Float8Tensor": Float8Tensor,
"Int4Tensor": Int4Tensor,
"Int4TilePackedTo4dTensor": Int4TilePackedTo4dTensor,
"IntxUnpackedToInt8Tensor": IntxUnpackedToInt8Tensor,
"Int8Tensor": Int8Tensor,
"Float8MMConfig": torchao.float8.inference.Float8MMConfig,
"QuantizeTensorToFloat8Kwargs": QuantizeTensorToFloat8Kwargs,
"QuantizeTensorToInt8Kwargs": QuantizeTensorToInt8Kwargs,
"PerRow": torchao.quantization.PerRow,
"PerTensor": torchao.quantization.PerTensor,
"KernelPreference": KernelPreference,
"MappingType": MappingType,
}

ALLOWED_TENSORS_SUBCLASSES = [
"Float8Tensor",
"Int4Tensor",
"Int4TilePackedTo4dTensor",
"IntxUnpackedToInt8Tensor",
"Int8Tensor",
]

__all__ = [
Expand Down
Loading