19
19
TeqConfig ,
20
20
)
21
21
22
+ torch .manual_seed (42 )
23
+
22
24
ipex_version = get_ipex_version ()
23
25
24
26
try :
@@ -96,8 +98,11 @@ def test_quantization_for_llm(self):
96
98
woq_model = AutoModelForCausalLM .from_pretrained (model_name_or_path , quantization_config = woq_config )
97
99
woq_model .eval ()
98
100
output = woq_model (dummy_input )
99
- # The output of torch.cholesky() had changed when torch < 2.5.0
100
- assert isclose (float (output [0 ][0 ][0 ][0 ]), - 0.0874 , abs_tol = 1e-04 )
101
+ # The output of torch.cholesky() changes on different torch version
102
+ if ipex_version < Version ("2.5.0" ):
103
+ assert isclose (float (output [0 ][0 ][0 ][0 ]), - 0.08614 , abs_tol = 1e-04 )
104
+ else :
105
+ assert isclose (float (output [0 ][0 ][0 ][0 ]), - 0.0874 , abs_tol = 1e-04 )
101
106
102
107
# AUTOROUND
103
108
woq_config = AutoRoundConfig (
@@ -107,7 +112,10 @@ def test_quantization_for_llm(self):
107
112
woq_model .eval ()
108
113
output = woq_model (dummy_input )
109
114
# The output might change when device supports bf16
110
- assert isclose (float (output [0 ][0 ][0 ][0 ]), - 0.0786 , abs_tol = 1e-04 )
115
+ if CpuInfo ().bf16 :
116
+ assert isclose (float (output [0 ][0 ][0 ][0 ]), - 0.07275 , abs_tol = 1e-04 )
117
+ else :
118
+ assert isclose (float (output [0 ][0 ][0 ][0 ]), - 0.0786 , abs_tol = 1e-04 )
111
119
112
120
def test_save_load (self ):
113
121
model_name_or_path = self .model_name_or_path
0 commit comments