Skip to content

[CUDA] Fix sanity check PTU compile fail and re-enable unittests - #1161

Merged
aaronj0 merged 3 commits into
compiler-research:mainfrom
aaronj0:cudatest-host-launcher
Oct 31, 2026
Merged

aaronj0 merged 3 commits into
compiler-research:mainfrom
aaronj0:cudatest-host-launcher

Conversation

@aaronj0

@aaronj0 aaronj0 commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

The sanity check currently always fails because LLVM 22 rejects the launch in
device compilation: the Declare fails skipping all tests as seen on the self-hosted
CUDA job.

On LLVM 21 the input compiles, but the launch runs from the
PTU's static initializer before the module constructor has registered
the device binary and fails with cudaErrorInvalidResourceHandle.
This is due to llvm/llvm-project#158021 which will be fixed by llvm/llvm-project#234643.

We can workaround this by using a launch from a host function defined with the
kernel and called in a later input works on both releases.

Define a host function next to the kernel that launches it and call it
from the next input. Both the simple kernel and CUB tests take the
same shape, since their own top-level launches fail the same way
once the fixture lets them run. Also drops the hardcoded arch and toolkit path

@aaronj0
aaronj0 requested a review from vgvassilev October 25, 2026 18:25
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.80%. Comparing base (b2e4a61) to head (276b239).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1161      +/-   ##
==========================================
+ Coverage   88.70%   88.80%   +0.10%     
==========================================
  Files          24       24              
  Lines        6978     6978              
==========================================
+ Hits         6190     6197       +7     
+ Misses        788      781       -7     

see 1 file with indirect coverage changes
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

DetectCudaInstallAndArch ends by creating an interpreter with
--cuda-path=/usr/local/cuda-12.3 and --offload-arch=sm_70, a toolkit
path that need not exist on the host. createClangInterpreter forwards
an explicit path unchecked, clang finds no installation there and
selects PTX 4.2, and the NVPTX backend of LLVM 22 reports the pair as a
fatal usage error, "PTX version 4.2 does not support target 'sm_70'".
The error aborts the unittest binary. LLVM 21 accepted the pair, and on
LLVM 22 the test was never reached because the fixture failed first.

Create that interpreter from the toolkit and the architecture the test
has just detected, so the explicit arguments are exercised on every
host with a GPU. The probe of the 12.3 path above it already tolerates
an absent directory.
CUDATest::SetUpTestSuite defines test_func and launches it as a
top-level statement of the same input. LLVM 22 rejects the launch in
device compilation with err_cuda_device_kernel_launch_require_rdc, the
Declare fails and all seven tests skip, as they do on the self-hosted
CUDA job. On LLVM 21 the input compiles, but the launch runs from the
PTU's static initializer before the module constructor has registered
the device binary and fails with cudaErrorInvalidResourceHandle, so the
four runtime tests skip. A launch from a host function defined with the
kernel and called in a later input, the shape a client of the
interpreter uses, works on both releases.

Define a host function next to the kernel that launches it and call it
from the next input. SimpleKernelExecution and
CUB_BlockReduceWithDeviceFunction take the same shape, since their own
top-level launches fail the same way once the fixture lets them run.
clang-repl builds the device TargetMachine without the target features,
so the PTX carries the minimum ISA version of the arch, 5.0 for sm_61.
CUB's block reduction uses shfl.sync, which needs 6.0, and the driver
JIT rejects the module with cudaErrorInvalidPtx. Skip the test below
sm_70, where the minimum is 6.0, until clang-repl passes the features.
@aaronj0
aaronj0 force-pushed the cudatest-host-launcher branch from fa8610b to 276b239 Compare October 31, 2026 06:28
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

// CUB's block reduction needs PTX ISA 6.0, first implied by sm_70.
std::string arch;
unsigned sm = 0;
if (compat::detectNVPTXArch(arch) &&

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Here we are skipping this CUB test based on the arch. This is because the GPU on the self hosted nuc runner is pre-volta which reveals the issue solved by llvm/llvm-project#235754. We can enable it with LLVM 24.

@aaronj0

aaronj0 commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

@vgvassilev with this PR we are back to running CUDA tests on the self hosted runner, which has been skipping for a while.

@vgvassilev vgvassilev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@aaronj0
aaronj0 merged commit 88ecf09 into compiler-research:main Oct 31, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants