Skip to content

feat: ORT GenAI Stateful Compilation changes #676

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

Open
wants to merge 1 commit into
base: ovep-develop
Choose a base branch
from

Conversation

ankitm3k
Copy link

Description

This PR enables the essential features to enable ORT GenAI with OVEP using Stateful Compilation of ov::Model, inspired from OV GenAI pipeline flow.

I have introduced a new provider option enable_causallm which can be set to True for enabling the ORT GenAI pipeline with Causal LLM Models that are fully supported on OVEP in the custom config file called genai_config.json

Sample genai_config.json -

"provider_options": [
    {
         // Key "OpenVINO" is case sensitive and must be used as below as its defined by MSFT
         "OpenVINO":
          {
              "device_type": "NPU",
              "enable_causallm" : "True",
              // (Applicable for NPU only) Optional setting for compilation with custom MAX_PROMPT_LEN & MIN_RESPONSE_LEN
              "load_config": "{\"NPU\":{\"MAX_PROMPT_LEN\":\"2048\",\"MIN_RESPONSE_LEN\":\"512\"}}"                            
                       
           }
    }
    ]

FYI the GenAI models in ONNX format are usually Stateless in nature & require dynamic shapes compilation.

@ankitm3k ankitm3k requested review from sfatimar and vthaniel April 25, 2025 07:53
@ankitm3k ankitm3k self-assigned this Apr 25, 2025
@ankitm3k ankitm3k requested a review from jatinwadhwa921 April 25, 2025 09:06
// For Stateful Model Compilation, the ONNX model includes KV cache (past/present) tensors.
// However, these tensors are internally converted to a stateful representation, which removes them.
// To prevent runtime exceptions, we simply continue processing here.
if (input_name.empty() || input_name == "beam_idx") continue;

Choose a reason for hiding this comment

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

Is the name "beam_idx" particular to LLM model? It looks like a custom check

Copy link
Author

@ankitm3k ankitm3k Apr 25, 2025

Choose a reason for hiding this comment

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

yes its a input name which is a part of ov::model which gets created as a part of translation. It required for OV LLMCOmpilation & inference pipeline. Its model agnostic

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.

2 participants