.Net: Add Provider Support to ONNX Connector (+CUDA Sample)#12861
Merged
markwallace-microsoft merged 11 commits intoAug 7, 2025
Merged
Conversation
Member
|
@loicbtd Thanks for the contribution, I added some extra updates to this PR related to your change and other outstanding changes I had plan myself to add to the connector. Overall LTGM. |
rogerbarreto
approved these changes
Aug 5, 2025
Contributor
Author
|
Thanks for the update 👍 |
markwallace-microsoft
approved these changes
Aug 6, 2025
loicbtd
commented
Aug 7, 2025
markwallace-microsoft
approved these changes
Aug 7, 2025
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.
Motivation and Context
Why is this change required?
Currently, users can configure ONNX execution providers by manually creating a
genai_config.jsonfile next to the ONNX model.What problem does it solve?
This change eliminates the need for manual JSON configuration files by providing a programmatic API for provider configuration, making it easier for developers to configure ONNX execution providers directly through code with the extension methods.
What scenario does it contribute to?
This improves the developer experience when working with ONNX models in Semantic Kernel, particularly for scenarios where:
If it fixes an open issue, please link to the issue here.
Closes .Net: Add Provider Choice Support to ONNX Connector #12828
Description
Changes Made:
Providerclass to encapsulate provider configuration withIdandOptionspropertiesOnnxRuntimeGenAIChatCompletionServiceto accept the providers parameter.OnnxKernelBuilderExtensions.AddOnnxRuntimeGenAIChatCompletionto accept the providers parameter.OnnxWithProviderChoicedemo showcasing the new provider configuration APIDesign Approach:
The implementation leverages ONNX Runtime GenAI's existing
ConfigAPI to programmatically set providers and their options. TheProviderclass provides a clean abstraction for specifying provider ID (e.g., "cuda", "cpu") and custom options. During service initialization, the providers are configured using the underlying ONNX Runtime GenAI configuration system.Usage Example:
Backward Compatibility:
This change maintains full backward compatibility. Existing code continues to work without modification, and the manual
genai_config.jsonapproach remains supported.Contribution Checklist