Skip to content

Commit ea3691e

Browse files
authored
Update Int4WeightOnlyConfig VERSION argument (#2754)
Update Int4WeightOnlyConfig argument VERSION Summary: This is missed from previous PRs, we want to use `version` instead Test Plan: python test/quantization/quantize_/workflows/int4/test_int4_tensor.py python test/quantization/quantize_/workflows/int4/test_int4_preshuffled_tensor.py Reviewers: Subscribers: Tasks: Tags:
1 parent 21ceb8e commit ea3691e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

test/quantization/quantize_/workflows/int4/test_int4_preshuffled_tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
BF16_ACT_CONFIG = Int4WeightOnlyConfig(
3131
group_size=128,
3232
packing_format="preshuffled",
33-
VERSION=2,
33+
version=2,
3434
)
3535

3636
FP8_ACT_CONFIG = Float8DynamicActivationInt4WeightConfig(

test/quantization/quantize_/workflows/int4/test_int4_tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setUp(self):
2727
self.config = Int4WeightOnlyConfig(
2828
group_size=128,
2929
packing_format="plain",
30-
VERSION=2,
30+
version=2,
3131
)
3232
self.GPU_DEVICES = ["cuda"] if torch.cuda.is_available() else []
3333

torchao/quantization/quant_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ class Int4WeightOnlyConfig(AOBaseConfig):
10131013
`zero_point_domain`: data type of zeros points, choices are [ZeroPointDomain.FLOAT, ZeroPointDomain.INT, ZeroPointDomain.NONE]
10141014
`set_inductor_config`: if True, adjusts `torchinductor` settings to recommended values.
10151015
`preserve_zero`: whether to preserve zero, default is None. Will be set to True if zero_point_domain is ZeroPointDomain.INT
1016-
`packing_format`: the packing format for int4 tensor, available from VERSION 2 and above
1016+
`packing_format`: the packing format for int4 tensor, available from version 2 and above
10171017
"""
10181018

10191019
group_size: int = 128
@@ -1022,9 +1022,9 @@ class Int4WeightOnlyConfig(AOBaseConfig):
10221022
zero_point_domain: Optional[ZeroPointDomain] = ZeroPointDomain.NONE
10231023
set_inductor_config: bool = True
10241024
preserve_zero: Optional[bool] = None
1025-
# only used in VERSION >= 2
1025+
# only used in version >= 2
10261026
packing_format: PackingFormat = PackingFormat.PLAIN
1027-
VERSION: int = 1
1027+
version: int = 1
10281028

10291029
def __post_init__(self):
10301030
torch._C._log_api_usage_once("torchao.quantization.Int4WeightOnlyConfig")
@@ -1055,7 +1055,7 @@ def _int4_weight_only_quantize_tensor(weight, config):
10551055

10561056
block_size = tuple([1 for _ in range(weight.ndim - 1)] + [group_size])
10571057

1058-
if config.VERSION == 2:
1058+
if config.version == 2:
10591059
block_size = list(block_size)
10601060
if packing_format == PackingFormat.PRESHUFFLED:
10611061
new_weight = Int4PreshuffledTensor.from_hp(
@@ -1073,7 +1073,7 @@ def _int4_weight_only_quantize_tensor(weight, config):
10731073
else:
10741074
raise ValueError(f"Unsupported packing format: {packing_format}")
10751075

1076-
assert config.VERSION == 1
1076+
assert config.version == 1
10771077

10781078
mapping_type = MappingType.ASYMMETRIC
10791079
target_dtype = torch.int32

0 commit comments

Comments
 (0)