Skip to content

Make Linker.backend a classmethod#1910

Merged
leofang merged 5 commits intoNVIDIA:mainfrom
cpcloud:linker-backend-classmethod-714
May 7, 2026
Merged

Make Linker.backend a classmethod#1910
leofang merged 5 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
@github-actions

This comment has been minimized.

@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 Outdated
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.

Comment thread cuda_core/cuda/core/_linker.pyx Outdated
@leofang
Copy link
Copy Markdown
Member

leofang commented May 5, 2026

We discussed this PR in the team sync today, but I forgot the conclusion... Maybe Mike or Ralf remembers? 😅

Comment thread cuda_core/cuda/core/_linker.pyx Outdated
@leofang leofang self-requested a review May 5, 2026 14:43
Merge upstream main into linker-backend-classmethod-714 and resolve
three conflicts (_linker.pyx, _program.pyx, 1.0.0-notes.rst).

Also rename Linker.backend to Linker.which_backend per review feedback
from Ralf, and update the return type from str to CompilerBackendType
to match main's enum convention.
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented May 7, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@leofang
Copy link
Copy Markdown
Member

leofang commented May 7, 2026

/ok to test 792d99f

@leofang leofang enabled auto-merge (squash) May 7, 2026 02:57
@leofang leofang disabled auto-merge May 7, 2026 04:34
@leofang leofang merged commit a61cb05 into NVIDIA:main May 7, 2026
94 checks passed
github-actions Bot pushed a commit that referenced this pull request May 7, 2026
Removed preview folders for the following PRs:
- PR #1910
- PR #2018
- PR #2031
- PR #2035
- PR #2037
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Doc Preview CI
Preview removed because the pull request was closed or merged.

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!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA]: Make Linker.backend a classmethod

5 participants