From 55f4997d82267b4ded9798611e6841cb268a1457 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Fri, 15 May 2026 15:07:43 +0800 Subject: [PATCH 1/2] test: skip IPC peer access tests when IPC is unavailable --- cuda_core/tests/conftest.py | 16 +++++++++++++++- cuda_core/tests/memory_ipc/test_peer_access.py | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/cuda_core/tests/conftest.py b/cuda_core/tests/conftest.py index 86c0c0cd7d4..ff4446f3ce4 100644 --- a/cuda_core/tests/conftest.py +++ b/cuda_core/tests/conftest.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 import multiprocessing @@ -286,6 +286,20 @@ def mempool_device_x3(): return _mempool_device_impl(3) +@pytest.fixture +def ipc_mempool_device_x2(mempool_device_x2): + """Fixture that provides two IPC-capable mempool devices, or skips.""" + from helpers import IS_WSL, supports_ipc_mempool + + if not all(device.properties.handle_type_posix_file_descriptor_supported for device in mempool_device_x2): + pytest.skip("Device does not support IPC") + + if IS_WSL or not all(supports_ipc_mempool(device) for device in mempool_device_x2): + pytest.skip("Driver rejects IPC-enabled mempool creation on this platform") + + return mempool_device_x2 + + @pytest.fixture( params=[ pytest.param((DeviceMemoryResource, DeviceMemoryResourceOptions), id="DeviceMR"), diff --git a/cuda_core/tests/memory_ipc/test_peer_access.py b/cuda_core/tests/memory_ipc/test_peer_access.py index 993aa7344ec..0c644c25ed4 100644 --- a/cuda_core/tests/memory_ipc/test_peer_access.py +++ b/cuda_core/tests/memory_ipc/test_peer_access.py @@ -21,8 +21,8 @@ class TestPeerAccessNotPreservedOnImport: """ @pytest.mark.flaky(reruns=2) - def test_main(self, mempool_device_x2): - dev0, dev1 = mempool_device_x2 + def test_main(self, ipc_mempool_device_x2): + dev0, dev1 = ipc_mempool_device_x2 # Parent Process - Create and Configure MR dev1.set_current() @@ -61,8 +61,8 @@ class TestBufferPeerAccessAfterImport: @pytest.mark.flaky(reruns=2) @pytest.mark.parametrize("grant_access_in_parent", [True, False]) - def test_main(self, mempool_device_x2, grant_access_in_parent): - dev0, dev1 = mempool_device_x2 + def test_main(self, ipc_mempool_device_x2, grant_access_in_parent): + dev0, dev1 = ipc_mempool_device_x2 # Parent Process - Create MR and Buffer dev1.set_current() From 73d6797e718f26fe34808081d54ea41ea7d129e7 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 17 May 2026 11:31:15 -0700 Subject: [PATCH 2/2] test: share IPC mempool fixture checks Reuse the same IPC-mempool gating for single- and multi-device fixtures so nvbug 6176793 stays fixed without duplicating skip logic. --- cuda_core/tests/conftest.py | 39 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/cuda_core/tests/conftest.py b/cuda_core/tests/conftest.py index ff4446f3ce4..a9c028b2db0 100644 --- a/cuda_core/tests/conftest.py +++ b/cuda_core/tests/conftest.py @@ -133,6 +133,21 @@ def _device_id_from_resource_options(device, args, kwargs): return 0 +def _require_ipc_mempool_devices(devices): + """Return devices if they all support IPC-enabled mempools, otherwise skip.""" + from helpers import IS_WSL, supports_ipc_mempool + + checked_devices = tuple(devices) + + if not all(device.properties.handle_type_posix_file_descriptor_supported for device in checked_devices): + pytest.skip("Device does not support IPC") + + if IS_WSL or not all(supports_ipc_mempool(device) for device in checked_devices): + pytest.skip("Driver rejects IPC-enabled mempool creation on this platform") + + return devices + + @pytest.fixture(scope="session", autouse=True) def session_setup(): # Always init CUDA. @@ -199,25 +214,13 @@ def pop_all_contexts(): @pytest.fixture def ipc_device(): """Obtains a device suitable for IPC-enabled mempool tests, or skips.""" - # Check if IPC is supported on this platform/device device = Device(0) device.set_current() if not device.properties.memory_pools_supported: pytest.skip("Device does not support mempool operations") - # Note: Linux specific. Once Windows support for IPC is implemented, this - # test should be updated. - if not device.properties.handle_type_posix_file_descriptor_supported: - pytest.skip("Device does not support IPC") - - # Skip on WSL or if driver rejects IPC-enabled mempool creation on this platform/device - from helpers import IS_WSL, supports_ipc_mempool - - if IS_WSL or not supports_ipc_mempool(device): - pytest.skip("Driver rejects IPC-enabled mempool creation on this platform") - - return device + return _require_ipc_mempool_devices((device,))[0] @pytest.fixture( @@ -289,15 +292,7 @@ def mempool_device_x3(): @pytest.fixture def ipc_mempool_device_x2(mempool_device_x2): """Fixture that provides two IPC-capable mempool devices, or skips.""" - from helpers import IS_WSL, supports_ipc_mempool - - if not all(device.properties.handle_type_posix_file_descriptor_supported for device in mempool_device_x2): - pytest.skip("Device does not support IPC") - - if IS_WSL or not all(supports_ipc_mempool(device) for device in mempool_device_x2): - pytest.skip("Driver rejects IPC-enabled mempool creation on this platform") - - return mempool_device_x2 + return _require_ipc_mempool_devices(mempool_device_x2) @pytest.fixture(