cuda-python icon indicating copy to clipboard operation
cuda-python copied to clipboard

[BUG]: cuda.core.experimental._stream.IsStreamT and cuda.core.experimental._memory.DevicePointerT missing in v0.5.0

Open xiakun-lu opened this issue 2 months ago • 4 comments

Is this a duplicate?

  • [x] I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug

Runtime Error

Component

cuda.core

Describe the bug

cuda.core 0.5.0 removed "experimental" in the module path, and added expermental/init.py for compatibility, but cuda.core.experimental._stream.IsStreamT and cuda.core.experimental._memory.DevicePointerT are not included, leading to compatibility issue if IsStreamT or DevicePointerT is used.

Neither IsStreamT nor DevicePointerT is exposed in __init__.py and treated as public API, but they appears in the public API arg list, see:

  • https://nvidia.github.io/cuda-python/cuda-core/0.5.0/generated/cuda.core.Device.html#cuda.core.Device.create_stream
  • https://nvidia.github.io/cuda-python/cuda-core/0.5.0/generated/cuda.core.Buffer.html#cuda.core.Buffer.from_handle

they should be treated as public and maintain compatibility within a major version.

How to Reproduce

install cuda.core 0.5.0

Python 3.10.19 (main, Oct 28 2025, 12:10:48) [Clang 20.1.4 ] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import cuda 
>>> from cuda.core.experimental._stream import IsStreamT, Stream 
<stdin>:1: DeprecationWarning: The cuda.core.experimental namespace is deprecated. Please import directly from cuda.core instead. For example, use 'from cuda.core import Device' instead of 'from cuda.core.experimental import Device'. The experimental namespace will be removed in v1.0.0. 
Traceback (most recent call last): 
  File "<stdin>", line 1, in <module> 
ModuleNotFoundError: No module named 'cuda.core.experimental._stream' 

Expected behavior

from cuda.core.experimental._stream import IsStreamT and from cuda.core.experimental._memory import DevicePointerT should work w/o errors.

IsStreamT and DevicePointerT are exposed in cuda.core.experimental

Operating System

No response

nvidia-smi output

No response

xiakun-lu avatar Dec 22 '25 21:12 xiakun-lu

Summarizing offline discussion with @xiakun-lu below:

  1. It was a mistake that I made to not expose IsStreamT, DevicePointer, etc., to the public namespace
    • The purpose was for cuda.core to annotate our own APIs, and for us to build docs
  2. As a proper fix, the type annotations will be exposed to the public namespace (in this case cuda.core.IsStreamT)
  3. Following standard Python convention, no users should access cuda.core's private APIs (names prefixed by an underscore)
  4. As a workaround, I recommend applying this patch so as to avoid tight-pinning on any particular cuda-core version:
try:
    from cuda.core import IsStreamT
except ImportError:
    try:
        from cuda.core._stream import IsStreamT
    except ImportError:
        try:
            from cuda.core.experimental._stream import IsStreamT
        except ImportError:
            # raise or warn or just mock up IsStreamT here

leofang avatar Dec 23 '25 01:12 leofang

I also encountered this issue and fixed it with pip install cuda.core==0.4.1.

wujiahao15 avatar Dec 29 '25 01:12 wujiahao15

@leofang Is there a list of things that need to be exposed? All the current imports are exposed explicitly, so we'd need to do that with these imports as well. I guess we could star import from experimental as well, since that would exactly replicate previous behavior.

cpcloud avatar Jan 13 '26 17:01 cpcloud

Discussed offline with Phillip, we'd like to push this out to cuda-core v0.6.0 if it's OK @xiakun-lu?

Is there a list of things that need to be exposed?

I had this in mind: https://github.com/NVIDIA/cuda-python/blob/main/cuda_core/docs/source/api_private.rst Types that we list here should also be exposed to cuda.core (or cuda.core.typing, I don't have strong opinions either way).

leofang avatar Jan 13 '26 18:01 leofang