Skip to content

Commit d6f60f2

Browse files
rparolinclaude
andcommitted
refactor(cuda.core): move managed_memory ops to cuda.core.utils
Per Leo's review request (#1775 (comment)), fold the managed-memory free functions and the Location dataclass into cuda.core.utils rather than maintaining a dedicated cuda.core.managed_memory namespace. - Re-export Location, advise, prefetch, discard, discard_prefetch from cuda.core.utils. - Delete cuda.core.managed_memory module. - Update cuda.core.__init__ to drop the managed_memory submodule import. - Update tests to import from cuda.core.utils. - Update api.rst: drop the dedicated Managed memory section; add the managed-memory entries to the Utility functions section. - Update 1.0.0-notes.rst accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ee96758 commit d6f60f2

6 files changed

Lines changed: 79 additions & 95 deletions

File tree

cuda_core/cuda/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _import_versioned_module():
2828
del _import_versioned_module
2929

3030

31-
from cuda.core import managed_memory, system, utils
31+
from cuda.core import system, utils
3232
from cuda.core._device import Device
3333
from cuda.core._event import Event, EventOptions
3434
from cuda.core._graphics import GraphicsResource

cuda_core/cuda/core/managed_memory.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

cuda_core/cuda/core/utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5+
from cuda.core._memory._managed_location import Location # noqa: F401
6+
from cuda.core._memory._managed_memory_ops import (
7+
advise, # noqa: F401
8+
discard, # noqa: F401
9+
discard_prefetch, # noqa: F401
10+
prefetch, # noqa: F401
11+
)
512
from cuda.core._memoryview import (
613
StridedMemoryView, # noqa: F401
714
args_viewable_as_strided_memory, # noqa: F401

cuda_core/docs/source/api.rst

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,6 @@ Each subclass exposes attributes unique to its operation type.
129129
graph.SwitchNode
130130

131131

132-
.. module:: cuda.core.managed_memory
133-
134-
Managed memory
135-
--------------
136-
137-
.. autosummary::
138-
:toctree: generated/
139-
140-
Location
141-
advise
142-
prefetch
143-
discard
144-
discard_prefetch
145-
146-
.. module:: cuda.core
147-
:no-index:
148-
149-
150132
Graphics interoperability
151133
-------------------------
152134

@@ -265,7 +247,12 @@ Utility functions
265247
:toctree: generated/
266248

267249
args_viewable_as_strided_memory
250+
advise
251+
prefetch
252+
discard
253+
discard_prefetch
268254

269255
:template: autosummary/cyclass.rst
270256

257+
Location
271258
StridedMemoryView

cuda_core/docs/source/release/1.0.0-notes.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ Highlights
1616
New features
1717
------------
1818

19-
- Added managed-memory range operations under :mod:`cuda.core.managed_memory`:
20-
:class:`~managed_memory.Location`, :func:`~managed_memory.advise`,
21-
:func:`~managed_memory.prefetch`, :func:`~managed_memory.discard`, and
22-
:func:`~managed_memory.discard_prefetch`. Each operation accepts either a
23-
single managed :class:`Buffer` or a sequence; with cuda.bindings 12.8+
24-
the N>1 case dispatches to the corresponding ``cuMem*BatchAsync`` driver
25-
entry point, addressing the managed-memory portion of #1333. Locations
26-
are expressed via the typed :class:`~managed_memory.Location` dataclass
27-
(with classmethod constructors ``device``, ``host``, ``host_numa``, and
28-
``host_numa_current``); ``Device`` and ``int`` values are still accepted
29-
for ergonomic compatibility.
19+
- Added managed-memory range operations to :mod:`cuda.core.utils`:
20+
:class:`~utils.Location`, :func:`~utils.advise`, :func:`~utils.prefetch`,
21+
:func:`~utils.discard`, and :func:`~utils.discard_prefetch`. Each
22+
operation accepts either a single managed :class:`Buffer` or a
23+
sequence; with cuda.bindings 12.8+ the N>1 case dispatches to the
24+
corresponding ``cuMem*BatchAsync`` driver entry point, addressing the
25+
managed-memory portion of #1333. Locations are expressed via the typed
26+
:class:`~utils.Location` dataclass (with classmethod constructors
27+
``device``, ``host``, ``host_numa``, and ``host_numa_current``);
28+
``Device`` and ``int`` values are still accepted for ergonomic
29+
compatibility.
3030

3131

3232
Fixes and enhancements

0 commit comments

Comments
 (0)