From 7db922af2b4f5713d5e503547a0a16e1c4e9263b Mon Sep 17 00:00:00 2001 From: Samir Nasibli Date: Fri, 4 Oct 2024 03:31:02 -0700 Subject: [PATCH 1/3] MAINT: reduce code duplication; make common skip func --- sklearnex/tests/test_run_to_run_stability.py | 47 +++++++------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/sklearnex/tests/test_run_to_run_stability.py b/sklearnex/tests/test_run_to_run_stability.py index 8d8892f40f..0d2f527184 100755 --- a/sklearnex/tests/test_run_to_run_stability.py +++ b/sklearnex/tests/test_run_to_run_stability.py @@ -146,6 +146,17 @@ def _run_test(estimator, method, datasets): ) +def _skip_neighbors(estimator, method): + if ( + not _IS_INTEL + and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator) + and method in ["score", "predict", "kneighbors", "kneighbors_graph"] + ): + if daal_check_version((2025, "P", 200)): + pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL") + pytest.skip(f"{estimator} shows instability on Non-Intel hardware") + + @pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues("numpy,array_api")) @pytest.mark.parametrize("estimator, method", gen_models_info(PATCHED_MODELS)) def test_standard_estimator_stability(estimator, method, dataframe, queue): @@ -155,14 +166,7 @@ def test_standard_estimator_stability(estimator, method, dataframe, queue): pytest.skip(f"variation observed in {estimator}.score") if estimator in ["IncrementalEmpiricalCovariance"] and method == "mahalanobis": pytest.skip("allowed fallback to sklearn occurs") - if ( - not _IS_INTEL - and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator) - and method in ["score", "predict", "kneighbors", "kneighbors_graph"] - ): - if daal_check_version((2025, "P", 200)): - pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL") - pytest.skip(f"{estimator} shows instability on Non-Intel hardware") + _skip_neighbors(estimator, method) if "NearestNeighbors" in estimator and "radius" in method: pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex") @@ -191,14 +195,7 @@ def test_special_estimator_stability(estimator, method, dataframe, queue): pytest.skip(f"variation observed in KMeans.score") if "NearestNeighbors" in estimator and "radius" in method: pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex") - if ( - not _IS_INTEL - and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator) - and method in ["score", "predict", "kneighbors", "kneighbors_graph"] - ): - if daal_check_version((2025, "P", 200)): - pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL") - pytest.skip(f"{estimator} shows instability on Non-Intel hardware") + _skip_neighbors(estimator, method) est = SPECIAL_INSTANCES[estimator] @@ -227,14 +224,7 @@ def test_sparse_estimator_stability(estimator, method, dataframe, queue): pytest.skip(f"variation observed in KMeans.{method} in 2024.7 oneDAL") if "NearestNeighbors" in estimator and "radius" in method: pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex") - if ( - not _IS_INTEL - and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator) - and method in ["score", "predict", "kneighbors", "kneighbors_graph"] - ): - if daal_check_version((2025, "P", 200)): - pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL") - pytest.skip(f"{estimator} shows instability on Non-Intel hardware") + _skip_neighbors(estimator, method) est = SPARSE_INSTANCES[estimator] @@ -259,14 +249,7 @@ def test_other_estimator_stability(estimator, method, dataframe, queue): pytest.skip(f"variation observed in KMeans.score") if "NearestNeighbors" in estimator and "radius" in method: pytest.skip(f"RadiusNeighbors estimator not implemented in sklearnex") - if ( - not _IS_INTEL - and ("Neighbors" in estimator or "LocalOutlierFactor" in estimator) - and method in ["score", "predict", "kneighbors", "kneighbors_graph"] - ): - if daal_check_version((2025, "P", 200)): - pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL") - pytest.skip(f"{estimator} shows instability on Non-Intel hardware") + _skip_neighbors(estimator, method) est = STABILITY_INSTANCES[estimator] From b5e263bedcc410224e8484880ad0731aa63270ba Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Fri, 4 Oct 2024 13:08:06 +0100 Subject: [PATCH 2/3] Update sklearnex/tests/test_run_to_run_stability.py --- sklearnex/tests/test_run_to_run_stability.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sklearnex/tests/test_run_to_run_stability.py b/sklearnex/tests/test_run_to_run_stability.py index 0d2f527184..197ed3a54b 100755 --- a/sklearnex/tests/test_run_to_run_stability.py +++ b/sklearnex/tests/test_run_to_run_stability.py @@ -153,8 +153,9 @@ def _skip_neighbors(estimator, method): and method in ["score", "predict", "kneighbors", "kneighbors_graph"] ): if daal_check_version((2025, "P", 200)): - pytest.fail("Re-verify failure of algorithms in 2025.2 oneDAL") - pytest.skip(f"{estimator} shows instability on Non-Intel hardware") + pytest.fail("Re-verify failure of algorithms in oneDAL 2025.2") + pytest.skip(f"{estimator} shows instability on non-Intel(R) hardware") + @pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues("numpy,array_api")) From 0a93b8835ca82c47578a0cf18795d170e4e62d0c Mon Sep 17 00:00:00 2001 From: Samir Nasibli Date: Fri, 4 Oct 2024 14:21:16 +0200 Subject: [PATCH 3/3] Update sklearnex/tests/test_run_to_run_stability.py --- sklearnex/tests/test_run_to_run_stability.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sklearnex/tests/test_run_to_run_stability.py b/sklearnex/tests/test_run_to_run_stability.py index 197ed3a54b..bae2d27a83 100755 --- a/sklearnex/tests/test_run_to_run_stability.py +++ b/sklearnex/tests/test_run_to_run_stability.py @@ -157,7 +157,6 @@ def _skip_neighbors(estimator, method): pytest.skip(f"{estimator} shows instability on non-Intel(R) hardware") - @pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues("numpy,array_api")) @pytest.mark.parametrize("estimator, method", gen_models_info(PATCHED_MODELS)) def test_standard_estimator_stability(estimator, method, dataframe, queue):