Skip to content

Commit d63861c

Browse files
Andy-Jostclaude
andcommitted
test(cuda.core): instantiate before changing the captured node
The executable node update ran against a graph instantiated after the definition node already pointed at host memory, so it restated the operand and tested nothing. Both instantiations now precede the change. Pool-backed operands require CUDA_ERROR_INVALID_VALUE from the node update, the code cuGraphExecMemcpyNodeSetParams reports for the same memory-class rejection. cuMemAlloc operands check the code when the driver rejects. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 0b312e9 commit d63861c

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

‎cuda_core/tests/graph/test_graph_node_update.py‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,10 @@ def test_memcpy_update_captured_node_host_operand(init_cuda, kind):
891891
"""Replacing a captured node's device operand with host memory.
892892
893893
The definition node accepts the host buffer and a fresh instantiation
894-
copies from it. Whether an executable update accepts the replacement
895-
depends on how the operands were allocated. The driver compares the
894+
copies from it. Two instantiations made before the change take the
895+
whole-graph update and the executable node update. Whether an
896+
executable update accepts the replacement depends on how the operands
897+
were allocated. The driver compares the
896898
memory class of pool-backed and virtual-memory operands and rejects the
897899
change for them, so the pool-backed case expects the rejection. Plain
898900
``cuMemAlloc`` operands skip that comparison and the driver may accept
@@ -913,7 +915,10 @@ def test_memcpy_update_captured_node_host_operand(init_cuda, kind):
913915
stream = init_cuda.create_stream()
914916
# The builder is unused; it keeps the captured graph alive.
915917
builder, graph_def, node, dst, src = _capture_device_memcpy(init_cuda, stream, mr=mr)
918+
# Both still copy from the device buffer; the node-level update below
919+
# must change the operand, not restate it.
916920
instantiated_before = graph_def.instantiate()
921+
other = graph_def.instantiate()
917922
host_src = LegacyPinnedMemoryResource().allocate(64)
918923
ctypes.memset(int(host_src.handle), 0xA5, 64)
919924

@@ -937,22 +942,24 @@ def _cuda_error_from(call):
937942
return exc
938943
return None
939944

945+
# cuGraphExecMemcpyNodeSetParams has no update-result output, so the
946+
# driver reports the same rejection as CUDA_ERROR_INVALID_VALUE there.
940947
if kind == "pool":
941948
with pytest.raises(CUDAError, match="PARAMETERS_CHANGED"):
942949
instantiated_before.update(graph_def)
950+
with pytest.raises(CUDAError, match="CUDA_ERROR_INVALID_VALUE"):
951+
other[node].update(dst=dst, src=host_src, size=64)
943952
else:
944953
rejected = _cuda_error_from(lambda: instantiated_before.update(graph_def))
945954
if rejected is None:
946955
_launch_copies_host_source(instantiated_before)
947956
else:
948957
assert "PARAMETERS_CHANGED" in str(rejected)
949-
950-
# The executable-view update varies by driver for both kinds: the CI
951-
# drivers accept it, others reject it. Either outcome is allowed.
952-
other = graph_def.instantiate()
953-
rejected = _cuda_error_from(lambda: other[node].update(dst=dst, src=host_src, size=64))
954-
if rejected is None:
955-
_launch_copies_host_source(other)
958+
rejected = _cuda_error_from(lambda: other[node].update(dst=dst, src=host_src, size=64))
959+
if rejected is None:
960+
_launch_copies_host_source(other)
961+
else:
962+
assert "CUDA_ERROR_INVALID_VALUE" in str(rejected)
956963

957964

958965
@pytest.mark.agent_authored(model="gpt-5.6")

0 commit comments

Comments
 (0)