Skip to content

Commit ca05db0

Browse files
authored
Bump transformers version (#724)
* Bump transformers version * fix default ignored scope for model using sdpa by default * fix quant ops test * update setup * add ops quant num gpt2 * fix expected ops quant in test * update optimum version
1 parent aefabf0 commit ca05db0

File tree

8 files changed

+25
-31
lines changed

8 files changed

+25
-31
lines changed

examples/openvino/image-classification/configs/swin-base-jpqd.json

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
"ignored_scopes": [
3737
"{re}.*__add___[0-1]",
3838
"{re}.*layer_norm_0",
39-
"{re}.*matmul_1",
40-
"{re}.*__truediv__*"
4139
]
4240
}
4341
]

examples/openvino/question-answering/configs/bert-base-jpqd.json

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
"ignored_scopes": [
3737
"{re}.*__add___[0-1]",
3838
"{re}.*layer_norm_0",
39-
"{re}.*matmul_1",
40-
"{re}.*__truediv__*"
4139
]
4240
}
4341
]

examples/openvino/text-classification/configs/bert-base-jpqd.json

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
"ignored_scopes": [
4141
"{re}.*__add___[0-1]",
4242
"{re}.*layer_norm_0",
43-
"{re}.*matmul_1",
44-
"{re}.*__truediv__*"
4543
]
4644
}
4745
]

optimum/intel/openvino/trainer.py

-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@
153153
"{re}.*Embedding.*",
154154
"{re}.*add___.*",
155155
"{re}.*layer_norm_.*",
156-
"{re}.*matmul_1",
157-
"{re}.*__truediv__.*",
158156
],
159157
}
160158

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
INSTALL_REQUIRE = [
3030
"torch>=1.11",
31-
"transformers>=4.36.0,<4.41.0",
32-
"optimum~=1.19",
31+
"transformers>=4.36.0,<4.42.0",
32+
"optimum~=1.20",
3333
"datasets>=1.4.0",
3434
"sentencepiece",
3535
"scipy",

tests/openvino/test_modeling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ def test_compare_output_attentions(self, model_arch):
16791679
preprocessor = AutoFeatureExtractor.from_pretrained(model_id)
16801680
inputs = preprocessor(images=image, return_tensors="pt")
16811681

1682-
transformers_model = AutoModelForImageClassification.from_pretrained(model_id)
1682+
transformers_model = AutoModelForImageClassification.from_pretrained(model_id, attn_implementation="eager")
16831683
transformers_model.eval()
16841684
with torch.no_grad():
16851685
transformers_outputs = transformers_model(**inputs, output_attentions=True)

tests/openvino/test_quantization.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
class OVQuantizerTest(unittest.TestCase):
7676
SUPPORTED_ARCHITECTURES_TORCH_MODEL = (
77-
(OVModelForSequenceClassification, "bert", 32, 35),
77+
(OVModelForSequenceClassification, "bert", 22, 35),
7878
(OVModelForCausalLM, "gpt2", 41, 3),
7979
)
8080
SUPPORTED_ARCHITECTURES_OV_MODEL = (
@@ -665,7 +665,7 @@ def preprocess_function(examples, tokenizer):
665665

666666

667667
class OVTrainerTest(unittest.TestCase):
668-
SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS = (("distilbert-base-uncased", 49, 38),)
668+
SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS = (("distilbert-base-uncased", 67, 38),)
669669

670670
@parameterized.expand(SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS)
671671
def test_aware_training_quantization(self, model_name, expected_fake_quantize, expected_int8):

tests/openvino/test_training.py

+20-18
Original file line numberDiff line numberDiff line change
@@ -322,30 +322,30 @@ def tearDown(self):
322322
"default_quantization": OVTrainerTestDescriptor(
323323
model_id="hf-internal-testing/tiny-random-bert",
324324
nncf_compression_config=DEFAULT_QUANTIZATION_CONFIG,
325-
expected_fake_quantize=34,
325+
expected_fake_quantize=22,
326326
expected_int8=32,
327327
compression_metrics=["compression_loss"],
328328
),
329329
"distillation,default_quantization": OVTrainerTestDescriptor(
330330
model_id="hf-internal-testing/tiny-random-bert",
331331
teacher_model_id="hf-internal-testing/tiny-random-bert",
332332
nncf_compression_config=DEFAULT_QUANTIZATION_CONFIG,
333-
expected_fake_quantize=34,
333+
expected_fake_quantize=22,
334334
expected_int8=32,
335335
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
336336
),
337337
"customized_quantization": OVTrainerTestDescriptor(
338338
model_id="hf-internal-testing/tiny-random-bert",
339339
nncf_compression_config=CUSTOMIZED_QUANTIZATION_CONFIG,
340-
expected_fake_quantize=34,
340+
expected_fake_quantize=22,
341341
expected_int8=32,
342342
compression_metrics=["compression_loss"],
343343
),
344344
"distillation,customized_quantization": OVTrainerTestDescriptor(
345345
model_id="hf-internal-testing/tiny-random-bert",
346346
teacher_model_id="hf-internal-testing/tiny-random-bert",
347347
nncf_compression_config=CUSTOMIZED_QUANTIZATION_CONFIG,
348-
expected_fake_quantize=34,
348+
expected_fake_quantize=22,
349349
expected_int8=32,
350350
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
351351
),
@@ -365,7 +365,7 @@ def tearDown(self):
365365
"default_quantization,structured_movement_sparsity": OVTrainerTestDescriptor(
366366
model_id="hf-internal-testing/tiny-random-bert",
367367
nncf_compression_config=[DEFAULT_QUANTIZATION_CONFIG, STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
368-
expected_fake_quantize=34,
368+
expected_fake_quantize=22,
369369
expected_int8=32,
370370
expected_binary_masks=60,
371371
compression_metrics=["compression_loss"],
@@ -376,7 +376,7 @@ def tearDown(self):
376376
CUSTOMIZED_QUANTIZATION_CONFIG,
377377
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
378378
],
379-
expected_fake_quantize=34,
379+
expected_fake_quantize=22,
380380
expected_int8=32,
381381
expected_binary_masks=60,
382382
compression_metrics=["compression_loss"],
@@ -385,7 +385,7 @@ def tearDown(self):
385385
model_id="hf-internal-testing/tiny-random-bert",
386386
teacher_model_id="hf-internal-testing/tiny-random-bert",
387387
nncf_compression_config=[DEFAULT_QUANTIZATION_CONFIG, STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
388-
expected_fake_quantize=34,
388+
expected_fake_quantize=22,
389389
expected_int8=32,
390390
expected_binary_masks=60,
391391
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
@@ -397,7 +397,7 @@ def tearDown(self):
397397
CUSTOMIZED_QUANTIZATION_CONFIG,
398398
STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
399399
],
400-
expected_fake_quantize=34,
400+
expected_fake_quantize=22,
401401
expected_int8=32,
402402
expected_binary_masks=60,
403403
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
@@ -418,7 +418,7 @@ def tearDown(self):
418418
"default_quantization,unstructured_movement_sparsity": OVTrainerTestDescriptor(
419419
model_id="hf-internal-testing/tiny-random-bert",
420420
nncf_compression_config=[DEFAULT_QUANTIZATION_CONFIG, UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
421-
expected_fake_quantize=34,
421+
expected_fake_quantize=22,
422422
expected_int8=32,
423423
expected_binary_masks=60,
424424
compression_metrics=["compression_loss"],
@@ -429,7 +429,7 @@ def tearDown(self):
429429
CUSTOMIZED_QUANTIZATION_CONFIG,
430430
UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
431431
],
432-
expected_fake_quantize=34,
432+
expected_fake_quantize=22,
433433
expected_int8=32,
434434
expected_binary_masks=60,
435435
compression_metrics=["compression_loss"],
@@ -438,7 +438,7 @@ def tearDown(self):
438438
model_id="hf-internal-testing/tiny-random-bert",
439439
teacher_model_id="hf-internal-testing/tiny-random-bert",
440440
nncf_compression_config=[DEFAULT_QUANTIZATION_CONFIG, UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT],
441-
expected_fake_quantize=34,
441+
expected_fake_quantize=22,
442442
expected_int8=32,
443443
expected_binary_masks=60,
444444
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
@@ -450,7 +450,7 @@ def tearDown(self):
450450
CUSTOMIZED_QUANTIZATION_CONFIG,
451451
UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_BERT,
452452
],
453-
expected_fake_quantize=34,
453+
expected_fake_quantize=22,
454454
expected_int8=32,
455455
expected_binary_masks=60,
456456
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
@@ -553,7 +553,7 @@ def check_ovmodel_reshaping(self, ovmodel: OVModel):
553553
"default_quantization": OVTrainerTestDescriptor(
554554
model_id="yujiepan/tiny-random-swin-patch4-window7-224",
555555
nncf_compression_config=DEFAULT_QUANTIZATION_CONFIG,
556-
expected_fake_quantize=28,
556+
expected_fake_quantize=36,
557557
expected_int8=28,
558558
compression_metrics=["compression_loss"],
559559
),
@@ -572,15 +572,15 @@ def check_ovmodel_reshaping(self, ovmodel: OVModel):
572572
"default_quantization,structured_movement_sparsity": OVTrainerTestDescriptor(
573573
model_id="yujiepan/tiny-random-swin-patch4-window7-224",
574574
nncf_compression_config=[STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_SWIN, DEFAULT_QUANTIZATION_CONFIG],
575-
expected_fake_quantize=28,
575+
expected_fake_quantize=36,
576576
expected_int8=28,
577577
expected_binary_masks=48,
578578
compression_metrics=["compression_loss"],
579579
),
580580
"default_quantization,unstructured_movement_sparsity": OVTrainerTestDescriptor(
581581
model_id="yujiepan/tiny-random-swin-patch4-window7-224",
582582
nncf_compression_config=[UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_SWIN, DEFAULT_QUANTIZATION_CONFIG],
583-
expected_fake_quantize=28,
583+
expected_fake_quantize=36,
584584
expected_int8=28,
585585
expected_binary_masks=48,
586586
compression_metrics=["compression_loss"],
@@ -589,7 +589,7 @@ def check_ovmodel_reshaping(self, ovmodel: OVModel):
589589
model_id="yujiepan/tiny-random-swin-patch4-window7-224",
590590
teacher_model_id="yujiepan/tiny-random-swin-patch4-window7-224",
591591
nncf_compression_config=[STRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_SWIN, DEFAULT_QUANTIZATION_CONFIG],
592-
expected_fake_quantize=28,
592+
expected_fake_quantize=36,
593593
expected_int8=28,
594594
expected_binary_masks=48,
595595
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
@@ -598,7 +598,7 @@ def check_ovmodel_reshaping(self, ovmodel: OVModel):
598598
model_id="yujiepan/tiny-random-swin-patch4-window7-224",
599599
teacher_model_id="yujiepan/tiny-random-swin-patch4-window7-224",
600600
nncf_compression_config=[UNSTRUCTURED_MOVEMENT_SPARSITY_CONFIG_FOR_SWIN, DEFAULT_QUANTIZATION_CONFIG],
601-
expected_fake_quantize=28,
601+
expected_fake_quantize=36,
602602
expected_int8=28,
603603
expected_binary_masks=48,
604604
compression_metrics=["compression_loss", "distillation_loss", "task_loss"],
@@ -797,7 +797,9 @@ def prepare_model_and_dataset(self, desc: OVTrainerTestDescriptor):
797797

798798
self.feature_extractor = AutoFeatureExtractor.from_pretrained(desc.model_id)
799799
self.tokenizer = self.feature_extractor
800-
self.model = AutoModelForAudioClassification.from_pretrained(desc.model_id, num_labels=self.num_labels)
800+
self.model = AutoModelForAudioClassification.from_pretrained(
801+
desc.model_id, num_labels=self.num_labels, attn_implementation="eager"
802+
)
801803
self.teacher_model = None
802804
if desc.teacher_model_id:
803805
self.teacher_model = AutoModelForAudioClassification.from_pretrained(

0 commit comments

Comments
 (0)