Skip to content

Commit 8a75d1b

Browse files
rparolinclaude
andcommitted
fix: validate managed buffer before checking discard_prefetch bindings support
Reorder checks in discard_prefetch so _normalize_managed_target_range runs before _require_managed_discard_prefetch_support. This ensures non-managed buffers raise ValueError before the RuntimeError for missing cuMemDiscardAndPrefetchBatchAsync support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 89329d9 commit 8a75d1b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cuda_core/cuda/core/_memory/_buffer.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,13 @@ def discard_prefetch(
489489
Explicit location kind. Supported values are ``"device"``, ``"host"``,
490490
``"host_numa"``, and ``"host_numa_current"``.
491491
"""
492-
_require_managed_discard_prefetch_support("discard_prefetch")
493-
cdef Stream s = Stream_accept(stream)
494492
cdef object ptr
495493
cdef object batch_ptr
496494
cdef size_t nbytes
497495

498496
ptr, nbytes = _normalize_managed_target_range(target, size, "discard_prefetch")
497+
_require_managed_discard_prefetch_support("discard_prefetch")
498+
cdef Stream s = Stream_accept(stream)
499499
batch_ptr = driver.CUdeviceptr(int(ptr))
500500
location = _normalize_managed_location(
501501
location,

0 commit comments

Comments
 (0)