@@ -3124,32 +3124,98 @@ def test_vmm_options_store_peers_as_tuple():
31243124
31253125
31263126@pytest .mark .agent_authored (model = "claude-fable-5-1" )
3127- @pytest .mark .parametrize ("location_type" , ["host" , "host_numa" , "host_numa_current" ])
3127+ @pytest .mark .parametrize ("location_type" , ["host" , "host_numa" ])
31283128def test_vmm_host_location_types_report_host_accessible (init_cuda , location_type ):
31293129 """Every host-backed location type reports is_host_accessible; only "host" needs handle_type=None.
31303130
3131- __init__ classifies "host", "host_numa" and "host_numa_current " alike when
3131+ __init__ classifies "host" and "host_numa " alike when
31323132 deciding the resource is not bound to a device, so is_host_accessible must
31333133 agree; otherwise a NUMA-located resource claims to be neither host- nor
31343134 device-accessible. The driver rejects an exportable handle type for HOST
31353135 memory only, so the default handle type is rejected at construction for
3136- "host" and accepted for the NUMA location types .
3136+ "host" and accepted for "host_numa" .
31373137 """
31383138 device = Device ()
31393139 device .set_current ()
3140+ numa = {"numa_id" : 0 } if location_type == "host_numa" else {}
31403141 if location_type == "host" :
31413142 with pytest .raises (ValueError , match = "handle_type=None" ):
31423143 VirtualMemoryResource (device , config = VirtualMemoryResourceOptions (location_type = location_type ))
31433144 else :
3144- VirtualMemoryResource (device , config = VirtualMemoryResourceOptions (location_type = location_type ))
3145+ VirtualMemoryResource (device , config = VirtualMemoryResourceOptions (location_type = location_type , ** numa ))
31453146 mr = VirtualMemoryResource (
3146- device , config = VirtualMemoryResourceOptions (location_type = location_type , handle_type = None )
3147+ device , config = VirtualMemoryResourceOptions (location_type = location_type , handle_type = None , ** numa )
31473148 )
31483149 assert mr .device is None
31493150 assert mr .is_host_accessible is True
31503151 assert mr .device_id == - 1
31513152
31523153
3154+ @pytest .mark .thread_unsafe (reason = "records process-global warnings" )
3155+ @pytest .mark .agent_authored (model = "claude-opus-5-5" )
3156+ def test_vmm_host_numa_allocates_and_copies (init_cuda ):
3157+ """A "host_numa" resource allocates on its NUMA node, and the host can use the memory.
3158+
3159+ The driver rejects CU_MEM_LOCATION_TYPE_HOST_NUMA with location id -1, so
3160+ the allocation works only if numa_id reaches the allocation properties
3161+ (#2694). The resource grants access to its own location only, so the data
3162+ goes through the host. A per-call config cannot move the buffer to another
3163+ node.
3164+ """
3165+ device = Device ()
3166+ device .set_current ()
3167+ props = device .properties
3168+ if not props .host_numa_virtual_memory_management_supported :
3169+ pytest .skip ("Host NUMA virtual memory management is not supported on this device" )
3170+ if props .host_numa_id < 0 :
3171+ pytest .skip ("The system reports no host NUMA node" )
3172+ mr = VirtualMemoryResource (
3173+ device ,
3174+ config = VirtualMemoryResourceOptions (location_type = "host_numa" , numa_id = props .host_numa_id , handle_type = None ),
3175+ )
3176+ with assert_no_cuda_warning ():
3177+ buf = mr .allocate (4096 )
3178+ try :
3179+ assert buf .is_host_accessible
3180+ ctypes .memset (int (buf .handle ), 0xAB , buf .size )
3181+ assert ctypes .string_at (int (buf .handle ), buf .size ) == b"\xab " * buf .size
3182+ other_node = VirtualMemoryResourceOptions (
3183+ location_type = "host_numa" , numa_id = props .host_numa_id + 1 , handle_type = None
3184+ )
3185+ with pytest .raises (ValueError , match = "config.numa_id" ):
3186+ mr .modify_allocation (buf , 2 * buf .size , other_node )
3187+ finally :
3188+ buf .close ()
3189+
3190+
3191+ @pytest .mark .agent_authored (model = "claude-opus-5-5" )
3192+ def test_vmm_host_numa_current_rejected (init_cuda ):
3193+ """The driver does not accept "host_numa_current" for physical allocations, so construction rejects it."""
3194+ device = Device ()
3195+ device .set_current ()
3196+ with pytest .raises (ValueError , match = "does not accept it for physical allocations" ):
3197+ VirtualMemoryResource (
3198+ device , config = VirtualMemoryResourceOptions (location_type = "host_numa_current" , handle_type = None )
3199+ )
3200+
3201+
3202+ @pytest .mark .agent_authored (model = "claude-opus-5-5" )
3203+ @pytest .mark .parametrize (
3204+ ("options" , "match" ),
3205+ [
3206+ pytest .param ({"location_type" : "host_numa" }, "requires numa_id" , id = "host_numa-missing" ),
3207+ pytest .param ({"location_type" : "host_numa" , "numa_id" : - 1 }, "numa_id must be >= 0" , id = "host_numa-negative" ),
3208+ pytest .param ({"location_type" : "host" , "numa_id" : 0 }, "only valid with" , id = "host-misplaced" ),
3209+ pytest .param ({"location_type" : "device" , "numa_id" : 0 }, "only valid with" , id = "device-misplaced" ),
3210+ ],
3211+ )
3212+ def test_vmm_numa_id_validation (init_cuda , options , match ):
3213+ """numa_id is required for "host_numa", must be non-negative, and is rejected for other location types."""
3214+ device = _vmm_device_or_skip ()
3215+ with pytest .raises (ValueError , match = match ):
3216+ VirtualMemoryResource (device , config = VirtualMemoryResourceOptions (handle_type = None , ** options ))
3217+
3218+
31533219def test_device_memory_resource_peer_accessible_by_non_owned (mempool_device ):
31543220 """peer_accessible_by on a non-owned (default) DMR queries the driver live."""
31553221 dev = mempool_device
0 commit comments