Skip to content

test(cuda.core): fake no fabric support without a production test hook - #3667

Open
mdboom wants to merge 1 commit into
NVIDIA:mainfrom
mdboom:issue3574-nohook
Open

mdboom wants to merge 1 commit into
NVIDIA:mainfrom
mdboom:issue3574-nohook

Conversation

@mdboom

@mdboom mdboom commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #3652 (#3574). Part of #2077.

Summary

#3652 made test_unsupported_fabric_construction run by adding a test-only function, _set_device_attribute_for_testing, to the production module cuda.core._device. #3555 adds an AGENTS.md rule against test hooks in production code, so this removes the hook and fakes the property from the test instead:

 cuda_core/cuda/core/_device.pyx
-def _set_device_attribute_for_testing(device, attribute, value): ...   # seeded DeviceProperties._cache

 cuda_core/tests/memory_ipc/test_vmm_fabric.py
+class _PropertiesWithoutFabricSupport:      # reports handle_type_fabric_supported = False,
+    ...                                     # delegates everything else to the real properties
 def test_unsupported_fabric_construction(init_cuda, monkeypatch):
-    _set_device_attribute_for_testing(device, FABRIC_SUPPORTED, 0)
+    monkeypatch.setattr(Device, "properties", property(lambda self: _PropertiesWithoutFabricSupport(...)))
     with pytest.raises(RuntimeError) as info:
         _resource(device)                     # the real constructor check and error
  • Device is a Python class and properties an ordinary property, so the patch needs no production support; monkeypatch restores it.
  • The patch affects every thread, so the test is marked thread_unsafe.

Evidence

Locally (cuda.core built from this branch, hook absent):

  • test_unsupported_fabric_construction and test_device.py pass (184 passed).
  • Flipping the proxy to report fabric support lets VirtualMemoryResource(..., handle_type="fabric") pass the check, so the patch really drives it.

CI coverage is unchanged from #3652: the test should pass on the Linux rows (it skips on Windows/WSL, where fabric IPC needs Linux).

Confirming in CI:

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

Merge Danger

Door: two-way.

Blast Radius: removes the private cuda.core._device._set_device_attribute_for_testing (added in #3652, used only by this test) and changes one test.

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

🤖 Generated with Claude Code

test_unsupported_fabric_construction used _set_device_attribute_for_testing,
a test-only function in cuda.core._device. Monkeypatch Device.properties
with a proxy that reports no fabric handle support instead, and remove the
hook. The constructor's real check and error still run.

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 →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated coverage for systems that do not support fabric memory, including platform-specific handling. Unsupported configurations are now verified to raise an error during resource construction.
    • Removed test reliance on a private device-property modification helper.

The private device-attribute testing helper was removed. The unsupported-fabric construction test now uses a properties proxy and checks for a RuntimeError.

Changes: Fabric support construction test

Layer / File(s) Summary
Replace the fabric test hook
cuda_core/cuda/core/_device.pyi, cuda_core/cuda/core/_device.pyx, cuda_core/tests/memory_ipc/test_vmm_fabric.py
The private helper and its stub declaration were removed. The test uses a proxy that reports fabric support as false, then verifies resource construction raises RuntimeError. The test also skips on Windows and WSL and is marked thread-unsafe.

Possibly related issues

  • Issue 3574: The test now uses a test-side Device.properties proxy instead of the removed production helper. This addresses the issue’s request for a test hook; whether the test runs in CI is not established by these changes.

Suggested reviewers: andy-jost

Change: Other

Merge Risk: Minimal · up to 0c5de

This is a test-only cleanup that removes a private hook and keeps the unsupported-fabric constructor check covered. No production behavior changes, so merge risk is minimal.

Security architecture risk: Minimal · up to 0c5de

The test still exercises the real fabric capability check. Only the test simulates an unsupported device; applications keep the same behavior and no longer carry the private test hook.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9519c65 and 0c5dea9.

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
Files with no reviewable changes: 1

  • cuda_core/cuda/core/_device.pyx

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

@mdboom
mdboom requested a review from Andy-Jost November 30, 2026 22:00

This branch has not been deployed

No deployments
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.

1 participant