Skip to content

Make Linker.backend a classmethod#1910

Open
cpcloud wants to merge 4 commits intoNVIDIA:mainfrom
cpcloud:linker-backend-classmethod-714
Open

Make Linker.backend a classmethod#1910
cpcloud wants to merge 4 commits intoNVIDIA:mainfrom
cpcloud:linker-backend-classmethod-714

Conversation

@cpcloud
Copy link
Copy Markdown
Contributor

@cpcloud cpcloud commented Apr 14, 2026

Summary

  • Converts Linker.backend from an instance property to a classmethod so callers can query the linking backend without constructing a Linker
  • Classmethod calls _decide_nvjitlink_or_driver() (existing memoised probe) and maps the return value to "nvJitLink" or "driver"
  • Updates the one in-repo call site in _program.pyx and existing test assertion to use parens
  • Adds 6 GPU-free tests via monkeypatch (no Device() / cuInit required)
  • Adds 0.8.0-notes.rst documenting the breaking change

Breaking change: linker.backend (attribute access) now returns a bound method, not a string. All call sites must use Linker.backend(). Only 2 in-repo call sites affected; numba-cuda (the requester) will adopt Linker.backend() from day one.

Test plan

  • 6 GPU-free tests pass locally (monkeypatch on module globals)
  • CI: existing GPU test test_linker_init passes with updated paren call
  • CI: Cython compile succeeds

Closes #714

🤖 Generated with Claude Code

@cpcloud cpcloud added this to the cuda.core v1.0.0 milestone Apr 14, 2026
@cpcloud cpcloud added enhancement Any code-related improvements P0 High priority - Must do! cuda.core Everything related to the cuda.core module breaking Breaking changes are introduced labels Apr 14, 2026
@cpcloud cpcloud self-assigned this Apr 14, 2026
@cpcloud cpcloud force-pushed the linker-backend-classmethod-714 branch 2 times, most recently from dbe6176 to 215418a Compare April 16, 2026 21:45
@cpcloud cpcloud requested a review from leofang April 17, 2026 12:58
Copy link
Copy Markdown
Member

@leofang leofang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Phillip! Implementation-wise LGTM. Left a few suggestions.

Comment thread cuda_core/docs/source/release/1.0.0-notes.rst
Comment thread cuda_core/tests/test_linker_backend.py Outdated
Comment thread cuda_core/tests/test_linker_backend.py Outdated
Comment thread cuda_core/docs/source/release/1.0.0-notes.rst
cpcloud added 3 commits April 21, 2026 11:14
Allows querying the linking backend without constructing a Linker
instance — useful for dispatching on input format (PTX vs. LTOIR)
before linking.

Updates existing call sites (Program init, test_linker) to use the
new invocation form Linker.backend().
Covers classmethod invocation (Linker.backend() without an instance),
memoisation flag handling, probe-on-first-use, and non-property
attribute semantics.
Breaking change: Linker.backend is now a classmethod, so call sites
must use parens: Linker.backend().
@cpcloud cpcloud force-pushed the linker-backend-classmethod-714 branch from 215418a to 12d291b Compare April 21, 2026 15:21
@cpcloud cpcloud requested a review from leofang April 21, 2026 19:48
Copy link
Copy Markdown
Member

@leofang leofang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we just recently went to the opposite direction (converting some methods to properties, #1945 & #1986), it'd be better to have @mdboom or @Andy-Jost to chime in from the design consistency perspective. It might be possible that we need to re-evaluate if #714 is really necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking changes are introduced cuda.core Everything related to the cuda.core module enhancement Any code-related improvements P0 High priority - Must do!

3 participants