Skip to content

Warn when ManagedMemoryResource is created without concurrent managed access#1618

Merged
Andy-Jost merged 1 commit intoNVIDIA:mainfrom
Andy-Jost:warn-managed-memory-no-concurrent-access
Feb 17, 2026
Merged

Warn when ManagedMemoryResource is created without concurrent managed access#1618
Andy-Jost merged 1 commit intoNVIDIA:mainfrom
Andy-Jost:warn-managed-memory-no-concurrent-access

Conversation

@Andy-Jost
Copy link
Copy Markdown
Contributor

@Andy-Jost Andy-Jost commented Feb 12, 2026

Summary

  • Emit a one-time UserWarning when ManagedMemoryResource is created on a platform where Device.properties.concurrent_managed_access is False. On such platforms, unsynchronized host access to managed memory causes a segfault.
  • Add tests for the warning (skip on platforms with concurrent access; pass on affected platforms like WSL2).
  • Unrelated: Skip test_build_hooks.py when setuptools is unavailable (Python 3.14+).

Closes #1607

Changes

  • cuda/core/_memory/_managed_memory_resource.pyx: Add _check_concurrent_managed_access helper with double-checked locking (warn-once pattern), and reset_concurrent_access_warning() for testing.
  • tests/test_managed_memory_warning.py: New test file verifying the warning fires and only fires once.
  • tests/test_build_hooks.py: Add pytest.importorskip("setuptools").

Test Coverage

  • test_warning_emitted: Verifies the warning content (category, message text).
  • test_warning_emitted_only_once: Verifies warn-once behavior across multiple resource creations.
  • Both tests validated on WSL2 (RTX 3500 Ada, concurrent_managed_access=False).

Made with Cursor

@Andy-Jost Andy-Jost added this to the cuda.core v0.6.0 milestone Feb 12, 2026
@Andy-Jost Andy-Jost added bug Something isn't working cuda.core Everything related to the cuda.core module labels Feb 12, 2026
@Andy-Jost Andy-Jost self-assigned this Feb 12, 2026
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented Feb 12, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Andy-Jost
Copy link
Copy Markdown
Contributor Author

/ok to test f7eeec8

@github-actions

This comment has been minimized.

"allocation is forbidden while any GPU kernel is in flight, even "
"if the kernel does not touch that allocation. Failing to "
"synchronize before host access will cause a segfault. "
"See: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#um-coherency-hd",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, that's a bit more specific

… access

Platforms where Device.properties.concurrent_managed_access is False
silently allow managed memory allocation but segfault on unsynchronized
host access. Emit a one-time UserWarning at construction time so users
get actionable guidance before hitting a crash.

Also skip test_build_hooks.py when setuptools is unavailable (Python 3.14+).

Closes NVIDIA#1607

Co-authored-by: Cursor <cursoragent@cursor.com>
@Andy-Jost Andy-Jost force-pushed the warn-managed-memory-no-concurrent-access branch from f7eeec8 to d8c876f Compare February 13, 2026 20:02
@Andy-Jost
Copy link
Copy Markdown
Contributor Author

/ok to test d8c876f

@Andy-Jost Andy-Jost merged commit 229dbac into NVIDIA:main Feb 17, 2026
167 of 169 checks passed
@Andy-Jost Andy-Jost deleted the warn-managed-memory-no-concurrent-access branch February 17, 2026 16:01
@github-actions
Copy link
Copy Markdown

Doc Preview CI
Preview removed because the pull request was closed or merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when creating ManagedMemoryResource on platforms without concurrent managed access

3 participants