Skip to content

Consider the NVRTC major version when deciding whether cubin is available - #2564

Open
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:nvrtc-cubin-version-check
Open

Consider the NVRTC major version when deciding whether cubin is available#2564
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:nvrtc-cubin-version-check

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor
        _, nvrtc_minor = nvrtc.version()
        use_cubin = nvrtc_minor >= 1

nvrtc.version() returns (major, minor) and the major is discarded, so the test is
really "is the minor at least 1". That is wrong for every x.0 release:

nvrtc.version() nvrtc_minor >= 1 correct?
(11, 0) False yes
(11, 1) True yes
(12, 0) False no
(12, 9) True yes
(13, 0) False no

The intent is "NVRTC is new enough to emit cubin" — nvrtcGetCUBIN arrived in CUDA 11.1.
On a 12.0 or 13.0 toolkit the check silently selects
--gpu-architecture=compute_XX + nvrtc.get_ptx() instead of sm_XX +
nvrtc.get_cubin(), so the examples JIT-compile PTX at module-load time rather than using
the cubin they asked for. It is a silent fallback, not a crash — which is why it has gone
unnoticed. Every example here carries a cuda-bindings>13.2.1 PEP-723 header, so a 13.0
toolkit is a realistic configuration.

Both copies of the expression are affected:
cuda/bindings/_example_helpers/common.py:58-59 (used by KernelHelper, i.e. most
examples) and examples/extra/jit_program.py:71-72.

Fix

Compare (major, minor) as a tuple against (11, 1).

In common.py this becomes a named nvrtc_supports_cubin() helper, so the decision table
is unit-testable without an NVRTC install. jit_program.py does not import the example
helpers, so it gets the equivalent inline comparison plus a comment rather than a new
dependency.

I kept the 11.1 threshold exactly as-is — this PR is only about the major being ignored,
not about re-deciding where cubin support starts.

Test

New cuda_bindings/tests/test_kernel_helper.py covers the full table above, plus a case
that pins the exact disagreement between the old and new expressions for (12, 0) and
(13, 0). Pure Python — no NVRTC, no toolkit, no GPU.

ruff check and ruff format --check are clean on all three files.

…able

    _, nvrtc_minor = nvrtc.version()
    use_cubin = nvrtc_minor >= 1

nvrtc.version() returns (major, minor) and the major is discarded, so the
test is really "is the minor at least 1". That is wrong for every x.0
release:

    (11, 0) -> False   correct
    (11, 1) -> True    correct
    (12, 0) -> False   WRONG
    (12, 9) -> True    correct
    (13, 0) -> False   WRONG

The intent is "NVRTC is new enough to emit cubin" (nvrtcGetCUBIN arrived in
CUDA 11.1). On a 12.0 or 13.0 toolkit the check silently selects the
--gpu-architecture=compute_XX + PTX path instead of sm_XX + cubin, so the
examples JIT-compile PTX at load time rather than using the cubin they asked
for. Every example in this repo carries a cuda-bindings>13.2.1 PEP-723
header, so a 13.0 toolkit is a realistic configuration.

Compare (major, minor) as a tuple. In common.py this becomes a named
nvrtc_supports_cubin() helper so the decision table can be unit tested
without an NVRTC install; jit_program.py, which does not import the example
helpers, gets the equivalent inline comparison.

Adds tests/test_kernel_helper.py covering the table above, including a case
that pins the exact disagreement between the old and new expressions.
@copy-pr-bot

copy-pr-bot Bot commented Aug 9, 2026

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.

@github-actions github-actions Bot added the cuda.bindings Everything related to the cuda.bindings module label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant