Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EPIC] RFC: cuda namespace cleanup #75

Closed
leofang opened this issue Jul 16, 2024 · 2 comments
Closed

[EPIC] RFC: cuda namespace cleanup #75

leofang opened this issue Jul 16, 2024 · 2 comments
Assignees
Labels
cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements P0 High priority - Must do! RFC Plans and announcements

Comments

@leofang
Copy link
Member

leofang commented Jul 16, 2024

Impact

Very little, except for those accessing __version__ from the cuda namespace, via, say,

from cuda import __version__

We'll offer a fallback (that would raise a warning) before the transition concludes. Semantically, this will be equivalent to

from cuda.bindings import __version__

after the transition, so we do not expect to break any existing code. See below for further details.

Context

  1. cuda-python is currently tightly coupled to CTK releases (including its versioning scheme) which is problematic as we move higher in the stack (say by offering pythonic CUDA constructs that can be used across CTK major releases).
  2. We want to add more features and functionalities as modules under cuda, each of which is potentially separately versioned.
  3. The top-level module cuda is not yet a namespace module.
  4. The name cuda.cuda for the CUDA driver API bindings is confusing (why is “cuda” = driver?)

Existing module layout

  • driver:
    • cuda.cuda (Python)
    • cuda.ccuda (Cython)
    • cuda._cuda.ccuda (internal)
  • runtime:
    • cuda.cudart (Python)
    • cuda.ccudart (Cython)
    • cuda._lib.ccudart.ccudart (internal)
  • NVRTC:
    • cuda.nvrtc (Python)
    • cuda.cnvrtc (Cython)
    • cuda._cuda.cnvrtc (internal)
  • others:
    • cuda/__init__.py (only defines __version__ and nothing else)

Solution

This proposal solves the problem by requiring the following changes to support namespace packages:

  1. Remove cuda/__init__.py
  2. Move actual code from the listed modules above (see “Existing module layout”) to the new place below (see “New module layout”).
  3. Raise compile-time/run-time deprecation warnings in the existing modules listed above (see the “Transition plan” section below).
  4. Publish new namespace packages as they are implemented.

New module layout

  • bindings:
    • driver:
      • cuda.bindings.driver (Python)
      • cuda.bindings.cydriver (Cython)
      • cuda.bindings._internal.driver (internal)
    • runtime:
      • cuda.bindings.runtime (Python)
      • cuda.bindings.cyruntime (Cython)
      • cuda.bindings._internal.runtime (internal)
    • NVRTC:
      • cuda.bindings.nvrtc (Python)
      • cuda.bindings.cynvrtc (Cython)
      • cuda.bindings._internal.nvrtc (internal)
    • nvJitLink (future):
      • cuda.bindings.nvjitlink (Python)
      • cuda.bindings.cynvjitlink (Cython)
      • cuda.bindings._internal.nvjitlink (internal)
    • libnvvm (future):
      • cuda.bindings.libnvvm (Python)
      • cuda.bindings.cylibnvvm (Cython)
      • cuda.bindings._internal.libnvvm (internal)

Transition plan

The transition to namespace packages is meant to be a non-breaking change, at least within the CUDA minor releases.

  • CUDA 12.x (12.7?)
    • Raise a compile-time deprecation warning for users cimport’ing the Cython modules:
      • cuda.ccuda (driver)
        • internally: from cuda.bindings.driver cimport *
      • cuda.ccudart (runtime)
        • internally: from cuda.bindings.runtime cimport *
      • cuda.cnvrtc (NVRTC)
        • internally: from cuda.bindings.nvrtc cimport *
    • Raise a run-time DeprecationWarning for users import’ing the Python modules:
      • cuda.cuda (driver)
        • internally: from cuda.bindings.driver import *
      • cuda.cudart (runtime)
        • internally: from cuda.bindings.runtime import *
      • cuda.nvrtc (NVRTC)
        • internally: from cuda.bindings.nvrtc import *
    • The internal modules are not supposed to be used by anyone anyway, remove them right away.
      • cuda._cuda
      • cuda._lib
    • Add a migration guide to the documentation to teach about the new modules
    • Add release note entries to warn about the upcoming change
    • Post a new announcement to NVIDIA/cuda-python Discussion
    • Work with major impacted projects to start early migration:
      • Cython module users: RAPIDS, CuPy (link)
      • Python module users: Numba, ??????
  • CUDA 13.0
    • Turn the DeprecationWarning to user-visible UserWarning
  • CUDA 13.x
    • Remove the deprecated Cython & Python modules (at this point they don’t contain actual code, as they are just “trampolines”
      • cuda.ccuda (driver)
      • cuda.ccudart (runtime)
      • cuda.cnvrtc (NVRTC)
      • cuda.cuda (driver)
      • cuda.cudart (runtime)
      • cuda.nvrtc (NVRTC)
@github-actions github-actions bot added the triage Needs the team's attention label Jul 16, 2024
@leofang leofang added this to the cuda-12-RC1, cuda-11-RC1 milestone Jul 16, 2024
@leofang leofang changed the title cuda namespace cleanup RFC: cuda namespace cleanup Sep 10, 2024
@leofang
Copy link
Member Author

leofang commented Sep 10, 2024

(Updated issue description.)

@leofang leofang added enhancement Any code-related improvements P0 High priority - Must do! and removed triage Needs the team's attention labels Sep 10, 2024
@leofang leofang added the RFC Plans and announcements label Sep 11, 2024
@leofang leofang pinned this issue Sep 16, 2024
@jollylili jollylili changed the title RFC: cuda namespace cleanup [EPIC] RFC: cuda namespace cleanup Sep 16, 2024
This was referenced Oct 4, 2024
@leofang leofang added the cuda.bindings Everything related to the cuda.bindings module label Oct 10, 2024
@vzhurba01
Copy link
Collaborator

With all 4 sub-issues closed, this issue is complete. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements P0 High priority - Must do! RFC Plans and announcements
Projects
None yet
Development

No branches or pull requests

2 participants