Skip to content

[FEA] Expose graph/node IDs as ints - #3332

Merged
Andy-Jost merged 10 commits into
NVIDIA:mainfrom
martindurant:ids
Nov 6, 2026
Merged

Andy-Jost merged 10 commits into
NVIDIA:mainfrom
martindurant:ids

Conversation

@martindurant

Copy link
Copy Markdown
Contributor

Description

closes #2360

Added read-only graph/node IDs and a kernel device-update capability flag, with CUDA version guards. The IDs become python ints.

Checklist

  • I have read the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Nov 2, 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 Nov 2, 2026
# Conflicts:
#	cuda_core/docs/source/release/1.3.0-notes.rst
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added read-only IDs for graph definitions and executable graphs, along with graph-local and tooling IDs for graph nodes. These properties require a CUDA 13 build and a CUDA 13.1 or newer driver.
    • Added a kernel attribute indicating whether device-node updates are supported. It requires a CUDA 13 build and a CUDA 13.3 or newer driver.
  • Documentation
    • Updated the API reference and release notes with the new properties, version requirements, and graph-node navigation details.

The change adds graph and node identity properties and a kernel attribute for device-node-update support. The properties include CUDA build and driver-version checks. Tests and documentation cover the new APIs.

Changes: Graph identity and kernel capability APIs

Layer / File(s) Summary
Expose graph and node identifiers
cuda_core/cuda/core/graph/_graph_definition.pyi, cuda_core/cuda/core/graph/_graph_definition.pyx, cuda_core/cuda/core/graph/_graph_builder.pyi, cuda_core/cuda/core/graph/_graph_builder.pyx, cuda_core/cuda/core/graph/_graph_node.pyi, cuda_core/cuda/core/graph/_graph_node.pyx, cuda_core/tests/graph/test_graph_definition.py, cuda_core/docs/source/api.rst, cuda_core/docs/source/release/1.3.0-notes.rst
Graph wrappers add id; graph nodes add local_id and tools_id. Access checks include build, driver-version, and object-validity checks. A test covers graph and node identity properties. The API reference and release notes document the properties.
Expose kernel update capability
cuda_core/cuda/core/_module.pyi, cuda_core/cuda/core/_module.pyx, cuda_core/docs/source/api.rst, cuda_core/tests/test_module.py
KernelAttributes adds device_node_update_supported. Builds before CUDA 13 and drivers older than 13.3 raise NotImplementedError. A test checks the property across supported and unsupported configurations. The API reference documents the property and version requirement.

Assessment against linked issues

Objective Addressed Explanation
[#2360] Expose graph and executable graph IDs, node local and tooling IDs, and node-to-graph navigation ❓ The graph and node ID properties are implemented. The summaries mention node.graph in documentation but do not show an implementation change for node-to-graph navigation.
[#2360] Expose the device-node-update kernel attribute ✅

Possibly related issues

  • NVIDIA/cuda-python#2663 — The kernel capability property supports capability checks, but this change does not add the requested LaunchConfig setter.

Possibly related PRs

  • NVIDIA/cuda-python#3034 — This PR migrates the CUDA Core 1.3.0 release documentation to generated snippets, which affects publication of this change’s release-note entry.

Suggested reviewers: mdboom

Change: Feature

Merge Risk: Low · up to fb702

The APIs are documented and guarded, but some availability guidance and one unsupported-build error can still mislead users. These bounded wording issues can be corrected before merge or accepted for follow-up.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e4f844e and fb7024f.

Files selected for processing: 2

  • cuda_core/cuda/core/graph/_graph_builder.pyx
  • cuda_core/cuda/core/graph/_graph_definition.pyx
Files skipped from review as they are similar to previous changes: 2

  • cuda_core/cuda/core/graph/_graph_builder.pyx
  • cuda_core/cuda/core/graph/_graph_definition.pyx

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@martindurant martindurant added this to the cuda.core 1.3.0 milestone Nov 2, 2026

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up Comments

Nitpick important: Assert unsupported node IDs on older drivers.

823-823: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

important: Assert unsupported node IDs on older drivers.

For a CUDA 13 build with a driver below 13.1, node.local_id and node.tools_id raise NotImplementedError, but this branch checks only definition.id and graph.id.

Suggested test fix
         if driver_version() < (13, 1, 0):
             with pytest.raises(NotImplementedError):
                 _ = definition.id
             with pytest.raises(NotImplementedError):
                 _ = graph.id
+            with pytest.raises(NotImplementedError):
+                _ = node.local_id
+            with pytest.raises(NotImplementedError):
+                _ = node.tools_id
             return

Add _BINDINGS_MAJOR < 13 to this condition after the ID properties receive a CUDA 12 build guard. At the current head, the CUDA 12 build cannot compile the direct ID API references.

Open the source location

Comment thread cuda_core/cuda/core/_module.pyx Outdated

@property
def device_node_update_supported(self) -> bool:
"""bool : Whether this kernel supports device-side graph node updates.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

important: Clarify which kernel the capability describes.

The driver attribute reports whether this kernel can be the target of a device-side update. The current wording can also mean that this kernel can issue updates to other nodes. Clarify the target meaning here and in the API documentation. (docs.nvidia.com)

Comment thread cuda_core/cuda/core/_module.pyx Resolved
Comment thread cuda_core/cuda/core/_module.pyx Resolved
@Andy-Jost Andy-Jost added the feature New feature or request label Nov 2, 2026

@Andy-Jost Andy-Jost 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.

The implementation looks good to me after the coderabbit issues are fixed. I'll approve it once the CUDA 12 fencing is in place.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up Comments

Outside diff suggestion: State the CUDA 13 build requirement.

48-50: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

suggestion: State the CUDA 13 build requirement.

On a CUDA 12 build, the graph identity properties raise NotImplementedError even with a 13.1+ driver. Replace “CUDA 13.1+” with “CUDA 13 build and driver 13.1+” so the release note describes the available configuration. As per coding guidelines, “Keep user-facing behaviors coherent with docs and samples.” (raw.githubusercontent.com)

Source: Coding guidelines

Open the source location

Comment thread cuda_core/cuda/core/_module.pyx Resolved
Comment on lines +1263 to +1271
IF CUDA_CORE_BUILD_MAJOR >= 13:
cdef unsigned int graph_id
if cy_driver_version() < (13, 1, 0):
raise NotImplementedError("Graph IDs require CUDA driver 13.1 or newer")
with nogil:
HANDLE_RETURN(cydriver.cuGraphExecGetId(as_cu(self._h_graph_exec), &graph_id))
return graph_id
ELSE:
raise NotImplementedError("Graph IDs require the CUDA 13 build of cuda.core")

@Andy-Jost Andy-Jost Nov 2, 2026 •

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.

nit: it would be better IMO to use the same message in either case when the feature is unavailable (5 instances)

IF CUDA_CORE_BUILD_MAJOR >= 13:
    cdef unsigned int graph_id
    if cy_driver_version() >= (13, 1, 0):
        with nogil:
            HANDLE_RETURN(cydriver.cuGraphExecGetId(as_cu(self._h_graph_exec), &graph_id))
        return graph_id
raise NotImplementedError("Graph IDs require CUDA driver 13.1 or newer")

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.

Reading through the bot messages above, it seems that there is a difference here between the SDK and driver version: cuda12 builds can still get the values if the driver is new enough. If we trust the bot... I am happy to keep the blanket guards as they are (with the language fix you suggest), but thought you might want to consider this.

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.

Are the driver functions defined in CUDA 12? I don't see them listed in the CUDA 12.9 Documentation or cuda-bindings. Without the entry point, a newer driver won't help.

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 don't know :|
I was trying to decode what the auto-review said

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.

coderabbit was out to lunch. I posted messages declining its recommendations.

@martindurant martindurant self-assigned this Nov 3, 2026
edges. Both produce an executable :class:`~graph.Graph` that can be
launched on a :class:`Stream`.

With CUDA >= 13.1, graph definitions and

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

suggestion: State the CUDA 13 build requirement for these properties. On a CUDA 12 build, the ID properties raise NotImplementedError even with a 13.1-or-newer driver. device_node_update_supported also raises on that build even with a 13.3-or-newer driver. State the build requirement in both paragraphs and in the Graph.id declaration.

As per coding guidelines, “Keep user-facing behaviors coherent with docs and samples.” As per path instructions, “Check that public behavior changes have corresponding tests, documentation and release notes.”

Sources: Coding guidelines, Path instructions

@Andy-Jost

Copy link
Copy Markdown
Contributor

Thanks @martindurant. I declined two of CodeRabbit's threads (the cuFuncGetAttribute detour and the CUDA 12 compatibility enum). These items remain:

  1. Test gate. On a CUDA 12 build with a 13.1+ driver, every ID property raises NotImplementedError, so test_graph_identity_attributes fails. Gate on the build major as well, as test_green_context.py does:
    from cuda.core._utils.version import BUILD_CUDA_MAJOR, driver_version
    
    if BUILD_CUDA_MAJOR < 13 or driver_version() < (13, 1, 0):
  2. Unsupported-path coverage. In that branch, also assert that node.local_id and node.tools_id raise NotImplementedError.
  3. device_node_update_supported has no test. Add one that checks for a bool on a CUDA 13 build with a 13.3+ driver, and checks for NotImplementedError otherwise.
  4. One error message. As in my earlier nit, use a single fall-through raise in each of the five properties. Word the message so it holds for both cases, for example "Graph IDs require a CUDA 13 build of cuda.core and CUDA driver 13.1 or newer". The current text is wrong on a CUDA 12 build with a new driver.
  5. Docs. State "CUDA 13 build and driver 13.1+" (13.3+ for device_node_update_supported) in api.rst, the 1.3.0 release note, and the Graph.id docstring in both .pyx and .pyi. GraphNode.local_id and GraphNode.tools_id state no requirement at all.
  6. Wording. In the device_node_update_supported docstring, say that the kernel can be the target of a device-side node update. The current text also reads as if the kernel issues updates to other nodes.

@martindurant

Copy link
Copy Markdown
Contributor Author

I think I covered it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · 🎯 Functional Correctness · _graph_builder.pyx:1267-1276

cuda_core/cuda/core/graph/_graph_builder.pyx:1267-1276
Minor · Functional Correctness · Quick win

important: State both requirements in the Graph.id error.

When an open Graph is used on a CUDA 12 build with a CUDA 13.1-or-newer driver, the ELSE branch raises a message that names only the driver requirement. State that graph IDs require a CUDA 13 build of cuda.core and a CUDA 13.1-or-newer driver. GraphDefinition.id has the same incomplete message and needs the equivalent correction.

Suggested fix
-            raise NotImplementedError("Graph IDs require CUDA driver 13.1 or newer")
+            raise NotImplementedError("Graph IDs require a CUDA 13 build of cuda.core and CUDA driver 13.1 or newer")
Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2439fd9 and 45c9a18.

Files selected for processing: 9
  • cuda_core/cuda/core/_module.pyi
  • cuda_core/cuda/core/_module.pyx
  • cuda_core/cuda/core/graph/_graph_definition.pyi
  • cuda_core/cuda/core/graph/_graph_definition.pyx
  • cuda_core/cuda/core/graph/_graph_node.pyi
  • cuda_core/cuda/core/graph/_graph_node.pyx
  • cuda_core/docs/source/release/1.3.0-notes.rst
  • cuda_core/tests/graph/test_graph_definition.py
  • cuda_core/tests/test_module.py
Files skipped from review as they are similar to previous changes: 1
  • cuda_core/docs/source/release/1.3.0-notes.rst

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

cydriver.CU_FUNC_ATTRIBUTE_DEVICE_NODE_UPDATE_SUPPORTED,
))
ELSE:
raise NotImplementedError("Device node update queries require CUDA driver 13.3 or newer")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

important: Include the CUDA 13 build requirement in the error.

On a CUDA 12 build with a 13.3 or newer driver, this error says a newer driver is required even though the driver meets that requirement. State that the property also requires a CUDA 13 build.

@Andy-Jost

Copy link
Copy Markdown
Contributor

/ok to test fb7024f

@Andy-Jost
Andy-Jost enabled auto-merge (squash) November 5, 2026 23:27
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor
Doc Preview CI
Preview removed because the pull request was closed or merged.

@Andy-Jost
Andy-Jost merged commit ddc2a2a into NVIDIA:main Nov 6, 2026
116 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 6, 2026
Removed preview folders for the following PRs:
- PR #3305
- PR #3332
- PR #3343
- PR #3368
- PR #3380
- PR #3387
- PR #3388
- PR #3389
- PR #3391
- PR #3393
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 feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA] cuda.core: expose graph and graph-node identity/introspection APIs (CUDA 13.1)

2 participants