Skip to content

fix: identify GPU by PCI bus id when probing hw decompression - #176

Merged
rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
aminaramoon:no_rmm_in_discovery
Sep 15, 2026
Merged

rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
aminaramoon:no_rmm_in_discovery

Conversation

@aminaramoon

@aminaramoon aminaramoon commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description

  1. move kvikio under cudf targets
  2. create 2 phase discovery for runtime attributes to avoid initializing cudaContext.

@copy-pr-bot

copy-pr-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

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.

Comment thread src/memory/topology_discovery.cpp Outdated
Comment on lines +67 to +69
* `CUdevice` and `CUresult` are spelled as `int` to avoid pulling in `<cuda.h>`:
* `CUdevice` is a typedef for `int` and `CUresult` is an int-sized enum, so both
* match the driver ABI.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only necessary if you want to be able to compile without cuda.h. Is that required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess topology discovery could, but you do have a point as cucascade has cuda as a dependency. so technicallyt it will never happen. I can change that.

Comment thread src/memory/topology_discovery.cpp Outdated
aminaramoon added a commit to aminaramoon/cucs that referenced this pull request Jul 31, 2026
Address review feedback on NVIDIA#176.

Spell the driver entry points with CUdevice/CUresult/CUdevice_attribute
and use CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_ALGORITHM_MASK directly
rather than hand-rolled int signatures and a literal 136. Including
<cuda.h> costs nothing here: the toolkit include path already comes in
via CUDA::nvml_static, the project requires CUDA 12.9+ so the 12.8
enumerator is always present, and the header adds no link dependency --
the .so still has no DT_NEEDED on libcuda.so.1. The dlopen indirection
stays, since that is what keeps the library loadable on driverless
hosts; only the type spelling changes.

Resolve symbols by clearing dlerror() and inspecting it afterwards. A
null return from dlsym is not by itself an error, so the previous
null-check was the wrong test. This also drops the memcpy: a plain
reinterpret_cast compiles clean under the project's full warning set
including -Wpedantic -Werror, so the workaround was unnecessary.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@aminaramoon
aminaramoon requested review from felipeblazing, pentschev and wence- and removed request for wence- September 14, 2026 16:49
Comment thread .cache/.gitignore Outdated
@@ -0,0 +1 @@
clangd/ No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should .cache itself be gitignored?

aminaramoon and others added 7 commits September 15, 2026 10:24
query_hw_decompression took a device ordinal and resolved it with
rmm::cuda_set_device_raii. Ordinals are not a stable identity across
APIs: NVML enumerates in PCI-bus order while the CUDA runtime defaults
to CUDA_DEVICE_ORDER=FASTEST_FIRST, so gpu.id -- a position in this
discovery's own CUDA_VISIBLE_DEVICES-filtered list -- need not name the
same device to CUDA on a heterogeneous host.

The mismatch was latent because rmm::detail::hwdecompress::is_supported()
only calls cudaDriverGetVersion; it answers "is the driver >= 12.8",
never a per-device question, so the ordinal selected nothing.

Query CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_ALGORITHM_MASK against the
device resolved by cuDeviceGetByPCIBusId instead. That is immune to both
the FASTEST_FIRST reordering and CUDA_VISIBLE_DEVICES remapping, takes
its device explicitly (no context created, current device untouched),
and reports actual silicon capability rather than a driver version.

The driver API is reached via dlopen("libcuda.so.1") + dlsym rather than
a link dependency, so the library still loads on driverless hosts --
matching the treatment of NVML -- and CUdevice/CUresult are spelled as
int to avoid pulling in <cuda.h>. The runtime API is not an option here:
this CUDA version exposes no cudaDevAttrMemDecompress* equivalent.

This removes the only RMM use in topology_discovery.cpp, so drop
rmm::rmm from the three topology targets. Side effect:
CUCASCADE_TOPOLOGY_ONLY=ON now configures and builds -- it never calls
find_package(rmm), so linking rmm::rmm had it failing at generate time.

Behavior change: hw_decompression_available now reports false on
pre-Blackwell GPUs that previously reported true on any >= 12.8 driver.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Address review feedback on NVIDIA#176.

Spell the driver entry points with CUdevice/CUresult/CUdevice_attribute
and use CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_ALGORITHM_MASK directly
rather than hand-rolled int signatures and a literal 136. Including
<cuda.h> costs nothing here: the toolkit include path already comes in
via CUDA::nvml_static, the project requires CUDA 12.9+ so the 12.8
enumerator is always present, and the header adds no link dependency --
the .so still has no DT_NEEDED on libcuda.so.1. The dlopen indirection
stays, since that is what keeps the library loadable on driverless
hosts; only the type spelling changes.

Resolve symbols by clearing dlerror() and inspecting it afterwards. A
null return from dlsym is not by itself an error, so the previous
null-check was the wrong test. This also drops the memcpy: a plain
reinterpret_cast compiles clean under the project's full warning set
including -Wpedantic -Werror, so the workaround was unnecessary.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Remove 19 comments in topology_discovery.cpp that narrate the line
below them without adding context ("// Get GPU count" above a
GetCount call, "// Convert to lowercase" above a tolower loop, and
similar).

Comments carrying information the code cannot express are kept: the
NVML re-init SEGV explanation, the MIG parent/instance rationale, the
NVML-vs-sysfs PCI bus id format mismatch, the path-type proximity
heuristic, and the /sys state file format.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Drop the internal cuInit(0) call from discover_runtime_attributes and
document the precondition instead. Callers of discover_runtime_attributes
(directly or via discover(with_runtime_attributes=true)) are expected to
have already initialized the CUDA driver API, either explicitly via
cuInit(0) or transitively via a prior CUDA runtime call.

This function still does not create a CUDA context. Per-GPU queries that
fail because the driver is uninitialized silently yield hw_decomp=false,
consistent with the existing best-effort behavior of query_hw_decompression.
@mbrobbel

Copy link
Copy Markdown
Member

/ok to test 988048f

@pentschev pentschev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving based on verification of CUDA initialization, I have been able to confirm that no distortion of CUDA_VISIBLE_DEVICES occur due to the early CUDA context initialization, which fixes the issue we had with RapidsMPF's use of topology discovery and allows us to resume using cuCascade's main branch during development.

Thanks @aminaramoon .

Comment thread src/memory/topology_discovery.cpp Outdated
Co-authored-by: Peter Andreas Entschev <peter@entschev.com>
@aminaramoon

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 5f19306 into NVIDIA:main Sep 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants