From 595246df6305759ac6310e3ede8db5356d7877e2 Mon Sep 17 00:00:00 2001 From: Nikita Savelyev Date: Thu, 21 Nov 2024 10:13:42 +0100 Subject: [PATCH] Support NNCF 2.14 and OV 2024.5 (#997) * Tweak reference values * Update requirements to OV 2024.5 * Update tokenizers condition in tests * Fix condition * Trigger Tests * Trigger Tests --- setup.py | 2 +- tests/openvino/test_exporters_cli.py | 17 +++++++++-------- tests/openvino/test_quantization.py | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 7ef3652f8..0c4bbc154 100644 --- a/setup.py +++ b/setup.py @@ -62,7 +62,7 @@ EXTRAS_REQUIRE = { "nncf": ["nncf>=2.11.0"], - "openvino": ["nncf>=2.11.0", "openvino==2024.4.1.dev20240926", "openvino-tokenizers==2024.4.1.0.dev20240926"], + "openvino": ["nncf>=2.11.0", "openvino==2024.5.0", "openvino-tokenizers==2024.5.0"], "neural-compressor": ["neural-compressor[pt]>3.0", "accelerate", "transformers<4.46"], "ipex": ["intel-extension-for-pytorch", "transformers>=4.39,<4.45"], "diffusers": ["diffusers"], diff --git a/tests/openvino/test_exporters_cli.py b/tests/openvino/test_exporters_cli.py index 783b994c1..67511bb84 100644 --- a/tests/openvino/test_exporters_cli.py +++ b/tests/openvino/test_exporters_cli.py @@ -50,6 +50,7 @@ from optimum.intel.utils.import_utils import ( compare_versions, is_openvino_tokenizers_available, + is_openvino_version, is_tokenizers_version, is_transformers_version, ) @@ -80,20 +81,20 @@ class OVCLIExportTestCase(unittest.TestCase): if is_transformers_version(">=", "4.45"): SUPPORTED_ARCHITECTURES.extend([("text-to-image", "stable-diffusion-3"), ("text-to-image", "flux")]) EXPECTED_NUMBER_OF_TOKENIZER_MODELS = { - "gpt2": 2 if is_tokenizers_version("<", "0.20") else 0, + "gpt2": 2 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 0, "t5": 0, # no .model file in the repository "albert": 0, # not supported yet "distilbert": 1, # no detokenizer - "roberta": 2 if is_tokenizers_version("<", "0.20") else 0, + "roberta": 2 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 0, "vit": 0, # no tokenizer for image model "wav2vec2": 0, # no tokenizer "bert": 1, # no detokenizer - "blenderbot": 2 if is_tokenizers_version("<", "0.20") else 0, - "stable-diffusion": 2 if is_tokenizers_version("<", "0.20") else 0, - "stable-diffusion-xl": 4 if is_tokenizers_version("<", "0.20") else 0, - "stable-diffusion-3": 6 if is_tokenizers_version("<", "0.20") else 2, - "flux": 4 if is_tokenizers_version("<", "0.20") else 0, - "llava": 2 if is_tokenizers_version("<", "0.20") else 0, + "blenderbot": 2 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 0, + "stable-diffusion": 2 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 0, + "stable-diffusion-xl": 4 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 0, + "stable-diffusion-3": 6 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 2, + "flux": 4 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 0, + "llava": 2 if is_tokenizers_version("<", "0.20") or is_openvino_version(">=", "2024.5") else 0, } SUPPORTED_SD_HYBRID_ARCHITECTURES = [ diff --git a/tests/openvino/test_quantization.py b/tests/openvino/test_quantization.py index 48a36f604..2869acf83 100644 --- a/tests/openvino/test_quantization.py +++ b/tests/openvino/test_quantization.py @@ -258,7 +258,7 @@ class OVWeightCompressionTest(unittest.TestCase): sensitivity_metric="mean_activation_magnitude", dataset=["one two, " * i for i in range(10)], ), - {"int4": 25, "int8": 14}, + {"int4": 24, "int8": 16}, ), ( OVModelForCausalLM, @@ -915,7 +915,7 @@ def preprocess_function(examples, tokenizer): class OVTrainerTest(unittest.TestCase): - SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS = (("albert", 64, 39),) + SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS = (("albert", 63, 39),) @parameterized.expand(SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS) @unittest.skipIf(