|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +"""Backward-compatibility checks for undocumented dict options in MR constructors.""" |
| 5 | + |
| 6 | +import pytest |
| 7 | +from helpers.constants import POOL_SIZE |
| 8 | +from helpers.memory import ( |
| 9 | + create_managed_memory_resource_or_skip, |
| 10 | + create_pinned_memory_resource_or_xfail, |
| 11 | + skip_if_managed_memory_unsupported, |
| 12 | + skip_if_pinned_memory_unsupported, |
| 13 | +) |
| 14 | + |
| 15 | +from cuda.core import Device, DeviceMemoryResource |
| 16 | + |
| 17 | + |
| 18 | +@pytest.mark.agent_authored(model="gpt-5.3-codex") |
| 19 | +def test_device_mr_accepts_dict_keyword(init_cuda): |
| 20 | + device = Device() |
| 21 | + if not device.properties.memory_pools_supported: |
| 22 | + pytest.skip("Device does not support memory pool operations") |
| 23 | + device.set_current() |
| 24 | + mr = DeviceMemoryResource(device, options={"max_size": POOL_SIZE}) |
| 25 | + buf = mr.allocate(64, stream=device.default_stream) |
| 26 | + buf.close(stream=device.default_stream) |
| 27 | + mr.close() |
| 28 | + |
| 29 | + |
| 30 | +@pytest.mark.agent_authored(model="gpt-5.3-codex") |
| 31 | +def test_pinned_mr_accepts_dict_keyword(init_cuda): |
| 32 | + device = Device() |
| 33 | + skip_if_pinned_memory_unsupported(device) |
| 34 | + device.set_current() |
| 35 | + mr = create_pinned_memory_resource_or_xfail(options={"max_size": POOL_SIZE}, xfail_device=device) |
| 36 | + buf = mr.allocate(64, stream=device.default_stream) |
| 37 | + buf.close(stream=device.default_stream) |
| 38 | + mr.close() |
| 39 | + |
| 40 | + |
| 41 | +@pytest.mark.agent_authored(model="gpt-5.3-codex") |
| 42 | +def test_managed_mr_accepts_dict_keyword(init_cuda): |
| 43 | + device = Device() |
| 44 | + skip_if_managed_memory_unsupported(device) |
| 45 | + device.set_current() |
| 46 | + mr = create_managed_memory_resource_or_skip(options={}) |
| 47 | + buf = mr.allocate(64, stream=device.default_stream) |
| 48 | + buf.close(stream=device.default_stream) |
| 49 | + mr.close() |
0 commit comments