Skip to content

Remove the legacy backend - #3163

Open
ndgrigorian wants to merge 5 commits into
feature/device-rng-random-statefrom
feature/remove-legacy-rng
Open

ndgrigorian wants to merge 5 commits into
feature/device-rng-random-statefrom
feature/remove-legacy-rng

Conversation

@ndgrigorian

@ndgrigorian ndgrigorian commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

This PR removes the legacy dpnp_backend_c library and the Cython layer built on it, as the last part of the series splitting #3147. It is stacked on #3162. With dpnp.random on the device RNG (#3157-#3162) and dpnp.partition on libtensor (#3138), nothing calls the backend any more.

Removes

  • All of dpnp/backend: the RNG kernels, DPNPRandomState and the mt19937/mcg59 engines, the function-pointer tables, the C++ examples, the GTest suite with the DPNP_BACKEND_TESTS CMake option, and the Doxygen docs with their page in the documentation
  • The Cython modules dpnp_algo, dpnp_algo_random and dpnp_algo_utils, and the NumPy fallback helper call_origin
  • dpnp.get_dpnp_descriptor, with dpnp_descriptor and the dpnp.config.__DPNP_ORIGIN__ setting that only it read
  • The dpnp.config.__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__ setting, which nothing reads since dpnp no longer falls back on NumPy
  • The onemkl-sycl-rng pin in the conda recipes

Also

  • get_usm_allocations and map_dtype_to_device are now in a Python module, dpnp/dpnp_utils/dpnp_algo_utils.py, and convert_item, which only the test helpers use, moves to dpnp/tests/testing/array.py
  • dpnp/__init__.py imports dpnp.config itself, which it used to get as a side effect of the Cython dpnp_algo_utils
  • The vendored CMake modules move from dpnp/backend/cmake/Modules to cmake/Modules
  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.22.0dev3=np2py314h8d9cdd5_131 ran successfully.
Passed: 1491
Failed: 0
Skipped: 6

@coveralls

coveralls commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage is 86.099% — feature/remove-legacy-rng into feature/device-rng-random-state. No base build found for feature/device-rng-random-state.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/3163/index.html

@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from 71b2060 to 86d7f1b Compare November 6, 2026 17:55
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-random-state branch from 160719a to 014a132 Compare November 6, 2026 17:55
@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from c3083f7 to 5ed41e0 Compare November 8, 2026 21:54
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-random-state branch from edee62b to 843a343 Compare November 8, 2026 21:54
Comment thread CHANGELOG.md Resolved
Comment thread conda-recipe-cf/meta.yaml Resolved
@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from 5ed41e0 to c60c009 Compare November 13, 2026 20:06
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-random-state branch from 843a343 to 0232b4c Compare November 13, 2026 20:06
@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from c60c009 to 9c8c9ec Compare November 13, 2026 22:41
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-random-state branch 2 times, most recently from 804d1ed to f2ab866 Compare November 16, 2026 15:57
@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from 9c8c9ec to c5b012f Compare November 16, 2026 15:57
Comment thread conda-recipe-cf/meta.yaml Resolved
@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from c5b012f to ae88fe1 Compare November 17, 2026 21:13
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-random-state branch 2 times, most recently from 46d8cc7 to 8463a23 Compare November 20, 2026 01:26
@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from ae88fe1 to 02dec42 Compare November 20, 2026 01:26
dpnp.random no longer uses dpnp_backend_c, and dpnp.partition left it in
gh-3138, so nothing calls the backend any more. Drop the whole of
dpnp/backend: the RNG kernels, DPNPRandomState and the backend engines,
the function-pointer tables, the GTest suite with the DPNP_BACKEND_TESTS
option, the examples and the Doxygen docs. With it go the Cython modules
dpnp_algo, dpnp_algo_random and dpnp_algo_utils, call_origin,
get_dpnp_descriptor with dpnp_descriptor and the DPNP_ORIGIN setting it
read. The helpers of dpnp_algo_utils that are still used become a Python
module, the vendored CMake modules move to cmake/Modules, and the conda
recipes no longer pin onemkl-sycl-rng.
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-random-state branch from d2f000b to 3194517 Compare November 23, 2026 20:18
@ndgrigorian
ndgrigorian force-pushed the feature/remove-legacy-rng branch from 9139b78 to 2e82bd8 Compare November 23, 2026 20:18
@ndgrigorian ndgrigorian changed the title Remove the legacy backend RNG Remove the legacy backend Nov 23, 2026
It came only through the ignored mkl-dpcpp run export, so import dpnp
failed to load libmkl_sycl_sparse.
dpnp itself never calls it; only the assert wrappers in
dpnp/tests/testing/array.py convert their arguments with it.

@vlad-perevezentsev vlad-perevezentsev left a comment

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.

Nothing loads the backend or libmkl_sycl_rng any more, the random streams are bit-identical to #3162, and the tests pass.
A few comments below:

Comment thread CHANGELOG.md
* Removed the legacy backend implementation of `dpnp.random`, which no longer needs `onemkl-sycl-rng` [#3163](https://github.com/IntelPython/dpnp/pull/3163)
* Removed the legacy `dpnp_backend_c` library with its GTest suite and the `DPNP_BACKEND_TESTS` CMake option, the Cython module `dpnp.dpnp_algo.dpnp_algo` built on it, and the NumPy fallback helper `call_origin` [#3163](https://github.com/IntelPython/dpnp/pull/3163)
* Removed `dpnp.get_dpnp_descriptor` and the `dpnp.config.__DPNP_ORIGIN__` setting, set by the `DPNP_ORIGIN` environment variable, which only it read [#3163](https://github.com/IntelPython/dpnp/pull/3163)
* Removed the `dpnp.config.__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__` setting, set by the `DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK` environment variable, which nothing reads since dpnp no longer falls back on NumPy [#3163](https://github.com/IntelPython/dpnp/pull/3163)

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.

Following up on #3163 (comment): 5671b36 now removes __DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__ without the deprecation it had before, and __DPNP_ORIGIN__ goes the same way. Code that still sets them now fails instead of warning:

import pytest, dpnp

with pytest.MonkeyPatch.context() as mp:
    mp.setattr(dpnp.config, "__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__", 0)
# AttributeError: <module 'dpnp.config' ...> has no attribute '__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__'
# #3162 head: no error

Could both go into _DEPRECATED_SETTINGS for a release, as the earlier version of this commit did?

# *****************************************************************************


"""Helpers to place the result of a computation on its inputs' queue."""

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.

In a tree built in place before this PR, dpnp/dpnp_utils/dpnp_algo_utils.cpython-*.so stays after build_locally.py, and Python imports it instead of this file: extension modules win over .py files. Then import dpnp still loads the old Cython module, libdpnp_backend_c.so and libmkl_sycl_rng, and edits here have no effect:

# a tree built before this PR, after `git checkout` of this PR and `python scripts/build_locally.py`
python -c "import dpnp.dpnp_utils.dpnp_algo_utils as m; print(m.__file__)"
# .../dpnp/dpnp_utils/dpnp_algo_utils.cpython-314-x86_64-linux-gnu.so

Could this module get a name an old build does not have, e.g. dpnp_utils/dpnp_utils_usm.py?

Comment thread CMakeLists.txt
# 8. Paths stored in the CMake System Package Registry
# 9. Paths specified by the PATHS option (assumed hard-coded guesses)
set(path_to_cmake_dir ${CMAKE_SOURCE_DIR}/dpnp/backend/cmake/Modules)
set(path_to_cmake_dir ${CMAKE_SOURCE_DIR}/cmake/Modules)

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.

Nit: Nothing links the oneDPL target after this PR: dpnp_backend_c was its only user. So ONEDPL_PAR_BACKEND and find_package(oneDPL REQUIRED ...) at lines 96-97 now only check that oneDPL is installed; gcd.hpp and lcm.hpp in libtensor get <oneapi/dpl/numeric> from the default include path. If the lines stay for that check, a short comment saying so would help.

run: cp -r dpnp/backend/doc/html ${{ env.PUBLISH_DIR }}/backend_doc

# Detect if this is a fork PR
- name: Check if fork PR

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.

Nit: With these steps gone, backend_doc/ is no longer built, but publishing to . keeps the files already on gh-pages. So https://intelpython.github.io/dpnp/backend_doc/ will keep serving the docs of the removed backend, with nothing linking to it. Could it be deleted from gh-pages once this is merged?

Comment thread dpnp/__init__.py

# For Windows OS with Python >= 3.7, it is required to explicitly define a path
# where to search for DLLs towards both DPNP backend and DPCTL Sycl interface,
# where to search for the DLLs of DPNP and of the DPCTL Sycl interface,

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.

Nit: After this PR nothing installs a DLL into dpnp/: the Windows package of this head has only .pyd modules, in dpnp/libtensor and dpnp/tensor. So os.add_dll_directory(mypath) and mypath in PATH below have no use now. Could they go, with this comment naming only the DPCTL interface library?



@pytest.mark.usefixtures("allow_fall_back_on_numpy")
def test_bytes():

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.

Nit: import pytest at line 1 is unused now that the usefixtures line is gone.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants