Skip to content

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Sep 29, 2025

This fully isolates us from llvmlite for regular cuda_bindings unit testing.

llvmlite needs to be installed locally only when the new toolshed/build_static_bitcode_input.py helper script is needed, which is expected to be rare.

See also:

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Sep 29, 2025

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rwgk rwgk requested a review from cpcloud September 29, 2025 17:51
@rwgk
Copy link
Collaborator Author

rwgk commented Sep 29, 2025

Holding off running tests until after reviews.

from cuda.bindings import nvvm


def get_minimal_nvvmir_txt_template():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just check in a JSON file that contains the bitcode? Why do we need the sys.path munging and print-generated dictionary?

Copy link
Collaborator Author

@rwgk rwgk Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would you put the JSON file?

I had on my mind: Avoid creating extra artifacts.
But that's something I could do if you prefer.

Re printing out the generated dictionary: I don't want to over-engineer a helper script that's used only rarely (possibly only every couple years). The main goal is to archive "how it worked last time", so that future maintainers don't have to start from scratch. (Back in February it took me more than a couple hours to figure out the approach.)

"Static bitcode for NVVM IR version "
f"{major}.{debug_major} is not available in this test.\n"
"Maintainers: Please run the helper script to generate it and add the "
"output to the MINIMAL_NVVMIR_BITCODE_STATIC dict:\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow why we can't make llvmlite a required testing dependency and always generate the bitcode and eliminate the static testing fixture altogether.

Then we can avoid a lot of this complexity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mutually exclusive with my JSON file suggestion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow why we can't make llvmlite a required testing dependency and always generate the bitcode and eliminate the static testing fixture altogether.

Ah, that's whole point of this PR: remove llvmlite even as an optional test dependency.

@leofang please correct me if I'm wrong, but I got the impression you were skeptical of the llvmlite dependency all the while.

Originally I wanted to keep things simple and make llvmlite a required dependency.

Before we had the recent llvmlite v0.45 related breakage (see #988 and numba/llvmlite#1297), I had it on my list to simplify the test_nvvm.py code, with llvmlite as a hard dependency.

But after the breakage, and seeing how @rparolin stumbled even over the optional dependency last week (see team chat), I got to think it's more trouble than it's worth to even have it as an optional dependency.

With this PR, the cuda_bindings unit tests will be fully isolated from llvmlite, so we won't stumble that much in the future.

Only every couple years probably someone has to dust off the helper script to add a new entry in test_nvvm.py. Estimated effort: 30-60 minutes, depending on prior background of the person who takes this on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't we still need llvmlite eventually to regenerate the bitcode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but only "offline", in the sense that the routine cuda_bindings unit tests (CI) don't need it.

Based on the few months of related experience that I have:

  • I expect that test_nvvm.py will only break if we're testing new CTK releases.
  • Fixing up test_nvvm.py will be just one of potentially several adjustments we have to make for new CTK versions.
  • Chances of test_nvvm.py breakages due to minor-version CTK releases are probably small. — Every couple of months roughly.
  • Chances of test_nvvm.py breakages due to major-version CTK releases are significant. — Every couple years.

Making llvmlite a required dependency means that we'll be living at the bleeding edge: random breakages at random times (from NVIDIA's viewpoint) that need immediate attention.

With the static bitcode inputs, we'll only need to tend to the test when there are CTK changes (release schedule controlled by NVIDIA).


For completeness: There are other ways to convert the txt version to bitcode. I don't remember exactly, I believe there are llvm commands that could be used instead. What's most suitable might change in the future, but I'm guessing as long as numba-cuda uses llvmlite, it'll be a good choice.

Copy link
Contributor

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really dislike the manual copy paste aspect of this, but it seems like we're content to leave it as is.

@rwgk
Copy link
Collaborator Author

rwgk commented Sep 29, 2025

/ok to test

@github-actions

This comment has been minimized.

@rwgk
Copy link
Collaborator Author

rwgk commented Sep 30, 2025

Thanks @cpcloud!

@rwgk rwgk merged commit 5383cb5 into NVIDIA:main Sep 30, 2025
136 of 137 checks passed
@rwgk rwgk deleted the use_llvmlite_in_toolshed_only branch September 30, 2025 00:31
@github-actions
Copy link

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

@rwgk rwgk self-assigned this Sep 30, 2025
@rwgk rwgk added cuda.bindings Everything related to the cuda.bindings module to-be-backported Trigger the bot to raise a backport PR upon merge labels Sep 30, 2025
github-actions bot pushed a commit that referenced this pull request Sep 30, 2025
* Remove bitcode_dynamic code from test_nvvm.py

* New toolshed/build_static_bitcode_input.py

* Import test_nvvm to get access to MINIMAL_NVVMIR_TXT (to avoid duplicating it).

* Rename MINIMAL_NVVMIR_TXT → MINIMAL_NVVMIR_TXT_TEMPLATE for clarity.

* Minor simplifications of helper script.

(cherry picked from commit 5383cb5)
@github-actions
Copy link

Successfully created backport PR for 12.9.x:

@leofang leofang added P1 Medium priority - Should do test Improvements or additions to tests labels Sep 30, 2025
rwgk added a commit that referenced this pull request Oct 1, 2025
…) (#1053)

* Remove bitcode_dynamic code from test_nvvm.py

* New toolshed/build_static_bitcode_input.py

* Import test_nvvm to get access to MINIMAL_NVVMIR_TXT (to avoid duplicating it).

* Rename MINIMAL_NVVMIR_TXT → MINIMAL_NVVMIR_TXT_TEMPLATE for clarity.

* Minor simplifications of helper script.

(cherry picked from commit 5383cb5)

Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
@cpcloud cpcloud mentioned this pull request Oct 8, 2025
@leofang leofang added this to the cuda-python 13.0.2 & 12.9.3 milestone Oct 9, 2025
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 P1 Medium priority - Should do test Improvements or additions to tests to-be-backported Trigger the bot to raise a backport PR upon merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants