Skip to content

Request: Support for dpnp #442

Closed
Closed

Description

@Nin17

dpnp aims to be a drop-in replacement for NumPy and is already compatible with the 2024.12 version of the array api standard. As such it should be a relatively simple addition.

I'm mainly asking as I'd like the inspection helper functions array_api_compat.is_dpnp_array and array_api_compat.is_dpnp_namespace to be included.

Activity

  1. lucascolley commented on Jun 29, 2026

    @lucascolley
    Member

    cc @antonwolfy @vlad-perevezentsev

    would someone be interested in contributing this?

  2. ev-br commented on Jun 29, 2026

    @ev-br
    Member

    To double-check: it looks that from the -compat perspective, dpnp is similar to jax: the Array API support lives in the package itself, and array-api-compat only has the two helper functions:

    def is_jax_namespace(xp: Namespace) -> bool:

    and
    def is_jax_array(x: object) -> TypeIs[jax.Array]:

    Meanwhile ndonnx is similar but -compat does not have matching is_ndonnx_* functions. Thus I wonder why we need to special-case some array providers and not others. A main question I suppose is how is -compat layer useful to dpnp if it's already fully compatible @Nin17 ?

    OTOH there's no problem adding these two functions to -compat if it's anyhow useful.

  3. lucascolley commented on Jun 29, 2026

    @lucascolley
    Member

    Meanwhile ndonnx is similar but -compat does not have matching is_ndonnx_* functions. Thus I wonder why we need to special-case some array providers and not others. A main question I suppose is how is -compat layer useful to dpnp if it's already fully compatible @Nin17 ?

    OTOH there's no problem adding these two functions to -compat if it's anyhow useful.

    I think the main two reasons are:

    • a downstream library wants to run library X through their test-suite
    • a downstream library wants to write to the standard whilst also having special-cases for library X in production code

    I guess neither of those have happened yet for ndonnx (or people have been happy to roll their own).

  4. Nin17 commented on Jun 30, 2026

    @Nin17
    ContributorAuthor

    Meanwhile ndonnx is similar but -compat does not have matching is_ndonnx_* functions.

    Those functions are included:

    def is_ndonnx_array(x: object) -> TypeIs[ndx.Array]:

    def is_ndonnx_namespace(xp: Namespace) -> bool:

    A main question I suppose is how is -compat layer useful to dpnp if it's already fully compatible @Nin17 ?

    • a downstream library wants to write to the standard whilst also having special-cases for library X in production code

    Essentially that, I have an array api standard compliant implementation, but for performance reasons for libraries that support as_strided/sliding_window_view I want to use an alternative implementation. I could just implement my own check, but thought seeing as you already include similar functions for jax, ndonnx and pydata/sparse it may as well be included here.

  5. ev-br commented on Jun 30, 2026

    @ev-br
    Member

    Ah, thanks, don't know how I missed these two.

    Essentially that, I have an array api standard compliant implementation, but for performance reasons for libraries that support as_strided/sliding_window_view I want to use an alternative implementation. I could just implement my own check, but thought seeing as you already include similar functions for jax, ndonnx and pydata/sparse it may as well be included here.

    PR welcome!

  6. Nin17 commented on Aug 23, 2026

    @Nin17
    ContributorAuthor

    I've run array-api-tests against dpnp locally.

    With dpnp version 0.20.0 tested against the 2024.12 version of the standard I get this output:

    ========================================== short test summary info ==========================================
    FAILED array_api_tests/test_dlpack.py::test_dunder_dlpack - BufferError: array cannot be placed on the requested device without a copy
    FAILED array_api_tests/test_dlpack.py::test_from_dlpack - assert Device(opencl:cpu:0) == <dpctl.SyclDevice [backend_type.opencl, device_type.cpu,  Intel(R) Core(T...
    FAILED array_api_tests/test_linalg.py::test_trace - AssertionError: The input arrays have different values (array(0, dtype=uint8) != array(254, dtype=uint8)...
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(real(x_i) is +0 and imag(x_i) is NaN) -> NaN \xb1 \u03c0j/2] - AssertionError: out=(nan+nanj), but should be NaN ± πj/2 [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[tanh(real(x_i) is +infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> 1 + 0j] - AssertionError: out=(1-0j), but should be 1 + 0j [tanh()]
    ================== 5 failed, 1359 passed, 14 skipped, 183284 warnings in 242.08s (0:04:02) ==================
    

    With dpnp version 0.21.0dev5+5.ge654d623031 tested against the 2025.12 version of the standard I get this output:

    ========================================== short test summary info ==========================================
    FAILED array_api_tests/test_dlpack.py::test_dunder_dlpack - BufferError: array cannot be placed on the requested device without a copy
    ==================== 1 failed, 1376 passed, 5 skipped, 48 warnings in 231.91s (0:03:51) =====================
    

    I skipped the test_device_to_device test in the above PR but that issue seems to be fixed in 0.21.0dev5+5.ge654d623031. So I'd just need to add "2024.12" to the skipped array-api-versions in test_array_namespace and then as far as I can tell, all the tests would be passing apart from test_dunder_dlpack.

    Though none of this is tested in CI, I'm not sure how is best to do that.

  7. antonwolfy commented on Aug 24, 2026

    @antonwolfy

    test_dunder_dlpack is failing due to array-api-tests#456

  8. added this to the 1.16 milestone on Aug 24, 2026
  9. ev-br commented on Aug 24, 2026

    @ev-br
    Member

    Though none of this is tested in CI, I'm not sure how is best to do that.

    Am probably being dense: what is the problem with CI?

  10. Nin17 commented on Aug 24, 2026

    @Nin17
    ContributorAuthor

    Am probably being dense: what is the problem with CI?

    Essentially this comment from copilot: #467 (comment)

    The array-api-test tests are run by dpnp but the array-api-compat tests aren't run in CI with dpnp. So the tests in tests/test_array_namespace.py aren't being run with dpnp in CI. They seem to be being skipped with JAX etc as well.

    Related I also haven't added dpnp to the dev dependency group in pyproject.toml

    This is the output of the latest run:

    tests/test_array_namespace.py::test_array_namespace[dpnp-None-True] SKIPPED [ 26%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-None-False] SKIPPED [ 26%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-None-None] SKIPPED [ 26%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2021.12-True] SKIPPED [ 26%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2021.12-False] SKIPPED [ 26%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2021.12-None] SKIPPED [ 26%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2022.12-True] SKIPPED [ 26%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2022.12-False] SKIPPED [ 27%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2022.12-None] SKIPPED [ 27%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2023.12-True] SKIPPED [ 27%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2023.12-False] SKIPPED [ 27%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2023.12-None] SKIPPED [ 27%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2024.12-True] SKIPPED [ 27%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2024.12-False] SKIPPED [ 27%]
    tests/test_array_namespace.py::test_array_namespace[dpnp-2024.12-None] SKIPPED [ 28%]
    

    Shouldn't the 2024.12 and None cases not be skipped and the others xfailed based on the tests?

  11. ev-br commented on Aug 24, 2026

    @ev-br
    Member

    Ah yes, this is the -compat-specific CI is run:

    https://github.com/data-apis/array-api-compat/blob/main/.github/workflows/tests.yml

    I suppose it can install dpnp similar to Jax,sparse and ndonnx.
    Note however that this all is CPU-only, as we do not currently have any non-CPU CI.

  12. ev-br commented on Sep 6, 2026

    @ev-br
    Member

    Helpers for is_dpnp_* have been added in #467;
    The CI side of testing is blocked on the lack of readily available hardware, in #471
    I'll close this issue as completed: we do not require that everything is tested in CI anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions