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 the managed-memory concurrent-access warning tests - #3651
test_warning_emitted and test_warning_emitted_only_once needed a GPU that supports managed memory pools but lacks concurrent managed access. No CI platform has that combination, so both tests skipped everywhere.
The once-per-process warning check now reads the attribute through the existing public property instead of calling the driver itself, and the tests fake that property, with no test hook in production code:
cdef inline _check_concurrent_managed_access():
if _concurrent_access_warned: return # every call after the first returns here
with _concurrent_access_lock:
...
- cuDeviceGetAttribute(&c_concurrent, CONCURRENT_MANAGED_ACCESS, 0)- if not c_concurrent:+ if not Device(0).properties.concurrent_managed_access:
warnings.warn(...)
_concurrent_access_warned = True
tests/test_managed_memory_warning.py
+class _PropertiesWithoutConcurrentManagedAccess: # reports concurrent_managed_access = False,+ ... # delegates everything else to the real properties
@pytest.fixture
def faked_no_concurrent_managed_access(init_cuda, monkeypatch):
+ monkeypatch.setattr(Device, "properties", property(lambda self: _PropertiesWithoutConcurrentManagedAccess(...)))
reset_concurrent_access_warning()
Only the property value is faked. Creating the resource, the warning text and category, and the once-per-process lock all run for real.
The check still queries device 0 (the attribute is system-wide on sm_60+) and still runs once per process, so resource creation after the first pays nothing extra.
Device is a Python class and properties an ordinary property, so the patch needs no production support; monkeypatch restores it. The two tests are marked thread_unsafe because the patch and the warning flag are process-wide.
test_default_pool_error_without_concurrent_access still needs real hardware, because it tests the driver's own behavior.
The "not currently run in any CI job" markers are removed.
Evidence
CI coverage: the two tests should now run in the 31 CI configurations where the existing ManagedMemoryResource tests (for example test_mempool_attributes[ManagedMemoryResource-...]) pass on main. Those are every Linux CUDA 13 row, CTK 13.0.2 and 13.5.0 on x86-64 and aarch64, on T4, L4, A100, H100, GB300, GH200, RTX PRO 6000 and the 2-GPU rows. Windows and CUDA 12 rows skip, as the other managed-memory tests do.
Locally (cuda.core built from this branch): both warning tests pass. The local GPU does support concurrent managed access, so the warning fires only because the property is patched. The managed-memory tests in test_memory.py pass (41 passed, 8 skipped).
Confirming in CI: in this PR's CI run, the Linux CUDA 13 cuda.core jobs should report both tests PASSED, where main reports them SKIPPED. For example:
gh run view <CI run id> --repo NVIDIA/cuda-python --log | grep -E "test_managed_memory_warning.py::test_warning_emitted"
Merge Danger
Door: two-way.
Blast Radius: small. The production change replaces one direct cuDeviceGetAttribute call with the cached Device(0).properties.concurrent_managed_access lookup, in a check that runs once per process; the warning behavior is unchanged.
Reviewers: please feel free to push commits directly to this PR to improve it.
test_warning_emitted and test_warning_emitted_only_once needed a GPU that
supports managed memory pools but lacks concurrent managed access. No CI
platform has that combination, so they never ran.
Add a private _set_concurrent_managed_access_for_testing hook that
overrides the CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS value the
warning check sees (a cdef int, so the check stays a direct C call). Only
the attribute value is faked: resource creation, the warning and its
once-per-process lock run for real. A new fixture sets the override and
resets the warning flag, and restores both afterwards.
test_default_pool_error_without_concurrent_access still needs real hardware,
since it tests the driver's own behavior.
Remove the "not currently run in any CI job" markers.
ClosesNVIDIA#3573.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The managed-memory warning now reflects the device’s reported concurrent-access support. When that support is unavailable, the warning continues to appear only once.
Tests
Warning behavior is tested across simulated device capability states. Tests that require memory-pool support skip devices that do not provide it.
The concurrent-managed-access warning check now reads Device(0).properties.concurrent_managed_access. Both warning tests patch that property to simulate a device without concurrent managed access and reset warning state around each test.
Changes: Managed-access warning tests
Layer / File(s)
Summary
Property check and warning tests cuda_core/cuda/core/_memory/_managed_memory_resource.pyx, cuda_core/tests/test_managed_memory_warning.py
The check reads concurrent managed access from Device.properties. The tests patch the property, reset warning state, and test warning emission and once-only behavior. The tests skip devices without memory-pool support and are marked thread-unsafe.
Assessment against linked issues
Objective
Addressed
Explanation
Allow both warning tests to simulate a device without concurrent managed access while retaining real resource creation and warning behavior [#3573]
✅
Suggested reviewers:andy-jost, juenglin
Change: Other · Severity of issue fixed: Low
Merge Risk: Minimal · up to 6dba0
This change moves the managed-memory concurrent-access warning check onto Device.properties and lets the warning tests simulate a missing capability. It has no apparent production impact, since the warning condition and once-per-process behavior are unchanged. The risk of merging is minimal.
Security architecture risk: Low · up to 6dba0
The warning still checks the same GPU capability and does not change memory permissions. The new lookup can leave an incomplete device cache on the calling thread if its first initialization fails, so retrying on that thread may not recover.
Retained concerns
Trivial · reliability · inferred: The new warning path can publish an incomplete thread-local Device list. If allocation fails before the first entry is appended, later Device(0) lookups on that thread reuse the empty list instead of rebuilding it, and managed-memory construction can keep failing despite the warning check being eligible to retry. The cache behavior predates the PR; the new exposure is from constructors that previously reached the warning check without initializing that cache.
inferred — The supported recovery issue is confined to the initializing thread's cache. The warning flag is process-wide, but a failed lookup does not mark it complete or prevent another thread with a usable cache from completing the check.
Trust Boundaries and Controls
observed — The production lookup still uses the fixed device ordinal 0 and the same driver capability. It does not select a device from caller input or switch the current CUDA context.
Resilience and Maintainability Implications
observed — The post-pool diagnostic does not change pool ownership. The dedicated-pool handle retains its last-reference deleter; the current-pool path still borrows its handle.
Hardening Proposals
proposed — Build the Device list locally and publish it to thread-local storage only after all entries are initialized, so a failed first attempt leaves the next call free to rebuild it.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
…on test hook
Remove _set_concurrent_managed_access_for_testing and its override global
from _managed_memory_resource. The once-per-process warning check now reads
Device(0).properties.concurrent_managed_access instead of calling
cuDeviceGetAttribute itself, so the tests can monkeypatch Device.properties
with a proxy that reports no concurrent managed access.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
Architecture findings (1)
Advisory architecture findings (1)
Trivial — The new warning path can publish an incomplete thread-local Device list. If allocation fails before the first entry is appended, later Device(0) lookups on that thread reuse the empty list instead of rebuilding it, and managed-memory construction can keep failing despite the warning check being eligible to retry. The cache behavior predates the PR; the new exposure is from constructors that previously reached the warning check without initializing that cache.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 8 remain after this review.
This branch has not been deployed
No deployments
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
1 participant
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 #3573. Part of #2077.
Summary
test_warning_emittedandtest_warning_emitted_only_onceneeded a GPU that supports managed memory pools but lacks concurrent managed access. No CI platform has that combination, so both tests skipped everywhere.The once-per-process warning check now reads the attribute through the existing public property instead of calling the driver itself, and the tests fake that property, with no test hook in production code:
cdef inline _check_concurrent_managed_access(): if _concurrent_access_warned: return # every call after the first returns here with _concurrent_access_lock: ... - cuDeviceGetAttribute(&c_concurrent, CONCURRENT_MANAGED_ACCESS, 0) - if not c_concurrent: + if not Device(0).properties.concurrent_managed_access: warnings.warn(...) _concurrent_access_warned = TrueDeviceis a Python class andpropertiesan ordinaryproperty, so the patch needs no production support;monkeypatchrestores it. The two tests are markedthread_unsafebecause the patch and the warning flag are process-wide.test_default_pool_error_without_concurrent_accessstill needs real hardware, because it tests the driver's own behavior.Evidence
CI coverage: the two tests should now run in the 31 CI configurations where the existing
ManagedMemoryResourcetests (for exampletest_mempool_attributes[ManagedMemoryResource-...]) pass onmain. Those are every Linux CUDA 13 row, CTK 13.0.2 and 13.5.0 on x86-64 and aarch64, on T4, L4, A100, H100, GB300, GH200, RTX PRO 6000 and the 2-GPU rows. Windows and CUDA 12 rows skip, as the other managed-memory tests do.Locally (cuda.core built from this branch): both warning tests pass. The local GPU does support concurrent managed access, so the warning fires only because the property is patched. The managed-memory tests in
test_memory.pypass (41 passed, 8 skipped).Confirming in CI: in this PR's CI run, the Linux CUDA 13 cuda.core jobs should report both tests PASSED, where
mainreports them SKIPPED. For example:Merge Danger
Door: two-way.
Blast Radius: small. The production change replaces one direct
cuDeviceGetAttributecall with the cachedDevice(0).properties.concurrent_managed_accesslookup, in a check that runs once per process; the warning behavior is unchanged.Reviewers: please feel free to push commits directly to this PR to improve it.
🤖 Generated with Claude Code