Skip to content

Use Specific CCCL Includes#1806

Merged
rapids-bot[bot] merged 7 commits intorapidsai:mainfrom
divyegala:unneeded-cccl-includes
Feb 18, 2026
Merged

Use Specific CCCL Includes#1806
rapids-bot[bot] merged 7 commits intorapidsai:mainfrom
divyegala:unneeded-cccl-includes

Conversation

@divyegala
Copy link
Copy Markdown
Member

@divyegala divyegala commented Feb 15, 2026

This is needed downstream because cub injects an EmptyKernel symbol into every TU that includes either cub/cub.cuh or cub/device/* includes, and this causes an issue for cubins created using JIT-LTO.

This PR also fixes 2 bugs in JIT kernels:

  1. Filters out cub::EmptyKernel from JIT TUs specifically because they only expect 1 kernel but are finding 2 instead
  2. Keeps a reference to cudaLibrary_t that loads the JIT kernel and unloading it at destruction

@divyegala divyegala self-assigned this Feb 15, 2026
@divyegala divyegala requested a review from a team as a code owner February 15, 2026 21:18
@divyegala divyegala added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Feb 15, 2026
Copy link
Copy Markdown
Member

@dantegd dantegd left a comment

Choose a reason for hiding this comment

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

Just a couple of questions

}

// Only keep the kernel if it's not EmptyKernel
if (!is_empty_kernel) { valid_kernels.push_back(kernels.release()[i]); }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (!is_empty_kernel) { valid_kernels.push_back(kernels.release()[i]); }
if (!is_empty_kernel) { valid_kernels.push_back(kernels[i]); }

In the first iteration (e.g. i == 0) this transfers ownership and sets kernels to nullptr. On the next iteration, kernels.release() returns nullptr, and nullptr[i] is undefined behavior. The unique_ptr can keep owning the array until the function returns; you only need to copy the cudaKernel_t handles into valid_kernels, no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, probably why the tests are failing.

AlgorithmLauncher::AlgorithmLauncher(cudaKernel_t k) : kernel{k} {}
AlgorithmLauncher::AlgorithmLauncher(cudaKernel_t k, cudaLibrary_t lib) : kernel{k}, library{lib} {}

AlgorithmLauncher::~AlgorithmLauncher() { RAFT_CUDA_TRY(cudaLibraryUnload(library)); }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
AlgorithmLauncher::~AlgorithmLauncher() { RAFT_CUDA_TRY(cudaLibraryUnload(library)); }
AlgorithmLauncher::~AlgorithmLauncher() {
if (library != nullptr) {
(void)cudaLibraryUnload(library); // ignore errors in destructor
}
}

This might be one of those places where I'm rusty about C++ destructors, isn't throwing from destructors during stack unwinding undefined behavior?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ugh yeah. I'm surprised the compiler did not complain.

@divyegala divyegala requested a review from dantegd February 17, 2026 23:39
@divyegala
Copy link
Copy Markdown
Member Author

/merge

@rapids-bot rapids-bot Bot merged commit c18ccfa into rapidsai:main Feb 18, 2026
148 of 151 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants