Skip to content

Commit bf6c814

Browse files
committed
torch version 2.8
Signed-off-by: Meng, Hengyu <hengyu.meng@intel.com>
1 parent d583d1c commit bf6c814

7 files changed

Lines changed: 18 additions & 17 deletions

File tree

‎test/dtypes/test_affine_quantized.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from torchao.utils import (
3838
TORCH_VERSION_AT_LEAST_2_5,
3939
TORCH_VERSION_AT_LEAST_2_6,
40-
TORCH_VERSION_AT_LEAST_2_7,
40+
TORCH_VERSION_AT_LEAST_2_8,
4141
is_fbcode,
4242
is_ROCM,
4343
is_sm_at_least_89,
@@ -62,7 +62,7 @@ def get_quantization_functions(
6262
base_functions.append(
6363
int4_weight_only(group_size=32, layout=Int4CPULayout())
6464
)
65-
elif device == "xpu" and TORCH_VERSION_AT_LEAST_2_7:
65+
elif device == "xpu" and TORCH_VERSION_AT_LEAST_2_8:
6666
base_functions.append(
6767
int4_weight_only(group_size=32, layout=Int4XPULayout())
6868
)

‎test/integration/test_integration.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
TORCH_VERSION_AT_LEAST_2_5,
8484
TORCH_VERSION_AT_LEAST_2_6,
8585
TORCH_VERSION_AT_LEAST_2_7,
86+
TORCH_VERSION_AT_LEAST_2_8,
8687
benchmark_model,
8788
is_fbcode,
8889
is_sm_at_least_90,
@@ -159,7 +160,7 @@ def _int4wo_api(mod, use_hqq=False):
159160
unwrap_tensor_subclass(mod)
160161
elif (
161162
is_device(next(mod.parameters()).device.type, "xpu")
162-
and TORCH_VERSION_AT_LEAST_2_7
163+
and TORCH_VERSION_AT_LEAST_2_8
163164
):
164165
quantize_(
165166
mod, int4_weight_only(layout=Int4XPULayout()), set_inductor_config=False
@@ -1139,7 +1140,7 @@ def test_int4_weight_only_quant_subclass_api_grouped(self, device, dtype):
11391140
layout_list = []
11401141
if device == "cpu" and TORCH_VERSION_AT_LEAST_2_6:
11411142
layout_list.append(Int4CPULayout())
1142-
elif device == "xpu" and TORCH_VERSION_AT_LEAST_2_7:
1143+
elif device == "xpu" and TORCH_VERSION_AT_LEAST_2_8:
11431144
layout_list.append(Int4XPULayout())
11441145
else:
11451146
for inner_k_tiles in [4, 2]:

‎test/quantization/test_quant_api.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
TORCH_VERSION_AT_LEAST_2_4,
5959
TORCH_VERSION_AT_LEAST_2_5,
6060
TORCH_VERSION_AT_LEAST_2_6,
61-
TORCH_VERSION_AT_LEAST_2_7,
61+
TORCH_VERSION_AT_LEAST_2_8,
6262
is_sm_at_least_89,
6363
is_sm_at_least_90,
6464
unwrap_tensor_subclass,
@@ -239,7 +239,7 @@ def test_dynamic_quant_gpu_unified_api_eager_mode_impl(self):
239239
torch.testing.assert_close(quantized, compiled, atol=0, rtol=0)
240240

241241
@unittest.skipIf(not torch.xpu.is_available(), "Need XPU available")
242-
@unittest.skipIf(not TORCH_VERSION_AT_LEAST_2_7, "only works for torch 2.7+")
242+
@unittest.skipIf(not TORCH_VERSION_AT_LEAST_2_8, "only works for torch 2.8+")
243243
def test_int4_wo_quant_save_load(self):
244244
m = ToyLinearModel().eval().cpu()
245245

‎test/quantization/test_quant_primitives.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
TORCH_VERSION_AT_LEAST_2_4,
3939
TORCH_VERSION_AT_LEAST_2_5,
4040
TORCH_VERSION_AT_LEAST_2_6,
41-
TORCH_VERSION_AT_LEAST_2_7,
41+
TORCH_VERSION_AT_LEAST_2_8,
4242
is_fbcode,
4343
)
4444

@@ -137,7 +137,7 @@ def _groupwise_affine_quantize_tensor_from_qparams(
137137

138138
if TORCH_VERSION_AT_LEAST_2_5:
139139
if (not (is_device(w.device.type, "cpu") and TORCH_VERSION_AT_LEAST_2_6)) and (
140-
not (is_device(w.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_7)
140+
not (is_device(w.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_8)
141141
):
142142
w_int4x8 = (w_int4x8[::, ::2] << 4 | w_int4x8[::, 1::2]).to(torch.uint8)
143143

@@ -755,7 +755,7 @@ def test_groupwise_affine_dequantize_tensor_from_qparams(self):
755755
) and (
756756
not (
757757
is_device(input.device.type, "xpu")
758-
and TORCH_VERSION_AT_LEAST_2_7
758+
and TORCH_VERSION_AT_LEAST_2_8
759759
)
760760
):
761761
input_tmp = (input[::, ::2] << 4 | input[::, 1::2]).to(torch.uint8)

‎torchao/dtypes/uintx/int4_xpu_layout.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from torchao.dtypes.utils import AQTTensorImpl, Layout, is_device
1515
from torchao.quantization.quant_primitives import ZeroPointDomain
1616
from torchao.utils import (
17-
TORCH_VERSION_AT_LEAST_2_7,
17+
TORCH_VERSION_AT_LEAST_2_8,
1818
fill_defaults,
1919
)
2020

@@ -248,7 +248,7 @@ def from_plain(
248248

249249
from torchao.quantization.utils import convert_weight_to_int4pack_xpu
250250

251-
if TORCH_VERSION_AT_LEAST_2_7:
251+
if TORCH_VERSION_AT_LEAST_2_8:
252252
assert (
253253
int_data.dtype == torch.int32
254254
), "torch.ops.aten._convert_weight_to_int4pack_for_cpu expects `int32` dtype"

‎torchao/quantization/subclass.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
)
1919
from torchao.utils import (
2020
TORCH_VERSION_AT_LEAST_2_6,
21-
TORCH_VERSION_AT_LEAST_2_7,
21+
TORCH_VERSION_AT_LEAST_2_8,
2222
find_multiple,
2323
)
2424

@@ -480,7 +480,7 @@ def _quantized_op(act_mat, w_qtensor, bias):
480480
w_qtensor.groupsize,
481481
w_qtensor.scales_and_zeros,
482482
)
483-
elif is_device(act_mat.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_7:
483+
elif is_device(act_mat.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_8:
484484
if not w_qtensor.zero_point_domain == ZeroPointDomain.INT:
485485
y = aten._weight_int4pack_mm(
486486
act_mat.contiguous(),
@@ -698,7 +698,7 @@ def to_qtensor_components(
698698
int_data = aten._convert_weight_to_int4pack_for_cpu(
699699
input_int4x8, inner_k_tiles
700700
)
701-
if is_device(input_float.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_7:
701+
if is_device(input_float.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_8:
702702
from torchao.quantization.utils import convert_weight_to_int4pack_xpu
703703

704704
int_data = convert_weight_to_int4pack_xpu(

‎torchao/quantization/utils.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from torchao.utils import (
2424
TORCH_VERSION_AT_LEAST_2_5,
2525
TORCH_VERSION_AT_LEAST_2_6,
26-
TORCH_VERSION_AT_LEAST_2_7,
26+
TORCH_VERSION_AT_LEAST_2_8,
2727
)
2828

2929
__all__ = [
@@ -434,7 +434,7 @@ def groupwise_affine_quantize_tensor_from_qparams(
434434
if (
435435
not (is_device(int_data.device.type, "cpu") and TORCH_VERSION_AT_LEAST_2_6)
436436
) and (
437-
not (is_device(int_data.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_7)
437+
not (is_device(int_data.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_8)
438438
):
439439
int_data = (int_data[::, ::2] << 4 | int_data[::, 1::2]).to(torch.uint8)
440440
return int_data
@@ -455,7 +455,7 @@ def groupwise_affine_dequantize_tensor_from_qparams(
455455
TORCH_VERSION_AT_LEAST_2_5
456456
and (w_int4x8.dtype == torch.uint8 or w_int4x8.shape[-1] > 1)
457457
and not (is_device(w_int4x8.device.type, "cpu") and TORCH_VERSION_AT_LEAST_2_6)
458-
and not (is_device(w_int4x8.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_7)
458+
and not (is_device(w_int4x8.device.type, "xpu") and TORCH_VERSION_AT_LEAST_2_8)
459459
):
460460
data = w_int4x8.to(torch.int32)
461461
high_bits = data >> 4

0 commit comments

Comments
 (0)