Skip to content

Commit 5120f75

Browse files
authored
Merge pull request #548 from daniil-lyakhov/dl/fix_ov_precommit
Fix openvino/test_training.py
2 parents 552de65 + 24f40bf commit 5120f75

File tree

1 file changed

+42
-29
lines changed

1 file changed

+42
-29
lines changed

tests/openvino/test_training.py

+42-29
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,21 @@ def tearDown(self):
276276
shutil.rmtree(self.output_dir)
277277

278278

279-
CUSTOMIZED_QUANTIZATION_CONFIG = {
280-
"algorithm": "quantization",
281-
"overflow_fix": "disable",
282-
"initializer": {
283-
"range": {
284-
"num_init_samples": 16,
285-
"type": "percentile",
286-
"params": {"min_percentile": 0.01, "max_percentile": 99.99},
279+
CUSTOMIZED_QUANTIZATION_CONFIG = deepcopy(DEFAULT_QUANTIZATION_CONFIG)
280+
CUSTOMIZED_QUANTIZATION_CONFIG.update(
281+
{
282+
"overflow_fix": "disable",
283+
"initializer": {
284+
"range": {
285+
"num_init_samples": 16,
286+
"type": "percentile",
287+
"params": {"min_percentile": 0.01, "max_percentile": 99.99},
288+
},
289+
"batchnorm_adaptation": {"num_bn_adaptation_samples": 4},
287290
},
288-
"batchnorm_adaptation": {"num_bn_adaptation_samples": 4},
289-
},
290-
"scope_overrides": {"activations": {"{re}.*matmul_0": {"mode": "asymmetric"}}},
291-
"ignored_scopes": [],
292-
}
291+
"scope_overrides": {"activations": {"{re}.*matmul_0": {"mode": "asymmetric"}}},
292+
}
293+
)
293294

294295
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT = {
295296
"algorithm": "movement_sparsity",
@@ -336,16 +337,16 @@ def tearDown(self):
336337
"customized_quantization": OVTrainerTestDescriptor(
337338
model_id="hf-internal-testing/tiny-random-bert",
338339
nncf_compression_config=CUSTOMIZED_QUANTIZATION_CONFIG,
339-
expected_fake_quantize=69,
340-
expected_int8=35,
340+
expected_fake_quantize=44,
341+
expected_int8=32,
341342
compression_metrics=["compression_loss"],
342343
),
343344
"distillation,customized_quantization": OVTrainerTestDescriptor(
344345
model_id="hf-internal-testing/tiny-random-bert",
345346
teacher_model_id="hf-internal-testing/tiny-random-bert",
346347
nncf_compression_config=CUSTOMIZED_QUANTIZATION_CONFIG,
347-
expected_fake_quantize=69,
348-
expected_int8=35,
348+
expected_fake_quantize=44,
349+
expected_int8=32,
349350
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
350351
),
351352
"structured_movement_sparsity": OVTrainerTestDescriptor(
@@ -371,9 +372,12 @@ def tearDown(self):
371372
),
372373
"customized_quantization,structured_movement_sparsity": OVTrainerTestDescriptor(
373374
model_id="hf-internal-testing/tiny-random-bert",
374-
nncf_compression_config=[CUSTOMIZED_QUANTIZATION_CONFIG, STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
375-
expected_fake_quantize=69,
376-
expected_int8=35,
375+
nncf_compression_config=[
376+
CUSTOMIZED_QUANTIZATION_CONFIG,
377+
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
378+
],
379+
expected_fake_quantize=44,
380+
expected_int8=32,
377381
expected_binary_masks=60,
378382
compression_metrics=["compression_loss"],
379383
),
@@ -389,9 +393,12 @@ def tearDown(self):
389393
"distillation,customized_quantization,structured_movement_sparsity": OVTrainerTestDescriptor(
390394
model_id="hf-internal-testing/tiny-random-bert",
391395
teacher_model_id="hf-internal-testing/tiny-random-bert",
392-
nncf_compression_config=[CUSTOMIZED_QUANTIZATION_CONFIG, STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
393-
expected_fake_quantize=69,
394-
expected_int8=35,
396+
nncf_compression_config=[
397+
CUSTOMIZED_QUANTIZATION_CONFIG,
398+
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
399+
],
400+
expected_fake_quantize=44,
401+
expected_int8=32,
395402
expected_binary_masks=60,
396403
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
397404
),
@@ -418,9 +425,12 @@ def tearDown(self):
418425
),
419426
"customized_quantization,unstructured_movement_sparsity": OVTrainerTestDescriptor(
420427
model_id="hf-internal-testing/tiny-random-bert",
421-
nncf_compression_config=[CUSTOMIZED_QUANTIZATION_CONFIG, UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
422-
expected_fake_quantize=69,
423-
expected_int8=35,
428+
nncf_compression_config=[
429+
CUSTOMIZED_QUANTIZATION_CONFIG,
430+
UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
431+
],
432+
expected_fake_quantize=44,
433+
expected_int8=32,
424434
expected_binary_masks=60,
425435
compression_metrics=["compression_loss"],
426436
),
@@ -436,9 +446,12 @@ def tearDown(self):
436446
"distillation,customized_quantization,unstructured_movement_sparsity": OVTrainerTestDescriptor(
437447
model_id="hf-internal-testing/tiny-random-bert",
438448
teacher_model_id="hf-internal-testing/tiny-random-bert",
439-
nncf_compression_config=[CUSTOMIZED_QUANTIZATION_CONFIG, UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
440-
expected_fake_quantize=69,
441-
expected_int8=35,
449+
nncf_compression_config=[
450+
CUSTOMIZED_QUANTIZATION_CONFIG,
451+
UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
452+
],
453+
expected_fake_quantize=44,
454+
expected_int8=32,
442455
expected_binary_masks=60,
443456
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
444457
),

0 commit comments

Comments
 (0)