Skip to content

TST: Add remaining tests for ObjectCode.from_<library/object>#2136

Open
acosmicflamingo wants to merge 1 commit into
NVIDIA:mainfrom
acosmicflamingo:add-remaining-objectcode-tests
Open

TST: Add remaining tests for ObjectCode.from_<library/object>#2136
acosmicflamingo wants to merge 1 commit into
NVIDIA:mainfrom
acosmicflamingo:add-remaining-objectcode-tests

Conversation

@acosmicflamingo
Copy link
Copy Markdown
Contributor

Resolves #663

Unlike adding tests for ObjectCode.from<ptx/ltoir/cubin/fatbin>, adding tests for ObjectCode.from_<object/library> was not as straightforward since cuda.core.Program module's SUPPORTED_TARGETS list do not include ObjectCodeFormatType.OBJECT or ObjectCodeFormatType.LIBRARY, so doing something like this throws an exception:

@pytest.fixture
def get_saxpy_kernel_object(init_cuda):
    # prepare program
    prog = Program(SAXPY_KERNEL, code_type="c++")
    mod = prog.compile(
        "object",
        name_expressions=("saxpy<float>", "saxpy<double>"),
    )
    return object

Going through different PRs and conversations related to testing for ObjectCode.from_<object/library> led me to the very illuminating discussion here.

Based on the very helpful back-and-forth, I took the approach of generating the library/object files within the test itself (assuming an NVCC is present in the environment, otherwise test will be skipped). Not adding a Makefile would mean we have one less file to worry about maintaining, although it does mean that the kernel is being recompiled over-and-over again when it could just be compiled once, saved, and the test relies on the persisted binaries.

I'm open to refactoring this code, whether it means creating a Makefile, generating the binaries, persisting them in the codebase, and having the tests point to them, or another approach I have not considered.

@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented May 25, 2026

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.core Everything related to the cuda.core module label May 25, 2026
@acosmicflamingo acosmicflamingo force-pushed the add-remaining-objectcode-tests branch from e0465db to 0b4de87 Compare May 25, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA]: Tests for ltoir, fatbin, object, and library constructors

1 participant