Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 36 additions & 25 deletions cuda_core/tests/graph/test_graph_node_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,32 +584,46 @@ def assert_exec_uses(graph, expected):
)


@pytest.fixture(
params=[
pytest.param(_event_record_case, id="event-record"),
pytest.param(_event_wait_case, id="event-wait"),
pytest.param(_host_callback_case, id="host-callback-python"),
pytest.param(_host_callback_ctypes_case, id="host-callback-ctypes"),
pytest.param(_memset_value_case, id="memset-value"),
pytest.param(_memset_destination_case, id="memset-destination"),
pytest.param(_memcpy_size_case, id="memcpy-size"),
pytest.param(_memcpy_source_case, id="memcpy-source"),
pytest.param(_memcpy_destination_case, id="memcpy-destination"),
pytest.param(_kernel_config_case, id="kernel-config"),
pytest.param(_kernel_args_case, id="kernel-args"),
pytest.param(_kernel_function_case, id="kernel-function"),
pytest.param(_child_graph_case, id="child-graph"),
]
)
def definition_update_case(request, init_cuda):
_DEFINITION_UPDATE_CASES = [
pytest.param(_event_record_case, id="event-record"),
pytest.param(_event_wait_case, id="event-wait"),
pytest.param(_host_callback_case, id="host-callback-python"),
pytest.param(_host_callback_ctypes_case, id="host-callback-ctypes"),
pytest.param(_memset_value_case, id="memset-value"),
pytest.param(_memset_destination_case, id="memset-destination"),
pytest.param(_memcpy_size_case, id="memcpy-size"),
pytest.param(_memcpy_source_case, id="memcpy-source"),
pytest.param(_memcpy_destination_case, id="memcpy-destination"),
pytest.param(_kernel_config_case, id="kernel-config"),
pytest.param(_kernel_args_case, id="kernel-args"),
pytest.param(_kernel_function_case, id="kernel-function"),
pytest.param(_child_graph_case, id="child-graph"),
]


def _definition_update_case_factory(factory):
if driver_version() < (12, 2, 0):
pytest.skip("individual graph node updates require CUDA 12.2+")
factory = request.param
# pytest-run-parallel shares this fixture object across workers. Build the
# case at call time on Device() so each worker gets its own graph/node.
return lambda: factory(Device())


@pytest.fixture(params=_DEFINITION_UPDATE_CASES)
def definition_update_case(request, init_cuda):
return _definition_update_case_factory(request.param)


@pytest.fixture(params=[param for param in _DEFINITION_UPDATE_CASES if param.id != "host-callback-ctypes"])
def definition_update_case_with_typed_argument(request, init_cuda):
"""Like ``definition_update_case``, for cases whose update takes a typed argument.

A ctypes host callback's ``update`` takes any callable; its prototype check is
covered by ``test_host_callback_ctypes_update_rejects_incompatible_signature``.
"""
return _definition_update_case_factory(request.param)


@pytest.mark.agent_authored(model="gpt-5.6")
def test_memcpy_update_rejects_unsupported_descriptor(init_cuda):
if driver_version() < (12, 2, 0):
Expand Down Expand Up @@ -993,15 +1007,12 @@ def test_failed_definition_node_update_preserves_state(
case.assert_exec_uses(graph, case.original)


# For the host-callback-ctypes parameter case:
# This test is not currently run in any CI job
@pytest.mark.agent_authored(model="gpt-5.6")
def test_definition_node_update_rejects_wrong_type(
definition_update_case,
definition_update_case_with_typed_argument,
):
case = definition_update_case()
if case.invalid_argument_update is None:
pytest.skip("update method has no typed positional argument")
case = definition_update_case_with_typed_argument()
assert case.invalid_argument_update is not None
with pytest.raises(TypeError):
case.invalid_argument_update()

Expand Down
Loading