Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dpnp/tests/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- Compute-follows-data error tests expect `(ValueError, ExecutionPlacementError)`: dpnp raises either, depending on the helper.
- A new function is added to the matching parametrized lists in `test_sycl_queue.py` and `test_usm_type.py` (`test_1in_1out`, `test_2in_1out`, ...); elementwise ones also to `test_strides.py`.
- A test that may exceed the device's maximum allocation size skips on `USMAllocationError` (from `dpnp.exceptions`), not `MemoryError`, which it does not derive from.
- Markers are strict and only `slow` and `multi_gpu` are registered. Tests that need huge allocations are `@pytest.mark.slow`; they never run in CI by design.
- Markers are strict and only `slow`, `multi_gpu` and `single_device` are registered. `test_sycl_queue.py` skips a test when only the default device is available, unless it is marked `single_device` (it uses a second queue on the same device, or an in-order or profiling one). Tests that need huge allocations are `@pytest.mark.slow`; they never run in CI by design.
- Skip lists are for device- or backend-specific failures only; use the full parametrized node ID relative to `dpnp/` (`tests/test_x.py::TestY::test_z[param]`; `conftest.py` matches it exactly, so a `dpnp/tests/...` entry matches nothing), and update or drop the entries of a test you rename or remove.
- The conda CI jobs run the installed package (`--pyargs dpnp.tests`), so a new test directory or data file needs a matching glob in `package_data` in `setup.py`, or they silently skip it. The oneMath, coverage and open-source LLVM SYCL jobs test an editable or in-place tree and won't catch the omission.

Expand Down
5 changes: 5 additions & 0 deletions dpnp/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def pytest_configure(config):
"markers",
"multi_gpu: marks tests that require a specified number of GPUs",
)
config.addinivalue_line(
"markers",
"single_device: marks test_sycl_queue.py tests that also check "
"placement when only the default device is available",
)

# NumPy arccosh
# Undefined behavior depends on the backend:
Expand Down
12 changes: 9 additions & 3 deletions dpnp/tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,12 +1178,18 @@ def test_complex_fp(self, dtype_x, dtype_y):

@pytest.mark.parametrize("dtype", ALL_DTYPES_NO_COMPLEX)
@pytest.mark.parametrize(
"left, right", [[-40, 40], [dpnp.array(-40), dpnp.array(40)]]
"left, right",
[
[-40, 40],
[dpnp.array(-40), dpnp.array(40)],
[-40, None],
[None, 40],
],
)
def test_left_right_args(self, dtype, left, right):
x = numpy.array([0, 1, 2, 3, 4, 5, 6], dtype=dtype)
xp = numpy.array([0, 3, 6], dtype=dtype)
fp = numpy.array([0, 9, 18], dtype=dtype)
xp = numpy.array([1, 3, 5], dtype=dtype)
fp = numpy.array([3, 9, 15], dtype=dtype)

ix = dpnp.array(x)
ixp = dpnp.array(xp)
Expand Down
23 changes: 21 additions & 2 deletions dpnp/tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@
pass
elif device.device_type.name not in list_of_device_type_str:
pass
elif device.backend.name in "opencl" and device.is_gpu:
# due to reported crash on Windows: CMPLRLLVM-55640
elif device.backend.name == "opencl" and device.is_gpu:
# Level Zero is the GPU backend users target
pass
else:
valid_dev.append(device)

dev_ids = [device.filter_string for device in valid_dev]

# inputs on the default device share its queue, so placement goes unchecked
only_default_dev = all(d == dpctl.select_default_device() for d in valid_dev)


@pytest.fixture(autouse=True)
def skip_if_only_default_device(request):
marked = request.node.get_closest_marker("single_device") is not None
if only_default_dev and not marked:
Comment on lines +50 to +53

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the skip stays: test_copy_method, test_astype, test_indices, test_tri_diag_indices and test_mask_indices also pass a new dpctl.SyclQueue(device), but they are not marked single_device, so CI skips them. If tril_indices ignored sycl_queue=, master's CPU CI would fail and this branch would pass. Could you mark them too? The open dpnp.random PRs (#3157-#3163) add more such tests.

pytest.skip("needs a SYCL device other than the default one")
Comment on lines +47 to +54

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With only the default device these checks still catch real bugs: get_execution_queue compares queue identity, so a result on a new queue, or an ignored sycl_queue=, fails. CI has only the CPU, so the fixture skips 712 of 787 tests there (on master they run in about 7 s):

import dpctl, dpnp
import dpnp.tensor as dpt

x = dpnp.ones(10)  # default device, default queue
y = dpnp.asarray(x, sycl_queue=dpctl.SyclQueue(x.sycl_device))
print(dpt.get_execution_queue([x.sycl_queue, y.sycl_queue]))  # None on GPU and CPU

Could we keep them running? To catch a dropped placement too, the inputs could be built on dpctl.SyclQueue(device) instead of the default queue.



def assert_sycl_queue_equal(result, expected):
assert result.backend == expected.backend
Expand Down Expand Up @@ -654,6 +664,7 @@ def test_2in_broadcasting(func, data1, data2, device):
assert_sycl_queue_equal(result.sycl_queue, x1.sycl_queue)


@pytest.mark.single_device
@pytest.mark.parametrize(
"func",
[
Expand Down Expand Up @@ -694,6 +705,7 @@ def test_flat(device):
assert_sycl_queue_equal(x.flat[y].sycl_queue, x.sycl_queue)


@pytest.mark.single_device
@pytest.mark.parametrize("device", valid_dev, ids=dev_ids)
def test_flat_setitem_diff_queue(device):
a = dpnp.arange(6, device=device)
Expand Down Expand Up @@ -843,6 +855,7 @@ def test_vecmat(device, shape1, shape2):
assert_sycl_queue_equal(result_queue, b.sycl_queue)


@pytest.mark.single_device
@pytest.mark.parametrize(
"func, args, kwargs",
[
Expand Down Expand Up @@ -887,6 +900,7 @@ def test_random(func, args, kwargs, device, usm_type):
assert_sycl_queue_equal(res_array.sycl_queue, sycl_queue)


@pytest.mark.single_device
@pytest.mark.parametrize(
"func, args, kwargs",
[
Expand Down Expand Up @@ -1039,6 +1053,7 @@ def test_basic(self, device_from, device_to):
assert y.sycl_device == device_to
assert (x.asnumpy() == y.asnumpy()).all()

@pytest.mark.single_device
def test_to_queue(self):
x = dpnp.full(100, 2, dtype=dpnp.int64)
q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling")
Expand All @@ -1047,6 +1062,7 @@ def test_to_queue(self):
assert (x.asnumpy() == y.asnumpy()).all()
assert_sycl_queue_equal(y.sycl_queue, q_prof)

@pytest.mark.single_device
def test_stream(self):
x = dpnp.full(100, 2, dtype=dpnp.int64)
q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling")
Expand All @@ -1062,6 +1078,7 @@ def test_stream(self):
assert (x.asnumpy() == y.asnumpy()).all()
assert_sycl_queue_equal(y.sycl_queue, q_prof)

@pytest.mark.single_device
def test_stream_no_sync(self):
x = dpnp.full(100, 2, dtype=dpnp.int64)
q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling")
Expand All @@ -1071,6 +1088,7 @@ def test_stream_no_sync(self):
assert (x.asnumpy() == y.asnumpy()).all()
assert_sycl_queue_equal(y.sycl_queue, q_prof)

@pytest.mark.single_device
@pytest.mark.parametrize(
"stream",
[1, dict(), dpctl.SyclDevice()],
Expand Down Expand Up @@ -1783,6 +1801,7 @@ def test_cho_solve(self, a_data, b_data, device):
assert_sycl_queue_equal(result.sycl_queue, a.sycl_queue)
assert_sycl_queue_equal(result.sycl_queue, b.sycl_queue)

@pytest.mark.single_device
@pytest.mark.parametrize("c_shape", [(2, 2), (1, 2, 2)])
def test_cho_solve_diff_queue(self, c_shape, device):
c = dpnp.full(c_shape, 2.0, device=device)
Expand Down
Loading