Skip to content

Add model package support for sdkv2 - #981

Open
Xiaoyu (xiaoyu-work) wants to merge 6 commits into
mainfrom
xiaoyu/mp
Open

Add model package support for sdkv2#981
Xiaoyu (xiaoyu-work) wants to merge 6 commits into
mainfrom
xiaoyu/mp

Conversation

@xiaoyu-work

Copy link
Copy Markdown

Add model package support for sdkv2

Add package-aware layout handling, loading, cache behavior, and catalog compatibility filtering.
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview Aug 17, 2026 1:10am

Request Review

@xiaoyu-work

Copy link
Copy Markdown
Author

Copilot resolve the merge conflicts in this pull request

# Conflicts:
#	sdk_v2/cpp/src/ep_detection/ep_detector.cc

Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve the merge conflicts in this pull request

Resolved in 2922026 — merged main into xiaoyu/mp, resolved the conflict in ep_detector.cc (kept both GetModelCompatibilityForEpDevices and PrepareForModelLoad), and fixed a dangling-reference build error the merge surfaced in model_load_manager.cc. Verified the C++ SDK builds and unit tests pass.

@xiaoyu-work
Xiaoyu (xiaoyu-work) marked this pull request as ready for review August 12, 2026 05:53
Copilot AI balanced review requested due to automatic review settings August 12, 2026 05:53

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

Adds C++ SDK v2 support for downloading, discovering, filtering, and loading ORT model packages.

Changes:

  • Adds package layout detection and cache handling.
  • Adds package metadata parsing and hardware compatibility filtering.
  • Loads selected package variants through ORT GenAI and expands tests.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk_v2/cpp/CMakeLists.txt Builds the layout classifier.
sdk_v2/cpp/src/util/model_layout.h Declares model layout classification.
sdk_v2/cpp/src/util/model_layout.cc Implements layout detection.
sdk_v2/cpp/src/model.cc Passes catalog EP and task metadata when loading.
sdk_v2/cpp/src/model_info.h Defines typed package metadata.
sdk_v2/cpp/src/model_info.cc Serializes package metadata.
sdk_v2/cpp/src/inferencing/model_load_manager.h Extends the loading interface.
sdk_v2/cpp/src/inferencing/model_load_manager.cc Handles package runtime metadata.
sdk_v2/cpp/src/inferencing/generative/genai_model_instance.h Tracks package and modality state.
sdk_v2/cpp/src/inferencing/generative/genai_model_instance.cc Loads packages through ORT GenAI.
sdk_v2/cpp/src/ep_detection/ep_detector.h Adds compiled-model compatibility APIs.
sdk_v2/cpp/src/ep_detection/ep_detector.cc Evaluates package compatibility.
sdk_v2/cpp/src/download/inference_model_writer.h Documents package marker behavior.
sdk_v2/cpp/src/download/inference_model_writer.cc Retains package root markers.
sdk_v2/cpp/src/download/download_manager.h Updates download workflow documentation.
sdk_v2/cpp/src/download/download_manager.cc Resolves package cache roots.
sdk_v2/cpp/src/catalog/local_model_scanner.h Documents package discovery.
sdk_v2/cpp/src/catalog/local_model_scanner.cc Discovers package roots without scanning variants.
sdk_v2/cpp/src/catalog/azure_model_catalog.h Adds injectable catalog clients.
sdk_v2/cpp/src/catalog/azure_model_catalog.cc Filters incompatible package entries.
sdk_v2/cpp/src/catalog/azure_catalog_models.h Defines catalog package payloads.
sdk_v2/cpp/src/catalog/azure_catalog_models.cc Parses package catalog metadata.
sdk_v2/cpp/test/internal_api/model_load_manager_test.cc Tests package loading behavior.
sdk_v2/cpp/test/internal_api/model_info_test.cc Tests metadata serialization.
sdk_v2/cpp/test/internal_api/local_model_scanner_test.cc Tests package cache discovery.
sdk_v2/cpp/test/internal_api/download_test.cc Tests package download and caching.
sdk_v2/cpp/test/internal_api/catalog_cache_test.cc Tests cached package metadata.
sdk_v2/cpp/test/internal_api/azure_catalog_test.cc Tests parsing and compatibility filtering.
model-package-foundry-local-integration.md Documents the integration design and scope.

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

Comment on lines +239 to +240
const bool is_multimodal =
package_is_multimodal || (genai_config.model && genai_config.model->IsMultiModal()) || IsTaskMultiModal(task);
Comment thread sdk_v2/cpp/src/model.cc
Comment on lines +323 to +328
if (ep == ExecutionProvider::kDefault && !info_.execution_provider.empty()) {
const auto catalog_ep = EPUtils::StringtoEP(info_.execution_provider);
if (catalog_ep != ExecutionProvider::kUnknown) {
ep = catalog_ep;
}
}
@@ -0,0 +1,314 @@
# Model Package Integration into Foundry Local — Scope & Plan

**Status:** Design / scoping (pre-implementation)
Restrict the catalog-task multimodal fallback to model packages so flat ASR
models (e.g. nemotron_speech) are not routed through OgaMultiModalProcessor.

Skip the provider override for kCPU, whose GenAI provider name is empty, so
default-loaded CPU catalog models are not configured with an empty provider.

Move the model package design doc under sdk_v2/cpp/docs and mark Stage 1 as
implemented.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e073a4e1-2902-4111-bb9b-56f152c82527
@xiaoyu-work

Copy link
Copy Markdown
Author

Copilot resolve the merge conflicts in this pull request

# Conflicts:
#	sdk_v2/cpp/src/catalog/azure_model_catalog.cc
#	sdk_v2/cpp/src/catalog/azure_model_catalog.h

Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve the merge conflicts in this pull request

Resolved in 252ecef. Conflicts were in sdk_v2/cpp/src/catalog/azure_model_catalog.{h,cc}: main replaced the catalog-client factory injection with a virtual CreateCatalogClient and split FetchModels into GetLiveCatalogOrLocalSnapshot + AddLocalModels. I kept main's structure and re-applied this branch's model-package compatibility filtering (FilterVisibleInfos) in FetchModels, FetchModelVersions, and FetchModelsByIds; ids of filtered-out catalog models are passed into AddLocalModels so a hidden model that exists on disk isn't resurrected as a synthesized local BYOM entry. The branch's fake-client test now subclasses AzureModelCatalog and overrides CreateCatalogClient.

Verified with python3 build.py --config Debug: build succeeds and unit tests pass, except pre-existing environment-dependent failures (ModelLoadManagerUnloadTest.* need FOUNDRY_TEST_DATA_DIR, CatalogLiveTest.DumpLiveCatalog needs network).

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.

3 participants