Skip to content

Commit c63874d

Browse files
committed
fix(cuda.core): define _read_preferred_location_v2 stub on cu12 builds
Commit 7344d89 lifted the `_read_preferred_location_v2` import in `_managed_buffer.py` from deferred (inside the property getter) to module top, per leofang's "no deferred imports" guidance. But that function was only defined inside the `IF CUDA_CORE_BUILD_MAJOR >= 13` block in `_managed_memory_ops.pyx`, so on a cu12 build the symbol doesn't exist and `import cuda.core` fails with ImportError: cannot import name '_read_preferred_location_v2' from 'cuda.core._memory._managed_memory_ops' Add an ELSE branch defining a stub that raises `NotImplementedError`. `ManagedBuffer.preferred_location` already gates on both binding_version() and driver_version() >= (13, 0, 0) before calling, so the stub is unreachable at runtime — it exists only to satisfy the unconditional module-level import on cu12. Fixes CI failure on all 12.9.1 test jobs.
1 parent 47d2358 commit c63874d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cuda_core/cuda/core/_memory/_managed_memory_ops.pyx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,16 @@ IF CUDA_CORE_BUILD_MAJOR >= 13:
367367
loc_arr.data(), loc_indices.data(), <size_t>n,
368368
0, hstream,
369369
))
370+
ELSE:
371+
def _read_preferred_location_v2(Buffer buf):
372+
# Symbol exists so _managed_buffer.py can `from ... import
373+
# _read_preferred_location_v2` unconditionally at module top.
374+
# `ManagedBuffer.preferred_location` gates on both
375+
# binding_version() and driver_version() >= (13, 0, 0) before
376+
# calling, so this path is unreachable on a cu12 build.
377+
raise NotImplementedError(
378+
"_read_preferred_location_v2 requires a CUDA 13 build of cuda.core"
379+
)
370380

371381

372382
cdef void _do_batch_prefetch(tuple bufs, tuple locs, Stream s):

0 commit comments

Comments
 (0)