Skip to content

Commit 24f40bf

Browse files
committedFeb 2, 2024·
CUSTOMIZED_QUANTIZATION_CONFIG is updated
1 parent 7ea3656 commit 24f40bf

File tree

1 file changed

+32
-35
lines changed

1 file changed

+32
-35
lines changed
 

‎tests/openvino/test_training.py

+32-35
Original file line numberDiff line numberDiff line change
@@ -276,24 +276,21 @@ def tearDown(self):
276276
shutil.rmtree(self.output_dir)
277277

278278

279-
TINY_RANDOM_BERT_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-
"BertForSequenceClassification/BertModel[bert]/__rsub___0",
293-
"BertForSequenceClassification/BertModel[bert]/__mul___0",
294-
"{re}BertLayer\\[[0-9]+\\]/BertAttention\\[attention\\]/BertSelfAttention\\[self\\]/__add___0",
295-
],
296-
}
291+
"scope_overrides": {"activations": {"{re}.*matmul_0": {"mode": "asymmetric"}}},
292+
}
293+
)
297294

298295
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT = {
299296
"algorithm": "movement_sparsity",
@@ -339,17 +336,17 @@ def tearDown(self):
339336
),
340337
"customized_quantization": OVTrainerTestDescriptor(
341338
model_id="hf-internal-testing/tiny-random-bert",
342-
nncf_compression_config=TINY_RANDOM_BERT_CUSTOMIZED_QUANTIZATION_CONFIG,
343-
expected_fake_quantize=64,
344-
expected_int8=35,
339+
nncf_compression_config=CUSTOMIZED_QUANTIZATION_CONFIG,
340+
expected_fake_quantize=44,
341+
expected_int8=32,
345342
compression_metrics=["compression_loss"],
346343
),
347344
"distillation,customized_quantization": OVTrainerTestDescriptor(
348345
model_id="hf-internal-testing/tiny-random-bert",
349346
teacher_model_id="hf-internal-testing/tiny-random-bert",
350-
nncf_compression_config=TINY_RANDOM_BERT_CUSTOMIZED_QUANTIZATION_CONFIG,
351-
expected_fake_quantize=64,
352-
expected_int8=35,
347+
nncf_compression_config=CUSTOMIZED_QUANTIZATION_CONFIG,
348+
expected_fake_quantize=44,
349+
expected_int8=32,
353350
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
354351
),
355352
"structured_movement_sparsity": OVTrainerTestDescriptor(
@@ -376,11 +373,11 @@ def tearDown(self):
376373
"customized_quantization,structured_movement_sparsity": OVTrainerTestDescriptor(
377374
model_id="hf-internal-testing/tiny-random-bert",
378375
nncf_compression_config=[
379-
TINY_RANDOM_BERT_CUSTOMIZED_QUANTIZATION_CONFIG,
376+
CUSTOMIZED_QUANTIZATION_CONFIG,
380377
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
381378
],
382-
expected_fake_quantize=64,
383-
expected_int8=35,
379+
expected_fake_quantize=44,
380+
expected_int8=32,
384381
expected_binary_masks=60,
385382
compression_metrics=["compression_loss"],
386383
),
@@ -397,11 +394,11 @@ def tearDown(self):
397394
model_id="hf-internal-testing/tiny-random-bert",
398395
teacher_model_id="hf-internal-testing/tiny-random-bert",
399396
nncf_compression_config=[
400-
TINY_RANDOM_BERT_CUSTOMIZED_QUANTIZATION_CONFIG,
397+
CUSTOMIZED_QUANTIZATION_CONFIG,
401398
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
402399
],
403-
expected_fake_quantize=64,
404-
expected_int8=35,
400+
expected_fake_quantize=44,
401+
expected_int8=32,
405402
expected_binary_masks=60,
406403
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
407404
),
@@ -429,11 +426,11 @@ def tearDown(self):
429426
"customized_quantization,unstructured_movement_sparsity": OVTrainerTestDescriptor(
430427
model_id="hf-internal-testing/tiny-random-bert",
431428
nncf_compression_config=[
432-
TINY_RANDOM_BERT_CUSTOMIZED_QUANTIZATION_CONFIG,
429+
CUSTOMIZED_QUANTIZATION_CONFIG,
433430
UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
434431
],
435-
expected_fake_quantize=64,
436-
expected_int8=35,
432+
expected_fake_quantize=44,
433+
expected_int8=32,
437434
expected_binary_masks=60,
438435
compression_metrics=["compression_loss"],
439436
),
@@ -450,11 +447,11 @@ def tearDown(self):
450447
model_id="hf-internal-testing/tiny-random-bert",
451448
teacher_model_id="hf-internal-testing/tiny-random-bert",
452449
nncf_compression_config=[
453-
TINY_RANDOM_BERT_CUSTOMIZED_QUANTIZATION_CONFIG,
450+
CUSTOMIZED_QUANTIZATION_CONFIG,
454451
UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
455452
],
456-
expected_fake_quantize=64,
457-
expected_int8=35,
453+
expected_fake_quantize=44,
454+
expected_int8=32,
458455
expected_binary_masks=60,
459456
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
460457
),

0 commit comments

Comments
 (0)
Please sign in to comment.