11
11
12
12
import inspect
13
13
import os
14
+ from contextlib import nullcontext
14
15
from typing import Callable , Dict , List , Optional
15
16
16
17
import numpy as np
@@ -1457,9 +1458,19 @@ def test_compression_with_different_algo_combinations(input_shape, kwargs):
1457
1458
)
1458
1459
1459
1460
1461
+ @pytest .mark .parametrize (
1462
+ ("transpose_a" , "transpose_b" , "raises_error" ),
1463
+ [
1464
+ (False , True , False ),
1465
+ (True , True , False ),
1466
+ (False , False , True ),
1467
+ (True , False , True ),
1468
+ ],
1469
+ ids = ["tb_nota" , "ta_tb" , "nota_notb" , "ta_notb" ],
1470
+ )
1460
1471
@pytest .mark .parametrize (
1461
1472
"kwargs" ,
1462
- (
1473
+ [
1463
1474
dict (scale_estimation = True ),
1464
1475
dict (lora_correction = True ),
1465
1476
dict (
@@ -1468,25 +1479,30 @@ def test_compression_with_different_algo_combinations(input_shape, kwargs):
1468
1479
scale_estimation = True ,
1469
1480
advanced_parameters = CompressionParams (gptq_params = GPTQParams (subset_size = 2 )),
1470
1481
),
1471
- ) ,
1482
+ ] ,
1472
1483
ids = ["se" , "lora" , "gptq_se_awq" ],
1473
1484
)
1474
- def test_compression_with_transpose (kwargs ):
1485
+ def test_compression_with_transpose (transpose_a , transpose_b , raises_error , kwargs ):
1475
1486
dataset_size = 4
1476
- model = LMLinearModel (transpose_a = True , transpose_b = True ).ov_model
1487
+ model = LMLinearModel (transpose_a = transpose_a , transpose_b = transpose_b ).ov_model
1477
1488
input_data = [np .ones (inp .shape ) for inp in model .inputs ] * dataset_size
1478
1489
dataset = Dataset (input_data )
1479
1490
1480
- compress_weights (
1481
- model ,
1482
- mode = CompressWeightsMode .INT4_SYM ,
1483
- ratio = 1.0 ,
1484
- group_size = 8 ,
1485
- subset_size = 2 ,
1486
- dataset = dataset ,
1487
- all_layers = True ,
1488
- ** kwargs ,
1489
- )
1491
+ with (
1492
+ pytest .raises (nncf .UnsupportedModelError )
1493
+ if raises_error and not kwargs .get ("lora_correction" , False )
1494
+ else nullcontext ()
1495
+ ):
1496
+ compress_weights (
1497
+ model ,
1498
+ mode = CompressWeightsMode .INT4_SYM ,
1499
+ ratio = 1.0 ,
1500
+ group_size = 8 ,
1501
+ subset_size = 2 ,
1502
+ dataset = dataset ,
1503
+ all_layers = True ,
1504
+ ** kwargs ,
1505
+ )
1490
1506
1491
1507
1492
1508
class TestOVTemplateWeightCompression (TemplateWeightCompression ):
0 commit comments