Skip to content

Start refactoring C API and pylibcugraph to Use DLPack - #5590

Open
alexbarghi-nv wants to merge 32 commits into
rapidsai:mainfrom
alexbarghi-nv:plc-dlpack-everywhere
Open

Start refactoring C API and pylibcugraph to Use DLPack#5590
alexbarghi-nv wants to merge 32 commits into
rapidsai:mainfrom
alexbarghi-nv:plc-dlpack-everywhere

Conversation

@alexbarghi-nv

@alexbarghi-nv alexbarghi-nv commented Jul 14, 2026

Copy link
Copy Markdown
Member

Overview

Refactor pylibcugraph to use DLPack for array exchange instead of calling NumPy and CuPy APIs directly. The C API owns DLPack interpretation and validation, while the Python bindings route array conversions through that common boundary.

Changes

  • add and use C API helpers for DLPack tensor conversion
  • update pylibcugraph algorithms and graph construction paths to exchange arrays through DLPack
  • validate managed tensors, data types, dimensions, contiguity, and ownership behavior
  • add C and Python coverage for DLPack conversion and graph construction
  • The goal is to eventually get to require DLPack >=1.0,<1.1 but staying at 0.8 in dependencies.yaml
  • use the DLPack v1.0 CMake fallback and regenerate the checked-in 26.10 conda environments

Release target

This PR targets main for the 26.10 release. The DLPack dependency updates previously tracked in #5602 are incorporated here so the API refactor and its required dependency range land together.

The cross-project DLPack migration is tracked in rapidsai/build-planning#308 and related to NVIDIA/cuvs#2354.

Validation

  • ran rapids-dependency-file-generator --clean --warn-all --strict
  • verified dependency generation is idempotent
  • parsed dependencies.yaml and the generated all_*.yaml environments with PyYAML
  • ran git diff --check
  • verified all generated conda environments use dlpack>=1.0,<1.1

Broader C++ and Python tests are handled by the PR's CI workflows.

@copy-pr-bot

copy-pr-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@alexbarghi-nv alexbarghi-nv added improvement Improvement / enhancement to an existing function breaking Breaking change labels Jul 14, 2026
@alexbarghi-nv alexbarghi-nv self-assigned this Jul 14, 2026
@alexbarghi-nv

Copy link
Copy Markdown
Member Author

/ok to test

1 similar comment
@josephine-wolf-oberholtzer

Copy link
Copy Markdown

/ok to test

@alexbarghi-nv

Copy link
Copy Markdown
Member Author

/ok to test

@alexbarghi-nv

Copy link
Copy Markdown
Member Author

/ok to test

@alexbarghi-nv

Copy link
Copy Markdown
Member Author

/ok to test

@alexbarghi-nv

Copy link
Copy Markdown
Member Author

/ok to test d0b35e4

@copy-pr-bot

copy-pr-bot Bot commented Jul 27, 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.

@alexbarghi-nv alexbarghi-nv changed the title Refactor PylibcuGraph to Use DLPack Refactor C API and pylibcugraph to Use DLPack Jul 27, 2026
@alexbarghi-nv

Copy link
Copy Markdown
Member Author

/ok to test 575ebfe

@alexbarghi-nv

Copy link
Copy Markdown
Member Author

/ok to test fc0fddc

@BradReesWork

Copy link
Copy Markdown
Member

/okay to test 4d65a87

@BradReesWork

Copy link
Copy Markdown
Member

/okay to test 63e046e

@BradReesWork

Copy link
Copy Markdown
Member

/ok to test 62abaf8

@BradReesWork

Copy link
Copy Markdown
Member

/ok to test dac9f4f

@BradReesWork BradReesWork changed the title Refactor C API and pylibcugraph to Use DLPack Start refactor C API and pylibcugraph to Use DLPack Aug 21, 2026
@BradReesWork BradReesWork changed the title Start refactor C API and pylibcugraph to Use DLPack Start refactoring C API and pylibcugraph to Use DLPack Aug 21, 2026
@BradReesWork
BradReesWork marked this pull request as ready for review August 24, 2026 13:25
@BradReesWork
BradReesWork requested review from a team as code owners August 24, 2026 13:26
@BradReesWork
BradReesWork requested a review from msarahan August 24, 2026 13:26
@BradReesWork

Copy link
Copy Markdown
Member

This is just the first PR and not the final version. There are a number of dependencies on other packages that prevents fully supporting DLPAck version 1.0 at this point. But this sets up the code for simply updating the dependency file when cuDF and others have moved to DLPack 1.0

@BradReesWork
BradReesWork requested a review from bdice August 24, 2026 14:35

@alexbarghi-nv alexbarghi-nv left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@BradReesWork just 1 comment; otherwise looks ok.

endfunction()

set(CUGRAPH_MIN_VERSION_dlpack 0.8)
set(CUGRAPH_MIN_VERSION_dlpack 1.0)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do we need to change this to 0.8? Or maybe it's safe to build with 1.0+ here as long as we set our runtime version to 0.8+. That would make sense I think.

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.

I'm not familiar with dlpack's version guarantees. This assumption usually does not hold, and I would set it to 0.8 to be safe - unless you know better about dlpack's behavior.

@msarahan msarahan 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.

I don't think this is safe, and I don't understand the thinking. I read rapidsai/build-planning#308 and I understand that an earlier effort was closed for 26.08 because cudf wasn't ready. I think the correct approach is to remain pinned to 0.8 until all of the projects are ready to change over.

I approve of the added pinnings, but I think the cmake file needs to revert back to 0.8.

endfunction()

set(CUGRAPH_MIN_VERSION_dlpack 0.8)
set(CUGRAPH_MIN_VERSION_dlpack 1.0)

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.

I'm not familiar with dlpack's version guarantees. This assumption usually does not hold, and I would set it to 0.8 to be safe - unless you know better about dlpack's behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change improvement Improvement / enhancement to an existing function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants