Skip to content

Feature/openvino model package - #2717

Open
Preetha Veeramalai (preetha-intel) wants to merge 4 commits into
microsoft:mainfrom
preetha-intel:feature/openvino-model-package
Open

Preetha Veeramalai (preetha-intel) wants to merge 4 commits into
microsoft:mainfrom
preetha-intel:feature/openvino-model-package

Conversation

@preetha-intel

Copy link
Copy Markdown

Adds an Olive pass that compiles an ONNX model into per-device OpenVINO NPU EPContext variants and assembles an ONNX Runtime .ortpackage. Weights are stored once as a shared asset and referenced by every variant.

  • Compile mode (per target_devices) and package_only mode (assemble from pre-compiled ctx models)
  • Fails if any requested device fails to compile (allow_partial_package to opt out)
  • Safe EP register/unregister lifecycle; preserves external-data paths
  • Docs (docs/README_OpenVINO.md) + example config + unit tests
  • Targets ORT's OrtModelPackageApi loader (distinct from olive generate-model-package).

Copilot AI balanced review requested due to automatic review settings October 6, 2026 16:07
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Copilot review overview

🟡 Changes recommended

Unresolved path-safety, registration-lifecycle, and package-completeness issues can cause unsafe or unusable output.

Review effort: Balanced
Findings: 2 High severity · 6 Medium severity

Open (8)
What changed in this PR

Adds OpenVINO model packaging for ONNX Runtime’s OrtModelPackageApi, with per-device variants and shared weights.

Changes:

  • Supports compilation and packaging of precompiled models.
  • Extends EPContext generation with OpenVINO plugin support.
  • Adds pass registration, configuration examples, documentation, and tests.
File Description
test/​passes/​openvino/​test_openvino_model_package.py Tests packaging and registration behavior.
olive/​passes/​openvino/​model_package.py Implements compilation, asset staging, and manifests.
olive/​passes/​openvino/​examples/​model_package_config_template.json Provides an example workflow.
olive/​passes/​onnx/​context_binary.py Adds OpenVINO compilation and plugin registration handling.
olive/​olive_config.json Registers the pass and supported providers.
docs/​README_OpenVINO.md Documents configuration, usage, and package format.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread olive/passes/onnx/context_binary.py Outdated
Comment thread olive/passes/openvino/model_package.py Outdated
Comment thread olive/passes/openvino/model_package.py
Comment thread olive/passes/openvino/model_package.py
Comment thread olive/passes/openvino/model_package.py Outdated
Comment thread olive/passes/openvino/model_package.py Outdated
Comment thread olive/passes/openvino/model_package.py Outdated
Comment thread olive/passes/openvino/model_package.py Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Preetha Veeramalai (@preetha-intel) . Can you please fix the below suggestions.
Also, overall guidance was to hold off merging this PR till Model Packaging support becomes a stable ABI, which is expected to be soon.

Comment thread docs/README_OpenVINO.md Outdated
Comment thread docs/README_OpenVINO.md Outdated
Comment thread docs/README_OpenVINO.md Outdated
Comment thread docs/README_OpenVINO.md Outdated
Comment thread olive/passes/onnx/context_binary.py
Comment thread olive/passes/openvino/examples/model_package_config_template.json Outdated
Comment thread olive/passes/openvino/examples/model_package_config_template.json Outdated
Comment thread olive/passes/onnx/context_binary.py
Comment thread docs/README_OpenVINO.md Outdated
Comment thread olive/passes/openvino/model_package.py Outdated
Comment on lines 172 to 176
if version.parse(OrtVersion).release <= version.parse("1.23.2").release:
assert self.accelerator_spec.execution_provider in get_available_providers(), (
f"Execution provider {self.accelerator_spec.execution_provider} is not available. Available providers:"
f" {get_available_providers()}"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do you need this check for your logic?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No — this check isn't needed for the OpenVINO logic. The OpenVINO path returns via _run_openvino before this block, so it never executes it. The check is existing QNN code, unchanged from main, so I've left it as is. Happy to have the QNN owners decide whether it's still needed.

@xiaoyu-work Xiaoyu Z (xiaoyu-work) Oct 13, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what i mean is does openvino need if version.parse(OrtVersion).release <= version.parse("1.23.2").release: this ort version check?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Xiaoyu Z (@xiaoyu-work) The <= 1.23.2 check is QNN-only (existing code, unchanged from main, now in _run_qnn). OpenVINO doesn't need it: _run_openvino returns before this block. The OpenVINO minimum (ORT >= 1.30) is enforced separately in OpenVINOModelPackage._check_ort_version for the model-package pass.

Comment thread olive/passes/onnx/context_binary.py Outdated
}


class OpenVINOModelPackage(Pass):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'm a little bit confused about this pass. we have a CLI generate-model-package to generate a model package. I'd like to split this into 2 steps: EPContextBinaryGenerator and generate model package. the generating model package logic should be generic and all other ep can use it as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this pass only create npu package? if we want to add support for cpu, gpu as well to ort-package. will this pass work? that's why i'm thinking having a generic packaging logic will be better here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The CLI generate-model-package is a GenAI specific model packaging which manually creates the manifest.json and component.json. But the OpenVINOModelPackage builds the package through ORT's ort.ModelPackage API. ORT owns the manifest, component and variant metadata, and the shared-asset hashing and URI.

I agree the packaging should be generic, and it already is in the pass. The ort.ModelPackage calls don't depend on OpenVINO, and only discovery and compile are OpenVINO-specific. Splitting it by moving the ORT-API packaging out of this pass can be done as the follow up once other EP's also want to accomodate the Olive but the CLI's GenAI packaging and the pass's ORT packaging are two different formats, so it can't be one generic CLI path without making it a different mode.

Comment thread olive/passes/openvino/examples/model_package_config_template.json Outdated
@xiaoyu-work

Copy link
Copy Markdown
Member

I've moved the context binary logic into #2732. can you check this pr?

This branch has not been deployed

No deployments
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.

5 participants