Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to modify provider options at runtime #1048

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

RyanUnderhill
Copy link
Member

Now a provider can be chosen and configured purely at runtime, to override what the genai_config.json specifies.
auto config = OgaConfig::Create("path\to\model"); config->SetProviderOption("cuda", "enable_quantum_drive", "1"); auto model = OgaModel::Create(*config);
vs this if no runtime changes are needed (this is also the current API):
auto model = OgaModel::Create("path\to\model");

This will solve the following use cases:

  • User wants to change a runtime option for a provider already specified in the genai_config.json
  • User wants to switch which provider is used vs what the genai_config.json specifies
  • The genai_config.json specifies no provider, and one is completely chosen at runtime.

The OgaConfig provides these methods:

  • ClearProviders() - Remove all providers currently specified (will default to cpu if nothing else happens)
  • SetProvider("provider_name") - If provider is already exists, does nothing, otherwise adds to end of provider list
  • SetProviderOption("provider_name", "option_name", "option_value") - If provider doesn't exist, adds it to end of list. Then sets an option on the provider.

* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
#include "ai_onnxruntime_genai_Model.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be `ai_onnxruntime_genai_Config.h"

Copy link
Member Author

Choose a reason for hiding this comment

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

I just noticed that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants