Skip to content

Build cuda.core RDC test fixtures without Bash#2335

Open
rwgk wants to merge 3 commits into
NVIDIA:mainfrom
rwgk:run_nvcc_without_bash
Open

Build cuda.core RDC test fixtures without Bash#2335
rwgk wants to merge 3 commits into
NVIDIA:mainfrom
rwgk:run_nvcc_without_bash

Conversation

@rwgk

@rwgk rwgk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This changes the cuda.core RDC test fixture build from a Bash script to a small Python driver around nvcc.

Why this change:

  • The tests still require nvcc, but they no longer require Bash. That avoids Windows-specific ambiguity between Git Bash, WSL Bash, path conversion behavior, and environment propagation.
  • The fixture builder now calls nvcc directly from Python with subprocess, using the platform's normal PATH lookup.
  • The pathfinder lookup is removed intentionally. For the environments we care about, requiring nvcc to be on PATH is straightforward, matches normal CUDA command-line expectations, and avoids passing a full nvcc path through another shell layer.
  • If local fixture files are absent, tests now distinguish between nvcc being unavailable, the host compiler environment being unavailable, and other nvcc failures. Only the first two become skips; unexpected nvcc failures still fail the test.

Suggested review path:

  1. Review cuda_core/tests/test_binaries/build_test_binaries.py first. It is the Python replacement for the deleted Bash script.
  2. Review _build_saxpy_rdc() in cuda_core/tests/test_module.py next. That is where the local fallback behavior and skip/fail policy lives.
  3. Review the small CI workflow change last; it now runs nvcc --version to aid troubleshooting and then the Python fixture builder.

@rwgk rwgk added this to the cuda.core next milestone Jul 9, 2026
@rwgk rwgk added test Improvements or additions to tests cuda.core Everything related to the cuda.core module labels Jul 9, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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

Contributors can view more details about this message here.

@github-actions github-actions Bot added the CI/CD CI/CD infrastructure label Jul 9, 2026
@rwgk rwgk self-assigned this Jul 9, 2026
@rwgk rwgk added the P0 High priority - Must do! label Jul 9, 2026
@rwgk rwgk marked this pull request as ready for review July 9, 2026 22:09
@rwgk rwgk requested a review from lijinf2 July 9, 2026 22:09
@rwgk

rwgk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

return rdc_path.read_bytes()


def _subprocess_output(result: subprocess.CompletedProcess[str]) -> str:

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.

Could we delete this function _subprocess_output and just default to system stdout/stderr behaviors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to keep this helper. We intentionally capture stdout/stderr here because we need to inspect the nvcc output to distinguish known host-compiler setup failures from unexpected nvcc failures.

For unexpected failures, pytest.fail(...) includes the captured stdout/stderr in one self-contained failure message. That makes the CI/test log easier to interpret, especially when pytest output capture or parallel test output would otherwise split the context.

On success we still print the captured output back to stdout/stderr, so the normal diagnostic trail is preserved.

# Keep these patterns narrow. Unknown nvcc failures should fail the test and
# expose their diagnostics, not be silently reclassified as environment skips.
windows_compiler_missing = (
"cannot find compiler" in normalized and "cl.exe" in normalized and "in path" in normalized

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.

Is "cannot find compiler" keyword stable enough and will not be modified in future release of nvcc logging?

I got the following from agent and it works on linux but not sure on windows.

    for line in p.stdout.splitlines():
        if line.startswith("#$"):
            cmd = line[3:].strip().split()
            if cmd:
                return cmd[0]  # gcc / g++ / clang++ / cl.exe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. I do not want to rely on this message being stable forever. The intent is almost the opposite: keep the recognized skip cases narrow.

If nvcc changes this diagnostic in a future release, this helper will stop recognizing it as a known environment setup issue. The test will then fail and include the full nvcc output, which gives us the evidence needed to decide whether to add another narrowly scoped skip pattern.

The #$ ... parsing approach can identify commands emitted by nvcc -v/dry-run style output, but it does not directly answer the question we need here: did the actual fixture build fail because the host compiler environment is missing, or did it fail for some other reason? For this test, it is safer to classify only the exact known failure modes after the real build attempt, and let everything else fail visibly.

# expose their diagnostics, not be silently reclassified as environment skips.
windows_compiler_missing = (
"cannot find compiler" in normalized and "cl.exe" in normalized and "in path" in normalized
)

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.

On windows is "cl.exe" the only host compiler available? What if nvcc is using another host compiler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For the path this PR exercises, yes, the Windows host compiler we expect is MSVC cl.exe. The fixture builder invokes bare nvcc and does not pass --compiler-bindir / -ccbin, so it is intentionally using the normal Windows nvcc setup.

If someone has a custom Windows nvcc host-compiler setup and it fails with a different diagnostic, this code will not silently skip it. It will fail the test and expose the actual output. That is intentional: the skip classification is only for the known default Windows setup failure where nvcc reports that it cannot find cl.exe in PATH.

In other words, this PR does intentionally not try to generalize all possible Windows host compiler configurations. It makes the supported test contract (see ctk-next PR 436)explicit: nvcc on PATH, with the normal host compiler environment already configured.


_run(
[
"nvcc",

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.

Your previous PR uses NVCC environmental variable and pathfinder instead of bare nvcc command. Do we consider that here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this was considered. Now that the builder is Python instead of Bash, a full nvcc.exe path would be much less problematic than it was in the earlier Bash-based version.

I still prefer bare nvcc here because it keeps the test contract simple and explicit: the test environment should put the intended CUDA toolkit's bin directory on PATH, and the host compiler environment should already be configured. That is easy to satisfy in CI, runbooks, and local development.

Using pathfinder or an NVCC override inside this unit test would add a second toolkit-selection mechanism. That can create mismatches where the test discovers one nvcc, while CUDA_PATH, PATH, runtime libraries, or the surrounding runbook point at another toolkit. For this fixture build, relying on the environment's normal executable lookup is simpler and easier to reason about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD CI/CD infrastructure cuda.core Everything related to the cuda.core module P0 High priority - Must do! test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants