Skip to content

tests: skip local NVML runtime mismatches while preserving CI failures#1739

Closed
cpcloud wants to merge 4 commits intoNVIDIA:mainfrom
cpcloud:fix/nvml-local-skip-ci-fail
Closed

tests: skip local NVML runtime mismatches while preserving CI failures#1739
cpcloud wants to merge 4 commits intoNVIDIA:mainfrom
cpcloud:fix/nvml-local-skip-ci-fail

Conversation

@cpcloud
Copy link
Contributor

@cpcloud cpcloud commented Mar 7, 2026

Summary

  • Centralize NVML runtime gating through require_nvml_runtime_or_skip_local fixtures in cuda_bindings and cuda_core tests.
  • Treat NVML init/load failures (including driver/library mismatch and missing NVML shared library) as local skips, but continue to fail in CI by re-raising.
  • Cover the behavior with regression tests and apply fixture-based gating across NVML-dependent test modules/fixtures.
  • Rationale: after a driver upgrade without a reboot (a common local developer state), NVML can report a temporary driver/library mismatch; local runs should skip NVML-dependent tests instead of failing collection, while CI should still fail fast for real infra regressions.

Test plan

  • pixi run --manifest-path cuda_bindings pytest cuda_bindings/tests --override-ini norecursedirs=examples -k "not test_cufile"
  • CI=1 pixi run --manifest-path cuda_bindings pytest cuda_bindings/tests/nvml/test_init.py::test_init_ref_count (expected error on NVML mismatch in CI mode)
  • pixi run --manifest-path cuda_core test (currently blocked in this workspace by unrelated import mismatch: cuda.core._resource_handles does not export expected C function create_culink_handle)
  • CI=1 pixi run --manifest-path cuda_core pytest cuda_core/tests/system/test_system_system.py::test_num_devices (same unrelated import mismatch blocker)

Made with Cursor

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Mar 7, 2026

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.

cpcloud added 3 commits March 7, 2026 11:51
Driver upgrades without a reboot can temporarily leave NVML in a driver/library mismatch state, which is a common local developer scenario. Route NVML-dependent checks through shared fixtures/helpers so local runs skip cleanly while CI still fails fast on real NVML init/load regressions.

Made-with: Cursor
Run repository hooks and keep the NVML fixture changes compliant by applying ruff import ordering and formatting adjustments.

Made-with: Cursor
Apply hook-driven import ordering/spacing updates introduced by rebasing onto upstream/main so pre-commit passes cleanly.

Made-with: Cursor
@cpcloud cpcloud force-pushed the fix/nvml-local-skip-ci-fail branch from 3ae1ece to 4272269 Compare March 7, 2026 16:52
@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 7, 2026

/ok to test

@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Copy link
Contributor

@mdboom mdboom left a comment

Choose a reason for hiding this comment

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

This looks great, in terms of centralizing all of this logic.

However, I'm not sure why some tests unrelated to NVML now have this tagging.

And within system/test_system_system.py, we need to keep most of those tests still running even when NVML is totally missing.



@pytest.mark.parametrize("change_device", [True, False])
@pytest.mark.usefixtures("require_nvml_runtime_or_skip_local")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do the tests here now require a working NVML? These tests predate NVML in cuda_bindings... What's the root cause?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look into why this ends up being required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_num_devices will use NVML if it's available. So, yeah, they're pre-existing tests, but they're hitting other APIs now.

Now that these route through NVML when it's available, they're a place where we need to skip if nvml is available but fails in an expected way.

What's the root cause?

The root cause is that I upgraded the driver without rebooting. Since NVML is a driver library, I can no longer use it without a reboot.

I don't want to reboot to keep working in the repo, especially if I'm working on something unrelated to any of this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification. That makes sense.

However, I'm not sure we want to pave over broken installations like this (though I feel your pain about wanting to continue working with a partially-broken install). The test suite can't know whether things are broken because of local installation issues or changes to the code that have broken things, and this would pave over the latter. I know this would eventually get caught in CI, but I'm not a fan of having local and remote testing behave differently.

Copy link
Member

Choose a reason for hiding this comment

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

@cpcloud there is a way to update driver without rebooting. Just need to unload and load the kernel modules with rmmod and/or modprobe, see, e.g.
https://forums.developer.nvidia.com/t/reset-driver-without-rebooting-on-linux/40625/2
Some of our internal infra use this, for example, to achieve <1 min driver refreshing at node allocation time.


from .conftest import skip_if_nvml_unsupported

pytestmark = skip_if_nvml_unsupported
Copy link
Contributor

Choose a reason for hiding this comment

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

Most of the tests in this file are expected to run, other than test_gpu_driver_version, even without an NVML available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look into why this ends up being required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not required

Remove the module-level pytestmark from test_system_system.py and the
per-test require_nvml_runtime_or_skip_local markers from test_memory.py.
These tests don't inherently need NVML; the NVML-specific tests already
have individual @skip_if_nvml_unsupported decorators.

Made-with: Cursor
@cpcloud cpcloud requested a review from mdboom March 10, 2026 21:14
@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 10, 2026

/ok to test

Copy link
Contributor

@mdboom mdboom left a comment

Choose a reason for hiding this comment

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

I'm kind of wary of this change papering over failures on broken installations. Maybe let's get a second opinion?

@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 11, 2026

Not worth the review effort/delay. By the time anyone else chimes in, everyone will have forgotten why this was done and it'll remain in limbo.

@cpcloud cpcloud closed this Mar 11, 2026
@cpcloud cpcloud deleted the fix/nvml-local-skip-ci-fail branch March 11, 2026 17:41
github-actions bot pushed a commit that referenced this pull request Mar 12, 2026
Removed preview folders for the following PRs:
- PR #1739
@leofang
Copy link
Member

leofang commented Mar 12, 2026

Agreed with Mike. The system needs to be in a sane state. Running nvidia-smi prior to any CUDA program, as in our CI, would cache such issues.

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.

3 participants