fix(cuda.core): avoid truncating graph queries - #2587
Open
yimoj wants to merge 4 commits into
Open
Conversation
Contributor
Verify exact edge identities so graph query regressions cannot pass through count-only checks.
Andy-Jost
self-requested a review
August 10, 2026 17:29
Contributor
|
/ok to test a1ba4ef |
Andy-Jost
approved these changes
Aug 10, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CUDA graph query APIs report the number of entries copied when the supplied buffer is too small.
cuda.coreused fixed-size buffers and treated that copied count as the total, silently truncating adjacency queries after 16 entries and graph node/edge queries after 128 entries.This change uses the documented two-call pattern: first query the total count with a NULL output buffer, then allocate the exact capacity and fetch the results. It covers adjacency iteration and membership as well as
GraphDefinition.nodes()andGraphDefinition.edges().NVBug: 6572657
Testing
cuda_core/tests/graph/test_graph_definition.py: 210 passed, 6 skippedcuda_core/tests/graph: 495 passed, 7 skippedImplementation choice
This follows the NULL-first two-call pattern discussed in #2529: the first call obtains the true count, then adjacency queries use the existing 16-entry C stack buffer when the result fits and fall back to
std::vectorfor larger sets. This preserves correctness without a new small-vector dependency and avoids heap allocation in the common small-adjacency case.We compared the plain
std::vector, manual stack fallback, and a small-vector wrapper. All variants passed the regression tests; the manual stack variant was the simplest and consistently fastest in the microbenchmark. For adjacency membership at 1/8/16 entries it was approximately 17%/21%/21% faster than always allocating a vector, while iteration improved by approximately 2-7%.Fixes #2529