Skip to content

Add CUDA plugin EP Sync support for IOBinding - #27919

Merged
Tianlei Wu (tianleiwu) merged 7 commits into
mainfrom
tlwu/20260331/cuda_plugin_sync_api
Apr 7, 2026
Merged

Tianlei Wu (tianleiwu) merged 7 commits into
mainfrom
tlwu/20260331/cuda_plugin_sync_api

Conversation

@tianleiwu

@tianleiwu Tianlei Wu (tianleiwu) commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

This change wires the CUDA plugin EP into ORT's sync surface (see #27538) so IOBinding can safely coordinate device work when inputs and outputs are bound on CUDA. It also clarifies the split between EP-level and factory-level sync-stream creation in the design doc and adds Python coverage to validate the new path with simple CUDA-bound models.

Summary of Changes

CUDA plugin EP implementation

File Change
onnxruntime/core/providers/cuda/plugin/cuda_ep.cc Registers OrtEp::CreateSyncStreamForDevice and OrtEp::Sync in CudaEp, adds per-session CUDA sync-stream creation, and implements a conservative device-wide sync via cudaSetDevice + cudaDeviceSynchronize().
onnxruntime/core/providers/cuda/plugin/cuda_ep.h Declares the new CreateSyncStreamForDeviceImpl and SyncImpl entry points on CudaEp.

Tests

File Change
onnxruntime/test/python/transformers/test_cuda_plugin_ep.py Adds a helper to resolve the CUDA ordinal from plugin device metadata and adds IOBinding-based Add and MatMul tests that bind CUDA inputs/outputs and exercise the plugin EP sync path.

Documentation

File Change
docs/cuda_plugin_ep/cuda_plugin_ep_design.md Documents that CudaEp owns the preferred OrtEp::CreateSyncStreamForDevice and OrtEp::Sync implementations, while CudaEpFactory::CreateSyncStreamForDevice remains a fallback path; also records the new IOBinding test coverage.

Testing

  • Set ORT_CUDA_PLUGIN_PATH to the rebuilt CUDA plugin library under build/cuda/Release and run python -m pytest onnxruntime/test/python/transformers/test_cuda_plugin_ep.py.
  • Verify the new IOBinding Add and MatMul tests pass with CUDA-bound OrtValue inputs and outputs.
  • Confirm existing CUDA plugin EP behavior is unchanged for non-IOBinding execution paths.

Motivation and Context

IOBinding relies on provider synchronization to ensure asynchronous device copies are complete before dependent kernel execution continues. The CUDA plugin EP already supported sync-stream creation at the factory layer, but the staged changes connect the per-session OrtEp callbacks that ORT prefers when coordinating bound CUDA execution. The documentation updates make that ownership model explicit so future plugin work does not conflate the fallback factory hook with the primary EP hook.

Checklist

  • Tests added/updated
  • Documentation updated (if applicable)
  • No breaking changes
  • CI passes

Copilot AI 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.

Pull request overview

Wires the CUDA plugin execution provider into ONNX Runtime’s sync surface so IOBinding can coordinate CUDA device work safely, and adds Python tests plus design documentation updates to cover the new EP-level callbacks.

Changes:

  • Register and implement OrtEp::CreateSyncStreamForDevice and OrtEp::Sync in CudaEp (per-session stream creation + device synchronization).
  • Add Python IOBinding tests (Add/MatMul) that bind CUDA inputs/outputs and exercise the plugin EP sync path.
  • Update the CUDA plugin EP design doc to clarify EP-level vs factory-level sync responsibilities.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
onnxruntime/core/providers/cuda/plugin/cuda_ep.cc Adds EP-level sync-stream creation and EP-level sync implementation.
onnxruntime/core/providers/cuda/plugin/cuda_ep.h Declares new EP-level callback entry points.
onnxruntime/test/python/transformers/test_cuda_plugin_ep.py Adds CUDA device-id helper and new IOBinding-based tests.
docs/cuda_plugin_ep/cuda_plugin_ep_design.md Documents the new sync ownership model and test coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/core/providers/cuda/plugin/cuda_ep.cc
Comment thread onnxruntime/test/python/transformers/test_cuda_plugin_ep.py
Comment thread onnxruntime/test/python/transformers/test_cuda_plugin_ep.py Outdated
Comment thread onnxruntime/core/providers/cuda/plugin/cuda_ep.cc
Comment thread onnxruntime/core/providers/cuda/plugin/cuda_ep.cc

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/core/providers/cuda/plugin/cuda_stream_plugin.cc Outdated
Comment thread onnxruntime/core/providers/cuda/plugin/cuda_ep.cc Outdated
Comment thread onnxruntime/core/providers/cuda/plugin/cuda_plugin_utils.h Outdated

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.

See OrtStatus comments.

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.

:shipit:

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/core/providers/cuda/plugin/cuda_stream_plugin.cc
@yuslepukhin
Dmitri Smirnov (yuslepukhin) dismissed their stale review April 2, 2026 19:54

Need copilot comment addressed

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/core/providers/cuda/plugin/cuda_stream_plugin.cc Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/core/providers/cuda/plugin/cuda_stream_plugin.cc

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/core/providers/cuda/plugin/cuda_ep.cc
@tianleiwu
Tianlei Wu (tianleiwu) merged commit e688ef1 into main Apr 7, 2026
106 of 111 checks passed
@tianleiwu
Tianlei Wu (tianleiwu) deleted the tlwu/20260331/cuda_plugin_sync_api branch April 7, 2026 04:49
Copilot AI added a commit that referenced this pull request May 27, 2026
…ghts_are_all_positive_ logic

PR #27552 removed the weights_are_all_positive_ flag which determined whether
to use the > 0.5 threshold with 1-score complement (write_additional_scores 0/1)
or the > 0 threshold with -score complement (write_additional_scores 2/3).

For RandomForestClassifier models where all leaf weights are non-negative
(representing probabilities), removing this distinction caused:
- Wrong probabilities (negative values instead of 1-p complement)
- Wrong labels (when score is between 0 and 0.5)

The LOGISTIC post_transform case (which issue #27533 was about) handles both
paths identically (applying sigmoid to score and -score), so restoring this
flag does not break the fix for #27533.

Fixes #27919
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.

3 participants