diff --git a/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt b/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt index 0d2b8d1d5612f4..7e64c24f604a85 100644 --- a/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt @@ -51,6 +51,8 @@ ov_add_test_target( unit_test_utils ov_snippets_models snippets_test_utils + ${MLAS_LIBRARY} + ${SHL_LIBRARY} ADD_CPPLINT LABELS OV UNIT CPU diff --git a/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py b/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py index 785591aeddde29..36d1c0e863635f 100644 --- a/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py +++ b/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py @@ -56,7 +56,7 @@ def get_models_list_type(file_name: str, cls: Union[Type[OVModelForCausalLM], Ty models.append((model_name, model_link, None, None, cls)) elif len(line_items) == 4: model_name, model_link, mark, reason = line_items - models.append((model_name, model_link, mark, reason)) + models.append((model_name, model_link, mark, reason, cls)) elif len(line_items) > 4: model_name, model_link, mark, reason, *other = line_items if not mark: diff --git a/tests/model_hub_tests/transformation_tests/sdpa2pa_ref_diff.py b/tests/model_hub_tests/transformation_tests/sdpa2pa_ref_diff.py index 56eb1181e29f9b..5352a009a1d5b3 100644 --- a/tests/model_hub_tests/transformation_tests/sdpa2pa_ref_diff.py +++ b/tests/model_hub_tests/transformation_tests/sdpa2pa_ref_diff.py @@ -3,6 +3,7 @@ nodes_to_compare = ("ScaledDotProductAttention", "PagedAttentionExtension", "Parameter", "ReadValue", "Assign") + ref_diff_map = { "hf-internal-testing/tiny-random-LlamaForCausalLM" : { "Assign" : -4, @@ -299,36 +300,36 @@ "ScaledDotProductAttention" : -6, }, "katuni4ka/tiny-random-llava-next" : { + "Assign" : -4, "PagedAttentionExtension" : 2, "Parameter" : 7, "ReadValue" : -4, "ScaledDotProductAttention" : -2, - "Assign" : -4, }, "katuni4ka/tiny-random-minicpmv-2_6" : { + "Assign" : -4, "PagedAttentionExtension" : 2, "Parameter" : 7, "ReadValue" : -4, "ScaledDotProductAttention" : -2, - "Assign" : -4, }, "katuni4ka/tiny-random-llava" : { "Assign" : -4, + "PagedAttentionExtension" : 2, "Parameter" : 7, "ReadValue" : -4, "ScaledDotProductAttention" : -2, - "PagedAttentionExtension" : 2, }, - # "katuni4ka/tiny-random-nanollava" : { # "Assign" : -4, + # "PagedAttentionExtension" : 2, # "Parameter" : 7, # "ReadValue" : -4, # "ScaledDotProductAttention" : -2, - # "PagedAttentionExtension" : 2, # }, } + ref_diff_map_cache_eviction = { "hf-internal-testing/tiny-random-LlamaForCausalLM" : { "Assign" : -4, @@ -554,13 +555,6 @@ "ReadValue" : -8, "ScaledDotProductAttention" : -4, }, - "katuni4ka/tiny-random-minicpm" : { - "Assign" : -8, - "PagedAttentionExtension" : 4, - "Parameter" : 14, - "ReadValue" : -8, - "ScaledDotProductAttention" : -4, - }, "katuni4ka/tiny-random-falcon-40b" : { "Assign" : -4, "PagedAttentionExtension" : 2, @@ -632,32 +626,31 @@ "ScaledDotProductAttention" : -6, }, "katuni4ka/tiny-random-llava-next" : { - "Parameter" : 8, "Assign" : -4, - "ReadValue" : -4, "PagedAttentionExtension" : 2, + "Parameter" : 12, + "ReadValue" : -4, "ScaledDotProductAttention" : -2, }, "katuni4ka/tiny-random-minicpmv-2_6" : { - "Parameter" : 8, "Assign" : -4, - "ReadValue" : -4, "PagedAttentionExtension" : 2, + "Parameter" : 12, + "ReadValue" : -4, "ScaledDotProductAttention" : -2, }, "katuni4ka/tiny-random-llava" : { + "Assign" : -4, + "PagedAttentionExtension" : 2, + "Parameter" : 12, "ReadValue" : -4, - "Parameter" : 8, "ScaledDotProductAttention" : -2, - "PagedAttentionExtension" : 2, - "Assign" : -4, }, - # "katuni4ka/tiny-random-nanollava" : { + # "Assign" : -4, + # "PagedAttentionExtension" : 2, + # "Parameter" : 12, # "ReadValue" : -4, - # "Parameter" : 8, # "ScaledDotProductAttention" : -2, - # "PagedAttentionExtension" : 2, - # "Assign" : -4, # }, } diff --git a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py b/tests/model_hub_tests/transformation_tests/test_pa_transformation.py index db2f95cb30515c..cfb6234c086e65 100644 --- a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py +++ b/tests/model_hub_tests/transformation_tests/test_pa_transformation.py @@ -37,7 +37,7 @@ def compare_diffs(ov_model: ov.Model, for op in set(after_map.keys()) | set(before_map.keys()): resulting_map[op] = after_map.get(op, 0) - before_map.get(op, 0) - use_cache_eviction = use_block_indices_inputs and use_score_outputs + use_cache_eviction = use_block_indices_inputs and use_score_outputs and allow_cache_rotation reference_map = ref_diff_map_cache_eviction[model_id] if use_cache_eviction else ref_diff_map[model_id] assert reference_map == resulting_map @@ -58,14 +58,14 @@ def compare_diffs(ov_model: ov.Model, # Test for block_indices inputs and scores outputs to appear in the model if (use_block_indices_inputs): - interesting_input_patterns["block_indices"] = r'block_indices\.[0-9]+' + interesting_input_patterns["block_indices"] = r'^block_indices\.[0-9]+' if (use_score_outputs): - interesting_output_patterns["scores"] = r'scores\.[0-9]+' + interesting_output_patterns["scores"] = r'^scores\.[0-9]+' if (allow_cache_rotation): - interesting_input_patterns["rotation_coefficients"] = r'rotation_coefficients\.[0-9]+'; - interesting_input_patterns["rotated_block_indices"] = r'rotated_block_indices\.[0-9]+'; + interesting_input_patterns["rotation_coefficients"] = r'^rotation_coefficients\.[0-9]+'; + interesting_input_patterns["rotated_block_indices"] = r'^rotated_block_indices\.[0-9]+'; input_counters = {k: 0 for k in interesting_input_patterns} output_counters = {k: 0 for k in interesting_output_patterns} @@ -95,11 +95,12 @@ def run_pa(tmp_path, model_link, cls: Union[Type[OVModelForCausalLM], Type[OVModelForVisualCausalLM]], use_block_indices_inputs, - use_score_outputs): + use_score_outputs, + allow_cache_rotation): model = cls.from_pretrained(model_id, export=True, trust_remote_code=True) ov_model = model.model if cls is OVModelForCausalLM else model.lm_model - compare_diffs(ov_model, model_id, use_block_indices_inputs, use_score_outputs) + compare_diffs(ov_model, model_id, use_block_indices_inputs, use_score_outputs, allow_cache_rotation) @pytest.mark.precommit @pytest.mark.parametrize("model_name, model_link, mark, reason", utils.get_models_list(os.path.join(os.path.dirname(__file__), "models", "hf-tiny-random-models-precommit"))) @@ -110,7 +111,7 @@ def test_pa_precommit(tmp_path, model_name, model_link, mark, reason, ie_device) pytest.skip(reason) elif mark == 'xfail': pytest.xfail(reason) - run_pa(tmp_path, model_name, model_link, OVModelForCausalLM False, False, False) + run_pa(tmp_path, model_name, model_link, OVModelForCausalLM, False, False, False) @pytest.mark.precommit @pytest.mark.parametrize("model_name, model_link, mark, reason", utils.get_models_list(os.path.join(os.path.dirname(__file__), "models", "hf-tiny-random-models-precommit"))) @@ -121,7 +122,7 @@ def test_pa_precommit_use_cache_eviction(tmp_path, model_name, model_link, mark, pytest.skip(reason) elif mark == 'xfail': pytest.xfail(reason) - run_pa(tmp_path, model_name, model_link, OVModelForCausalLM, True, True) + run_pa(tmp_path, model_name, model_link, OVModelForCausalLM, True, True, True) @pytest.mark.precommit @pytest.mark.parametrize("model_name, model_link, mark, reason", utils.get_models_list(os.path.join(os.path.dirname(__file__), "models", "hf-tiny-random-vl-models-precommit")))