Skip to content

test(cuda.core): run test_unsupported_fabric_construction with a faked attribute - #3652

Merged
mdboom merged 1 commit into
NVIDIA:mainfrom
mdboom:issue3574
Nov 30, 2026
Merged

mdboom merged 1 commit into
NVIDIA:mainfrom
mdboom:issue3574

Conversation

@mdboom

@mdboom mdboom commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Closes #3574. Part of #2077.

Summary

test_unsupported_fabric_construction needed a Linux device with VMM support but without fabric handle support. Every CI GPU supports fabric handles, so the test skipped everywhere with "No visible VMM device without fabric handle support".

A private test hook seeds the attribute cache that DeviceProperties already keeps:

def _set_device_attribute_for_testing(device: Device | int, attribute, value: int | None) -> None:
    cdef DeviceProperties props = Device(device).properties
    if value is None:
        props._cache.pop(attribute, None)   # next read queries the driver
    else:
        props._cache[attribute] = value
 def test_unsupported_fabric_construction(init_cuda):
-    unsupported = [d for d in Device.get_all_devices() if VMM and not fabric]
-    if not unsupported: pytest.skip(...)
+    device = Device()
+    _set_device_attribute_for_testing(device, HANDLE_TYPE_FABRIC_SUPPORTED, 0)
+    try:
+        with pytest.raises(RuntimeError) as info:
+            _resource(device)
+    finally:
+        _set_device_attribute_for_testing(device, HANDLE_TYPE_FABRIC_SUPPORTED, None)
     assert "NVLink fabric" in message ...
  • Only the attribute value is faked. The VirtualMemoryResource constructor reads device.properties.handle_type_fabric_supported as usual, and its real check and error message run.
  • The normal attribute path is unchanged, so the hook costs nothing outside tests.
  • Device objects are per thread, so the override is visible only to the calling thread. The test is therefore safe in the free-threaded pytest-run-parallel rows without a thread_unsafe marker.
  • The "not currently run in any CI job" comment is removed.

Evidence

CI coverage: on main the test skips in all 65 cuda.core configurations: 43 Linux rows skip because no device lacks fabric support, and 22 Windows/WSL rows skip because fabric IPC requires Linux. After this change it should run in the 42 Linux rows that test this branch's sources (the remaining Linux row runs the released cuda-core's tests). The Windows/WSL skip is intended and unchanged.

Locally (cuda.core built from this branch): the test passes, as do test_vmm_fabric.py and test_device.py (185 passed, 17 skipped). A direct check confirmed that faking 0 and 1 both change the property, that another thread's Device still sees the driver's value, and that None restores it.

Confirming in CI: in this PR's CI run, the Linux cuda.core jobs should report the test PASSED, where main reports it SKIPPED. For example:

gh run view <CI run id> --repo NVIDIA/cuda-python --log | grep -F "test_unsupported_fabric_construction"

Merge Danger

Door: two-way.

Blast Radius: small. The library change is one private module-level function in cuda.core._device that only tests call.

Reviewers: please feel free to push commits directly to this PR to improve it.

🤖 Generated with Claude Code

…d attribute

test_unsupported_fabric_construction needed a Linux device with VMM but
without fabric handle support. Every CI GPU supports fabric handles, so it
never ran.

Add a private _set_device_attribute_for_testing hook that seeds the
attribute cache DeviceProperties already keeps (None clears the entry, so
the next read queries the driver). The normal attribute path is unchanged.
Devices are per thread, so the override is visible only to the calling
thread. The test fakes no fabric support on the current device, checks the
constructor's error, and restores the cache.

Remove the "not currently run in any CI job" comment.

Closes NVIDIA#3574.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mdboom mdboom added this to the cuda.core 1.4.0 milestone Nov 30, 2026
@mdboom mdboom added test Improvements or additions to tests cuda.core Everything related to the cuda.core module labels Nov 30, 2026
@mdboom mdboom self-assigned this Nov 30, 2026
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Summary

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for handling unsupported fabric configurations, including environments where virtual memory management is unavailable.
    • The check now runs in continuous integration and verifies the expected error without depending on which devices are present.

The change adds a private helper to override a cached device attribute for the calling thread. The unsupported-fabric test uses the helper to check the resource construction error on a selected device.

Changes: Unsupported fabric construction test

Layer / File(s) Summary
Device attribute cache override
cuda_core/cuda/core/_device.pyi, cuda_core/cuda/core/_device.pyx
The stub and implementation add _set_device_attribute_for_testing, which sets an attribute value in the calling thread’s device-properties cache or removes it when given None.
Unsupported fabric test
cuda_core/tests/memory_ipc/test_vmm_fabric.py
The test sets a device’s fabric-support attribute to unsupported, checks that resource construction raises the expected error, and restores the attribute. It no longer searches for a device without fabric support.

Assessment against linked issues

Objective Addressed Explanation
Allow the unsupported-fabric test to exercise the constructor’s error path without requiring a device that lacks fabric support [3574] ✅

Possibly related issues

Suggested reviewers: andy-jost, juenglin

Change: Other

Merge Risk: Minimal · up to d33f5

This change adds a private test hook so the unsupported-fabric construction test can run deterministically. It does not alter production runtime behavior. The remaining step is confirming in CI logs that the test runs on the Linux rows.

Security architecture risk: Low · up to d33f5

The test now exercises the real fabric-support check without special hardware. The new helper can affect another thread if both threads use the same Device object. The added test does not share its Device, and the helper does not grant access to GPU memory.

Retained concerns

  • Trivial · reliability · inferred: The new hook writes to the supplied Device object's cache, not necessarily to the caller's thread-local Device. If an instance is shared, another thread reading that instance can see the override and make a different capability decision. The added test does not share its instance.

View findings in the submitted review

Security review details

Trust Boundaries and Controls

  • observed — The hook changes the input to the library's capability precheck; it does not set CUDA driver state or authorize fabric handle export. Export still calls the CUDA driver and checks its result.

Hardening Proposals

  • proposed — Accept only a device ordinal in the helper and resolve it in the calling thread, so a Device object shared across threads cannot redirect the cache write.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — The new hook writes to the supplied Device object's cache, not necessarily to the caller's thread-local Device. If an instance is shared, another thread reading that instance can see the override and make a different capability decision. The added test does not share its instance.
Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1c9ed66 and d33f51c.

Files selected for processing: 3

  • cuda_core/cuda/core/_device.pyi
  • cuda_core/cuda/core/_device.pyx
  • cuda_core/tests/memory_ipc/test_vmm_fabric.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

@jpascucci-nv jpascucci-nv 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.

Sol 6.1 high says no actionable findings, lgtm.

@mdboom
mdboom merged commit fb1fc2a into NVIDIA:main Nov 30, 2026
227 of 229 checks passed
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 test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(cuda.core): add a test hook so test_unsupported_fabric_construction runs

2 participants