Repository navigation
Description
Part of #2077.
Problem
cuda_core/tests/memory/test_managed_ops.py::TestManagedBuffer::test_preferred_location_roundtrip_host_numa never runs in CI.
It sets ManagedBuffer.preferred_location = Host(numa_id=0). If the value doesn't read back, it skips with "host_numa preferred_location not supported by this driver / hardware". It skips on all 31 Linux CUDA 13 configurations, including GH200 and GB300; Windows and WSL skip earlier, on concurrent managed access.
The "not supported by this hardware" explanation doesn't hold up. On the same 31 configurations:
| Test | Result |
|---|---|
test_preferred_location_roundtrip_host_numa (advise Host(numa_id=0), read back) |
skipped on all 31 |
test_last_prefetch_location_roundtrip_host_numa[pool] / [external] (prefetch to Host(numa_id=0), read back) |
passes on all 31 |
test_preferred_location_roundtrip (advise a Device, read back) |
passes on all 31 |
Both read paths use the same helper, _read_location_v2, with the *_LOCATION_TYPE/*_LOCATION_ID range attributes. So host-NUMA locations work for prefetch; only the preferred-location advice doesn't round-trip.
Local reproduction with cuda.bindings only
The same behavior reproduces without cuda.core: GeForce RTX 5070, driver 615.71.09 (CUDA 13.4), one NUMA node. The script calls cuMemAdvise(..., CU_MEM_ADVISE_SET_PREFERRED_LOCATION, loc) on a cuMemAllocManaged range, then reads CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE/_ID:
| Advice set (in this order, same range) | PREFERRED_LOCATION_TYPE / _ID read back |
|---|---|
DEVICE 0 |
DEVICE / 0 |
HOST |
HOST / -1 |
HOST_NUMA 0 |
HOST / -1, i.e. unchanged from the previous advice |
HOST_NUMA 0 on a fresh range |
INVALID / -2, i.e. no preferred location recorded |
For comparison, cuMemPrefetchAsync to HOST_NUMA 0 reads back LAST_PREFETCH_LOCATION_TYPE / _ID = HOST_NUMA / 0.
So the driver accepts SET_PREFERRED_LOCATION with a HOST_NUMA location (the call returns CUDA_SUCCESS), but the preferred-location attribute never reports it. That points to the driver (or a documented driver limitation), not to cuda.core.
Meanwhile, cuda.core documents the opposite. The ManagedBuffer.preferred_location docstring (cuda/core/_memory/_managed_buffer.py) says: "On CUDA 13 builds, fully round-trips Host(numa_id=N)."
Proposal
- Confirm with the CUDA driver team whether
SET_PREFERRED_LOCATIONwithCU_MEM_LOCATION_TYPE_HOST_NUMAis expected to be reported byCU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE/_ID. If it is, file a driver bug with the reproduction above. - Fix the cuda.core docstring to describe the actual behavior.
- Change the test so it stops presenting this as unsupported hardware. If it's a driver bug, use an
xfailthat references the bug, gated on the affected driver versions. If it's intended behavior, change the test to assert the documented result.
Done when
The behavior is confirmed as a driver bug (tracked) or intended (documented), the docstring matches it, and the test no longer skips on capable Linux runners.
Guidance for PRs that address this issue
- When making a fix that allows a test to run in CI, remove the comment about the test not running in CI from the code.
- When making a test run only in nightly CI, we need to concretely confirm that in nightly CI. Include instructions in the PR about how to kick off a nightly run for the specific PR in order to test that (see below).
- For every PR note that the reviewer should feel free to push commits directly to the PR to improve things. @mdboom does not have the bandwidth to shepard each of them through.
- Every PR should include a way to confirm automatically that the tests are now running in at least one CI configuration.
Running the nightly test suites for a PR
The nightly workflow can test a PR's own wheels and tests, but it has to be started by hand. Starting it needs write access to NVIDIA/cuda-python, so ask a maintainer if you don't have it.
-
Wait for the PR's CI workflow run to finish successfully, and note its run ID, the number in its URL (
.../actions/runs/<run-id>). -
Start CI: Nightly optional-deps on the PR's mirror branch, with that run ID. Either:
-
In the GitHub UI: Actions → CI: Nightly optional-deps → Run workflow. Set Use workflow from to
pull-request/<PR number>, enter the run ID in the run-ID field, and leave the link-checker-only box unchecked. -
From the command line:
gh workflow run ci-nightly.yml --repo NVIDIA/cuda-python --ref pull-request/<PR number> -f run-id=<run-id>
Supply the run ID. Without it, the nightly run tests
main's latest wheels and tests, not the PR's. -
-
Link the nightly run in the PR. Then confirm that the affected tests ran and passed, rather than skipped, in the relevant nightly jobs.
The nightly run tests the commit of that CI run. Repeat these steps after pushing changes that affect the nightly-only tests.
Activity