Skip to content

Make Linker.backend a classmethod#1910

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

Make Linker.backend a classmethod#1910
cpcloud wants to merge 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
Copy link
Copy Markdown

cpcloud and others added 5 commits April 14, 2026 18:15
Make `Linker.backend` callable without instantiation, allowing
downstream libraries (e.g., numba-cuda) to query which linking
backend will be used before constructing a Linker.

The classmethod calls `_decide_nvjitlink_or_driver()` and maps
its return value to "nvJitLink" or "driver". Existing call sites
updated to use parens (`linker.backend()` instead of
`linker.backend`).

Breaking change: attribute-style access `linker.backend` now
returns a bound method, not a string. Only two in-repo call sites
affected; both updated.

Refs NVIDIA#714

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests monkeypatch module-level flags in cuda.core._linker to verify
the classmethod without requiring a GPU. Covers nvJitLink path,
driver path, probe invocation when not memoised, classmethod
descriptor check, and idempotency.

Refs NVIDIA#714

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Explicit guard that the intentional property-to-classmethod break
is preserved. Documents the breaking change in the test itself.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the breaking change from property to classmethod. Also
remove unused pytest import from test_linker_backend.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cpcloud cpcloud force-pushed the linker-backend-classmethod-714 branch from ecc449b to dbe6176 Compare April 14, 2026 22:15
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

1 participant