From cd37245eac3b26c2aee9ab4b5116ae86a7451fc9 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Aug 2023 09:14:27 -0700 Subject: [PATCH 1/3] Treat warnings as errors in Python documentation (#1316) This will allow us to more easily audit the quality of our docs in CI going forward. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Lawrence Mitchell (https://github.com/wence-) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1316 --- ci/build_docs.sh | 8 +++---- .../all_cuda-118_arch-x86_64.yaml | 10 ++++++++ .../all_cuda-120_arch-x86_64.yaml | 10 ++++++++ dependencies.yaml | 2 ++ python/docs/Makefile | 2 +- python/docs/api.rst | 2 ++ python/docs/basics.md | 2 +- python/docs/conf.py | 12 ++++++++-- python/rmm/_lib/memory_resource.pyx | 23 +++++++++++++++++++ python/rmm/allocators/numba.py | 17 ++++++++++++++ python/rmm/mr.py | 2 ++ 11 files changed, 82 insertions(+), 8 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 956a7389d..d54947106 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -37,11 +37,11 @@ popd rapids-logger "Build Python docs" pushd python/docs -sphinx-build -b dirhtml . _html -sphinx-build -b text . _text +make dirhtml +make text mkdir -p "${RAPIDS_DOCS_DIR}/rmm/"{html,txt} -mv _html/* "${RAPIDS_DOCS_DIR}/rmm/html" -mv _text/* "${RAPIDS_DOCS_DIR}/rmm/txt" +mv _build/dirhtml/* "${RAPIDS_DOCS_DIR}/rmm/html" +mv _build/text/* "${RAPIDS_DOCS_DIR}/rmm/txt" popd rapids-upload-docs diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 0240b46e5..d56088fbc 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -9,12 +9,18 @@ dependencies: - cuda-version=11.8 - cudatoolkit - cython>=3.0.0 +- doxygen=1.8.20 - fmt>=9.1.0,<10 - gcovr>=5.0 +- graphviz - identify>=2.5.20 +- ipython +- make +- nbsphinx - ninja - numba>=0.57 - numpy>=1.21 +- numpydoc - nvcc_linux-64=11.8 - pre-commit - pytest @@ -22,5 +28,9 @@ dependencies: - python>=3.9,<3.11 - scikit-build>=0.13.1 - spdlog>=1.11.0,<1.12 +- sphinx +- sphinx-copybutton +- sphinx-markdown-tables +- sphinx_rtd_theme - tomli name: all_cuda-118_arch-x86_64 diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index 96b8c8065..baa480a1f 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -9,17 +9,27 @@ dependencies: - cuda-python>=12.0,<13.0a0 - cuda-version=12.0 - cython>=3.0.0 +- doxygen=1.8.20 - fmt>=9.1.0,<10 - gcovr>=5.0 +- graphviz - identify>=2.5.20 +- ipython +- make +- nbsphinx - ninja - numba>=0.57 - numpy>=1.21 +- numpydoc - pre-commit - pytest - pytest-cov - python>=3.9,<3.11 - scikit-build>=0.13.1 - spdlog>=1.11.0,<1.12 +- sphinx +- sphinx-copybutton +- sphinx-markdown-tables +- sphinx_rtd_theme - tomli name: all_cuda-120_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 17fb1d66d..e16d7a292 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -10,6 +10,7 @@ files: - checks - cudatoolkit - develop + - docs - run - test_python test_python: @@ -155,6 +156,7 @@ dependencies: - doxygen=1.8.20 - graphviz - ipython + - make - nbsphinx - numpydoc - sphinx diff --git a/python/docs/Makefile b/python/docs/Makefile index d4bb2cbb9..72d1dcd85 100644 --- a/python/docs/Makefile +++ b/python/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= +SPHINXOPTS = -n -v -W --keep-going SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build diff --git a/python/docs/api.rst b/python/docs/api.rst index 73cd5dd81..b229d8214 100644 --- a/python/docs/api.rst +++ b/python/docs/api.rst @@ -15,6 +15,7 @@ Memory Resources .. automodule:: rmm.mr :members: + :inherited-members: :undoc-members: :show-inheritance: @@ -28,6 +29,7 @@ Memory Allocators .. automodule:: rmm.allocators.numba :members: + :inherited-members: :undoc-members: :show-inheritance: diff --git a/python/docs/basics.md b/python/docs/basics.md index 0c47073c1..997745f00 100644 --- a/python/docs/basics.md +++ b/python/docs/basics.md @@ -91,7 +91,7 @@ example, enabling the `ManagedMemoryResource` tells RMM to use > :warning: The default resource must be set for any device **before** > allocating any device memory on that device. Setting or changing the > resource after device allocations have been made can lead to unexpected -> behaviour or crashes. See [Multiple Devices](#multiple-devices) +> behaviour or crashes. As another example, `PoolMemoryResource` allows you to allocate a large "pool" of device memory up-front. Subsequent allocations will diff --git a/python/docs/conf.py b/python/docs/conf.py index 3010fc069..76b95183e 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -113,7 +113,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] +html_static_path = [] # -- Options for HTMLHelp output ------------------------------------------ @@ -179,7 +179,10 @@ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {"https://docs.python.org/": None} +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "numba": ("https://numba.readthedocs.io/en/stable", None), +} # Config numpydoc numpydoc_show_inherited_class_members = True @@ -187,6 +190,11 @@ autoclass_content = "init" +nitpick_ignore = [ + ("py:class", "size_t"), + ("py:class", "void"), +] + def setup(app): app.add_js_file("copybutton_pydocs.js") diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index aa0d21d1f..0e9277f31 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -217,18 +217,41 @@ cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ cdef class DeviceMemoryResource: cdef device_memory_resource* get_mr(self): + """Get the underlying C++ memory resource object.""" return self.c_obj.get() def allocate(self, size_t nbytes): + """Allocate ``nbytes`` bytes of memory. + + Parameters + ---------- + nbytes : size_t + The size of the allocation in bytes + """ return self.c_obj.get().allocate(nbytes) def deallocate(self, uintptr_t ptr, size_t nbytes): + """Deallocate memory pointed to by ``ptr`` of size ``nbytes``. + + Parameters + ---------- + ptr : uintptr_t + Pointer to be deallocated + nbytes : size_t + Size of the allocation in bytes + """ self.c_obj.get().deallocate((ptr), nbytes) # See the note about `no_gc_clear` in `device_buffer.pyx`. @cython.no_gc_clear cdef class UpstreamResourceAdaptor(DeviceMemoryResource): + """Parent class for all memory resources that track an upstream. + + Upstream resource tracking requires maintaining a reference to the upstream + mr so that it is kept alive and may be accessed by any downstream resource + adaptors. + """ def __cinit__(self, DeviceMemoryResource upstream_mr, *args, **kwargs): diff --git a/python/rmm/allocators/numba.py b/python/rmm/allocators/numba.py index 18a010e1c..5e87b87b6 100644 --- a/python/rmm/allocators/numba.py +++ b/python/rmm/allocators/numba.py @@ -13,6 +13,7 @@ # limitations under the License. import ctypes +import inspect from cuda.cuda import CUdeviceptr, cuIpcGetMemHandle from numba import config, cuda @@ -112,6 +113,12 @@ def get_ipc_handle(self, memory): ) def get_memory_info(self): + """Returns ``(free, total)`` memory in bytes in the context. + + This implementation raises `NotImplementedError` because the allocation + will be performed using rmm's currently set default mr, which may be a + pool allocator. + """ raise NotImplementedError() @property @@ -119,6 +126,16 @@ def interface_version(self): return 1 +# The parent class docstrings contain references without fully qualified names, +# so we need to replace them here for our Sphinx docs to render properly. +for _, method in inspect.getmembers(RMMNumbaManager, inspect.isfunction): + if method.__doc__ is not None: + method.__doc__ = method.__doc__.replace( + ":class:`BaseCUDAMemoryManager`", + ":class:`numba.cuda.BaseCUDAMemoryManager`", + ) + + # Enables the use of RMM for Numba via an environment variable setting, # NUMBA_CUDA_MEMORY_MANAGER=rmm. See: # https://numba.readthedocs.io/en/stable/cuda/external-memory.html#environment-variable diff --git a/python/rmm/mr.py b/python/rmm/mr.py index ea0a0cf8c..a00d96184 100644 --- a/python/rmm/mr.py +++ b/python/rmm/mr.py @@ -24,6 +24,7 @@ PoolMemoryResource, StatisticsResourceAdaptor, TrackingResourceAdaptor, + UpstreamResourceAdaptor, _flush_logs, _initialize, disable_logging, @@ -51,6 +52,7 @@ "StatisticsResourceAdaptor", "TrackingResourceAdaptor", "FailureCallbackResourceAdaptor", + "UpstreamResourceAdaptor", "_flush_logs", "_initialize", "set_per_device_resource", From 314b669a0e1747acf6e27b1a41a86459180bdb8d Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 9 Aug 2023 12:31:00 -0400 Subject: [PATCH 2/3] Update Changelog [skip ci] --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 385798d20..453ab54c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +# RMM 23.08.00 (9 Aug 2023) + +## 🚨 Breaking Changes + +- Stop invoking setup.py ([#1300](https://github.com/rapidsai/rmm/pull/1300)) [@vyasr](https://github.com/vyasr) +- Remove now-deprecated top-level allocator functions ([#1281](https://github.com/rapidsai/rmm/pull/1281)) [@wence-](https://github.com/wence-) +- Remove padding from device_memory_resource ([#1278](https://github.com/rapidsai/rmm/pull/1278)) [@vyasr](https://github.com/vyasr) + +## 🐛 Bug Fixes + +- Fix typo in wheels-test.yaml. ([#1310](https://github.com/rapidsai/rmm/pull/1310)) [@bdice](https://github.com/bdice) +- Add a missing '#include <array>' in logger.hpp ([#1295](https://github.com/rapidsai/rmm/pull/1295)) [@valgur](https://github.com/valgur) +- Use gbench `thread_index()` accessor to fix replay bench compilation ([#1293](https://github.com/rapidsai/rmm/pull/1293)) [@harrism](https://github.com/harrism) +- Ensure logger tests don't generate temp directories in build dir ([#1289](https://github.com/rapidsai/rmm/pull/1289)) [@robertmaynard](https://github.com/robertmaynard) + +## 🚀 New Features + +- Remove now-deprecated top-level allocator functions ([#1281](https://github.com/rapidsai/rmm/pull/1281)) [@wence-](https://github.com/wence-) + +## 🛠️ Improvements + +- Switch to new CI wheel building pipeline ([#1305](https://github.com/rapidsai/rmm/pull/1305)) [@vyasr](https://github.com/vyasr) +- Revert CUDA 12.0 CI workflows to branch-23.08. ([#1303](https://github.com/rapidsai/rmm/pull/1303)) [@bdice](https://github.com/bdice) +- Update linters: remove flake8, add ruff, update cython-lint ([#1302](https://github.com/rapidsai/rmm/pull/1302)) [@vyasr](https://github.com/vyasr) +- Adding identify minimum version requirement ([#1301](https://github.com/rapidsai/rmm/pull/1301)) [@hyperbolic2346](https://github.com/hyperbolic2346) +- Stop invoking setup.py ([#1300](https://github.com/rapidsai/rmm/pull/1300)) [@vyasr](https://github.com/vyasr) +- Use cuda-version to constrain cudatoolkit. ([#1296](https://github.com/rapidsai/rmm/pull/1296)) [@bdice](https://github.com/bdice) +- Update to CMake 3.26.4 ([#1291](https://github.com/rapidsai/rmm/pull/1291)) [@vyasr](https://github.com/vyasr) +- use rapids-upload-docs script ([#1288](https://github.com/rapidsai/rmm/pull/1288)) [@AyodeAwe](https://github.com/AyodeAwe) +- Reorder parameters in RMM_EXPECTS ([#1286](https://github.com/rapidsai/rmm/pull/1286)) [@vyasr](https://github.com/vyasr) +- Remove documentation build scripts for Jenkins ([#1285](https://github.com/rapidsai/rmm/pull/1285)) [@ajschmidt8](https://github.com/ajschmidt8) +- Remove padding from device_memory_resource ([#1278](https://github.com/rapidsai/rmm/pull/1278)) [@vyasr](https://github.com/vyasr) +- Unpin scikit-build upper bound ([#1275](https://github.com/rapidsai/rmm/pull/1275)) [@vyasr](https://github.com/vyasr) +- RMM: Build CUDA 12 packages ([#1223](https://github.com/rapidsai/rmm/pull/1223)) [@bdice](https://github.com/bdice) + # RMM 23.06.00 (7 Jun 2023) ## 🚨 Breaking Changes From 663e659451341505636daa7e05a94ef84290a870 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:46:11 -0500 Subject: [PATCH 3/3] Fix missing jQuery error in docs (#1321) The latest versions `4.1` and `4.0` of `sphinxcontrib-jquery` have an issue with jQuery installed currently in sphinx. This is causing the search functionality to fail so I've pinned the version to `3.0.0`, this resolves the issue. Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - https://github.com/jakirkham - AJ Schmidt (https://github.com/ajschmidt8) --- python/docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/docs/conf.py b/python/docs/conf.py index 76b95183e..17c012194 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -35,6 +35,7 @@ # ones. extensions = [ + "sphinxcontrib.jquery", "sphinx.ext.intersphinx", "sphinx.ext.autodoc", "sphinx.ext.autosummary",