From 5670f78fc98849966cb288a339977674198cc7d8 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 13:41:16 +0200 Subject: [PATCH 1/8] Trace the current device info when running the tests --- dpnp/tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dpnp/tests/conftest.py b/dpnp/tests/conftest.py index a0a76e3edb4..c4938fff9bd 100644 --- a/dpnp/tests/conftest.py +++ b/dpnp/tests/conftest.py @@ -145,6 +145,7 @@ def pytest_collection_modifyitems(config, items): print(f"DPNP version: {dpnp.__version__}, location: {dpnp}") print(f"NumPy version: {numpy.__version__}, location: {numpy}") print(f"Python version: {sys.version}") + print(f"Device info: {dpctl.utils.intel_device_info(dev)}") print("") if is_gpu or os.getenv("DPNP_QUEUE_GPU") == "1": excluded_tests.extend(get_excluded_tests(test_exclude_file_gpu)) From 8a8606422a4c36ef9ef9a73b30ebaa7e2ebb9ff8 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 13:48:16 +0200 Subject: [PATCH 2/8] Trace global memory usage in histogramm tests --- .../cupy/statistics_tests/test_histogram.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py b/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py index fbc22032aba..0a49fb580c7 100644 --- a/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py +++ b/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py @@ -1,6 +1,7 @@ import sys import unittest +import dpctl import numpy import pytest @@ -44,6 +45,20 @@ def for_all_dtypes_combination_bincount(names): return testing.for_dtypes_combination(_all_types, names=names) +# TODO: comments +_dev = dpctl.select_default_device() + + +@pytest.fixture(autouse=True) +def setup_each(): + print("\n[Setup] Run before each test") + free_mem = dpctl.utils.intel_device_info(_dev).get("free_memory", None) + if free_mem: + print(f"Global memory available: {free_mem}") + yield + print("[Teardown] Run after each test") + + class TestHistogram(unittest.TestCase): @testing.for_all_dtypes(no_bool=True, no_complex=True) From ecaf289570f9cf70907d0b7a38832db0dc2c7678 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 13:53:52 +0200 Subject: [PATCH 3/8] Enable pytest vebose mode --- conda-recipe/run_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe/run_test.sh b/conda-recipe/run_test.sh index b2c96df3624..05f0794b1a2 100755 --- a/conda-recipe/run_test.sh +++ b/conda-recipe/run_test.sh @@ -37,4 +37,4 @@ set -e $PYTHON -c "import dpnp; print(dpnp.__version__)" $PYTHON -m dpctl -f -$PYTHON -m pytest -ra --pyargs dpnp +$PYTHON -m pytest -ra -sv --pyargs dpnp From da6208f5ac386a74bc9473a83a871b990cb68ffe Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 14:09:53 +0200 Subject: [PATCH 4/8] Enable tracing in all histogram tests --- dpnp/tests/test_histogram.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dpnp/tests/test_histogram.py b/dpnp/tests/test_histogram.py index a00312af3a5..6cb7423bea1 100644 --- a/dpnp/tests/test_histogram.py +++ b/dpnp/tests/test_histogram.py @@ -24,6 +24,19 @@ numpy_version, ) +# TODO: comments +_dev = dpctl.select_default_device() + + +@pytest.fixture(autouse=True) +def setup_each(): + print("\n[Setup] Run before each test") + free_mem = dpctl.utils.intel_device_info(_dev).get("free_memory", None) + if free_mem: + print(f"Global memory available: {free_mem}") + yield + print("[Teardown] Run after each test") + class TestDigitize: @pytest.mark.parametrize("dtype", get_integer_float_dtypes()) From bbd1224a0972f3e740e9aa0eaa878e7caed0d138 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 15:18:27 +0200 Subject: [PATCH 5/8] Measure time spent by each histogramm test --- dpnp/tests/test_histogram.py | 6 ++++++ .../third_party/cupy/statistics_tests/test_histogram.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/dpnp/tests/test_histogram.py b/dpnp/tests/test_histogram.py index 6cb7423bea1..7ce218d55e2 100644 --- a/dpnp/tests/test_histogram.py +++ b/dpnp/tests/test_histogram.py @@ -1,3 +1,5 @@ +import time + import dpctl import numpy import pytest @@ -31,10 +33,14 @@ @pytest.fixture(autouse=True) def setup_each(): print("\n[Setup] Run before each test") + start_time = time.time() free_mem = dpctl.utils.intel_device_info(_dev).get("free_memory", None) if free_mem: print(f"Global memory available: {free_mem}") yield + end_time = time.time() + duration = end_time - start_time + print(f"\n[Test Duration] {duration:.4f} seconds") print("[Teardown] Run after each test") diff --git a/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py b/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py index 0a49fb580c7..a16d7f598e8 100644 --- a/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py +++ b/dpnp/tests/third_party/cupy/statistics_tests/test_histogram.py @@ -1,4 +1,5 @@ import sys +import time import unittest import dpctl @@ -52,10 +53,14 @@ def for_all_dtypes_combination_bincount(names): @pytest.fixture(autouse=True) def setup_each(): print("\n[Setup] Run before each test") + start_time = time.time() free_mem = dpctl.utils.intel_device_info(_dev).get("free_memory", None) if free_mem: print(f"Global memory available: {free_mem}") yield + end_time = time.time() + duration = end_time - start_time + print(f"\n[Test Duration] {duration:.4f} seconds") print("[Teardown] Run after each test") From d280393c2dfb405d5a85229686aef3245bf317bb Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 17:13:14 +0200 Subject: [PATCH 6/8] Disable the w/a with OneMKL hanging --- dpnp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpnp/__init__.py b/dpnp/__init__.py index 170b73b76cc..225f923b473 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -30,7 +30,7 @@ mypath = os.path.dirname(os.path.realpath(__file__)) # workaround against hanging in OneMKL calls and in DPCTL -os.environ.setdefault("SYCL_QUEUE_THREAD_POOL_SIZE", "6") +# os.environ.setdefault("SYCL_QUEUE_THREAD_POOL_SIZE", "6") import dpctl From 3e92e68313e8b606c70a53548ce80c553db988c6 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 19:01:25 +0200 Subject: [PATCH 7/8] Catch hanging with gdb --- conda-recipe/run_test.sh | 3 ++- dpnp/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conda-recipe/run_test.sh b/conda-recipe/run_test.sh index 05f0794b1a2..48a29ffbe94 100755 --- a/conda-recipe/run_test.sh +++ b/conda-recipe/run_test.sh @@ -37,4 +37,5 @@ set -e $PYTHON -c "import dpnp; print(dpnp.__version__)" $PYTHON -m dpctl -f -$PYTHON -m pytest -ra -sv --pyargs dpnp +# $PYTHON -m pytest -ra -sv --pyargs dpnp +timeout --signal=SIGINT 30m gdb --batch -ex "run" --ex "thread apply all bt" --ex "quit" --args "$PYTHON" -m pytest -ra -sv --pyargs dpnp diff --git a/dpnp/__init__.py b/dpnp/__init__.py index 225f923b473..170b73b76cc 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -30,7 +30,7 @@ mypath = os.path.dirname(os.path.realpath(__file__)) # workaround against hanging in OneMKL calls and in DPCTL -# os.environ.setdefault("SYCL_QUEUE_THREAD_POOL_SIZE", "6") +os.environ.setdefault("SYCL_QUEUE_THREAD_POOL_SIZE", "6") import dpctl From 6a060bc8ddc4b937908f8193bce723023b502a8a Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 24 Jul 2025 23:48:50 +0200 Subject: [PATCH 8/8] Use dpnp.is_supported_array_type() --- dpnp/dpnp_utils/dpnp_algo_utils.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pyx b/dpnp/dpnp_utils/dpnp_algo_utils.pyx index 732b792af12..f0b60ec5e6a 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pyx +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pyx @@ -76,7 +76,8 @@ cdef ERROR_PREFIX = "DPNP error:" def convert_item(item): - if hasattr(item, "__sycl_usm_array_interface__"): + # if hasattr(item, "__sycl_usm_array_interface__"): + if dpnp.is_supported_array_type(item): item_converted = dpnp.asnumpy(item) elif hasattr(item, "__array_interface__"): # detect if it is a container (TODO any better way?) mod_name = getattr(item, "__module__", 'none')