You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(cuda.core): run test_unsupported_fabric_construction with a faked attribute - #3652
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:
cdefDevicePropertiesprops=Device(device).propertiesifvalueisNone:
props._cache.pop(attribute, None) # next read queries the driverelse:
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.
…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.
ClosesNVIDIA#3574.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
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.
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
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cuda.coreEverything related to the cuda.core moduletestImprovements or additions to tests
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3574. Part of #2077.
Summary
test_unsupported_fabric_constructionneeded 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
DevicePropertiesalready keeps:VirtualMemoryResourceconstructor readsdevice.properties.handle_type_fabric_supportedas usual, and its real check and error message run.Deviceobjects are per thread, so the override is visible only to the calling thread. The test is therefore safe in the free-threadedpytest-run-parallelrows without athread_unsafemarker.Evidence
CI coverage: on
mainthe 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.pyandtest_device.py(185 passed, 17 skipped). A direct check confirmed that faking0and1both change the property, that another thread'sDevicestill sees the driver's value, and thatNonerestores it.Confirming in CI: in this PR's CI run, the Linux cuda.core jobs should report the test PASSED, where
mainreports it SKIPPED. For example:Merge Danger
Door: two-way.
Blast Radius: small. The library change is one private module-level function in
cuda.core._devicethat only tests call.Reviewers: please feel free to push commits directly to this PR to improve it.
🤖 Generated with Claude Code