Skip to content

Make Linker.backend a classmethod - #1910

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

Make Linker.backend a classmethod#1910
leofang merged 5 commits into
NVIDIA:mainfrom
cpcloud:linker-backend-classmethod-714

Conversation

@cpcloud

@cpcloudcpcloud commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

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

@cpcloudcpcloud added this to the cuda.core v1.0.0 milestone Apr 14, 2026
@cpcloudcpcloud 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
@cpcloudcpcloud self-assigned this Apr 14, 2026
@github-actions

This comment has been minimized.

@cpcloud
cpcloudforce-pushed the linker-backend-classmethod-714 branch 2 times, most recently from dbe6176 to 215418aCompareApril 16, 2026 21:45
@cpcloud
cpcloud requested a review from leofangApril 17, 2026 12:58

@leofangleofang left a comment

Copy link
Copy Markdown
Member

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 threadcuda_core/docs/source/release/1.0.0-notes.rst
Comment threadcuda_core/tests/test_linker_backend.py Outdated
Comment threadcuda_core/tests/test_linker_backend.py Outdated
Comment threadcuda_core/docs/source/release/1.0.0-notes.rst Outdated
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
cpcloudforce-pushed the linker-backend-classmethod-714 branch from 215418a to 12d291bCompareApril 21, 2026 15:21
@cpcloud
cpcloud requested a review from leofangApril 21, 2026 19:48

@leofangleofang left a comment

Copy link
Copy Markdown
Member

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 threadcuda_core/cuda/core/_linker.pyx Outdated
@leofang

Copy link
Copy Markdown
Member

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

Comment threadcuda_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

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

/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:mainMay 7, 2026
94 checks passed
github-actionsBot 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
Doc Preview CI
Preview removed because the pull request was closed or merged.

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

Labels

breakingBreaking changes are introducedcuda.coreEverything related to the cuda.core moduleenhancementAny code-related improvementsP0High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA]: Make Linker.backend a classmethod

5 participants

@cpcloud@leofang@rwgk@rparolin@Andy-Jost