Skip to content

Report host_numa virtual memory as host-accessible - #2503

Open
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:fix/vmm-host-numa-is-host-accessible
Open

Report host_numa virtual memory as host-accessible#2503
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:fix/vmm-host-numa-is-host-accessible

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown

A VirtualMemoryResource configured with location_type="host_numa" or "host_numa_current" reports is_host_accessible is False and is_device_accessible is False — it claims the memory is reachable from nowhere.

__init__ classifies host-located resources with a substring test:

# Matches ("host", "host_numa", "host_numa_current")
if "host" in self.config.location_type:
    self.device = None

but is_host_accessible used exact equality:

return self.config.location_type == "host"

Both were introduced in cec0efb (#2016) and disagreed from the start. The answer propagates to Buffer.is_host_accessible, which forwards straight to the memory resource, so anything choosing CPU vs GPU from a buffer — DLPack/StridedMemoryView device selection, copy validation — sees the wrong answer.

host_numa_current is a working configuration today: the driver ignores location.id for that type, so the resource allocates fine and only the reported accessibility is wrong.

The fix gives both sites a shared _HOST_LOCATION_TYPES frozenset so they cannot drift again. VirtualMemoryLocationType is a StrEnum, so membership behaves identically for raw strings and enum members. is_device_accessible is deliberately left alone.

On verification, plainly: I have no GPU and no cuda.bindings build here, so nothing under cuda_core/tests/ can even import and I did not run the new test. What I did run is the old and new expressions plus __init__'s classifier extracted against a verbatim copy of the enum — that reproduces both NUMA types returning False on both properties before the change, and agreement with __init__ for all four members after. The regression test is GPU-gated by construction and will fail on main for the two NUMA parameters.

NOTE: developed with the assistance of an AI coding agent. The new test carries @pytest.mark.agent_authored per AGENTS.md. I reviewed and verified the change before submitting.

`VirtualMemoryResource.__init__` classifies "host", "host_numa" and
"host_numa_current" all as host-located (it clears `self.device` for
each), but `is_host_accessible` compared with `== "host"`. A resource
configured with `location_type="host_numa"` or `"host_numa_current"`
therefore reported `is_host_accessible is False` *and*
`is_device_accessible is False` -- an impossible answer that propagates
to `Buffer.is_host_accessible`, which forwards to the memory resource.

Share a single `_HOST_LOCATION_TYPES` set between the constructor and
the property so the two classifications cannot drift again.
@copy-pr-bot

copy-pr-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant