Rework Linker dispatching for cross-major nvJitLink/driver skew#1911
Open
cpcloud wants to merge 4 commits intoNVIDIA:mainfrom
Open
Rework Linker dispatching for cross-major nvJitLink/driver skew#1911cpcloud wants to merge 4 commits intoNVIDIA:mainfrom
cpcloud wants to merge 4 commits intoNVIDIA:mainfrom
Conversation
|
Replace the module-level "decide once, use everywhere" nvJitLink-vs-driver choice with a per-Linker-instance decision that considers the CUDA driver major version, nvJitLink's availability and major version, the input code types, and whether link-time optimization is requested. The dispatch is factored into a pure helper `_choose_backend()` that is fully unit-testable without a GPU. Its decision matrix: - no nvJitLink, no LTO -> driver - matching majors -> nvJitLink - cross-major, no LTO -> driver (nvJitLink output may not be loadable) - LTO + no nvJitLink -> RuntimeError - LTO + cross-major -> RuntimeError This resolves the cross-major-driver scenario described in NVIDIA#712, where an nvJitLink 12.x may produce a CUBIN the driver 13.x (or vice versa) cannot load. The previous code committed to nvJitLink unconditionally when it was importable. Tests: - `tests/test_linker_dispatch.py` parametrizes the entire matrix against `_choose_backend()` with mocked versions (no GPU, no driver required). - `tests/test_linker.py::TestLinkerDispatch` drives the same decision through the real `Linker` constructor via monkeypatched version probes. - `tests/test_optional_dependency_imports.py` is updated to exercise the new `_probe_nvjitlink()` helper in place of the removed `_decide_nvjitlink_or_driver()`. - `tests/test_program.py` and `tests/test_linker.py` use a small local helper to compute the effective backend for the current environment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
driver_version() was called unconditionally during Linker.__init__, which fails in environments where nvJitLink is installed but the CUDA driver is absent (e.g., build containers). Now catches the exception and sets driver_major=None. When driver_major is unknown and nvJitLink is available, optimistically selects the nvJitLink backend. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Test helpers calling driver_version() at module scope would crash in no-driver environments before test collection. Mirror the production lazy-probe pattern: catch exceptions and pass None. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9064059 to
0ca3034
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Linker-instance dispatch at__init__time_choose_backend()helper for GPU-free unit testingRuntimeErrorfor LTO when backends are incompatibledriver_version()lazily — environments with nvJitLink but no driver (build containers) still work_probe_nvjitlink()cached, warns at most once when nvJitLink is absentBreaking change:
options.link_time_optimization=Truewith nvJitLink absent now raisesRuntimeErrorinstead of silently passingCU_JIT_LTOto the driver (which was not real LTO linking).Decision matrix
Test plan
test_linker_dispatch.py)Closes #712
🤖 Generated with Claude Code