Skip to content

WinML2.0 preview samples#634

Open
bmehta001 wants to merge 25 commits into
mainfrom
bhamehta/winml2-preview-samples
Open

WinML2.0 preview samples#634
bmehta001 wants to merge 25 commits into
mainfrom
bhamehta/winml2-preview-samples

Conversation

@bmehta001
Copy link
Copy Markdown
Contributor

@bmehta001 bmehta001 commented Apr 14, 2026

Summary

  • Added WinML 2.0 verify-winml samples in samples/cpp, samples/cs, samples/js, samples/python, and samples/rust, plus sample README/count updates.
  • Added and updated WinML packaging pipeline logic to:
    • package Microsoft.Windows.AI.MachineLearning.dll alongside WinML Core artifacts,
    • write the WinML runtime version into sdk/deps_versions_winml.json, and
    • add sdk/cpp/cmake/FoundryLocalNativeDeps.cmake plus sample-side CMake/vcpkg wiring for C++ WinML native deps.
  • Updated SDK/runtime wiring for the preview stack:
    • C++ manager/catalog/model changes for EP download/discovery and model callback correctness,
    • C# manager/catalog/interop/docs updates for WinML EP flows and shared CoreInterop usage,
    • JS WinML install utilities plus compatibility with older Core binary exports,
    • Python and Rust WinML install/build logic and docs updates.
  • Stabilized JS manager/model tests for slower manager startup and incomplete local test-data.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

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

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment May 22, 2026 11:35pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds WinML 2.0 “preview” verification samples across multiple SDKs and updates the SDKs/pipelines to support execution-provider (EP) discovery + download/registration flows and WinML-targeting changes.

Changes:

  • Add new “verify-winml” samples for C++, C#, Python, JavaScript, and Rust, plus update existing audio transcription samples to align with newer streaming/download APIs.
  • Extend the C++ SDK manager to support EP discovery and EP download/registration with optional progress reporting, and invalidate the catalog cache after EP changes.
  • Update WinML target framework/min-version pins across .NET projects and pipeline build steps; adjust JS WinML installer robustness and fix C# catalog ordering behavior.

Reviewed changes

Copilot reviewed 46 out of 48 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
sdk/python/requirements-winml.txt Formatting fix in WinML Python requirements file.
sdk/js/script/install-winml.cjs Adds more robust logic to locate the SDK root when running the WinML installer script.
sdk/cs/test/FoundryLocal.Tests/Microsoft.AI.Foundry.Local.Tests.csproj Updates WinML target framework/min-version for C# tests.
sdk/cs/test/FoundryLocal.Tests/CatalogTests.cs Adds a test ensuring model listing preserves Core-provided ordering.
sdk/cs/src/Microsoft.AI.Foundry.Local.csproj Updates WinML target framework/min-version for the C# SDK package.
sdk/cs/src/Catalog.cs Preserves Core ordering by tracking models in insertion order rather than sorting by alias.
sdk/cpp/src/foundry_local_manager.cpp Adds EP discovery/download APIs, progress callback wiring, bootstrap auto-setting, and catalog cache invalidation.
sdk/cpp/src/core.h Makes execute_command_with_binary optional and returns a descriptive error for unsupported Core versions.
sdk/cpp/src/catalog.cpp Adds InvalidateCache() to refresh the catalog after EP registration changes.
sdk/cpp/include/foundry_local_manager.h Exposes EP discovery/download result structs and download APIs (with progress callback).
sdk/cpp/include/catalog.h Exposes Catalog::InvalidateCache().
sdk/cpp/CMakeLists.txt Adds ole32 link dependency.
samples/rust/verify-winml/src/main.rs New Rust WinML EP verification sample (discover/register EPs, find accelerated variants, streaming chat check).
samples/rust/verify-winml/README.md Documentation for the new Rust WinML verification sample.
samples/rust/verify-winml/Cargo.toml Cargo manifest for the new Rust sample.
samples/rust/live-audio-transcription/src/main.rs Updates the Rust live audio transcription sample to newer SDK APIs/types.
samples/rust/Cargo.toml Adds live-audio-transcription and verify-winml to the Rust samples workspace members.
samples/README.md Adds a C++ samples row to the “Samples by Language” table.
samples/python/verify-winml/src/app.py New Python WinML EP verification script.
samples/python/verify-winml/requirements.txt Adds a WinML-flavored Python SDK dependency for the new sample.
samples/python/verify-winml/README.md Documentation for the new Python WinML verification sample.
samples/js/verify-winml/README.md Documentation for the new JS WinML verification sample.
samples/js/verify-winml/package.json New JS WinML verification sample package with postinstall WinML setup.
samples/js/verify-winml/app.js New JS WinML EP verification script.
samples/cs/verify-winml/VerifyWinML.csproj New C# WinML EP verification sample project.
samples/cs/verify-winml/README.md Documentation for the new C# WinML verification sample.
samples/cs/verify-winml/Program.cs New C# WinML EP verification program.
samples/cs/tutorial-voice-to-text/TutorialVoiceToText.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/tutorial-tool-calling/TutorialToolCalling.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/tutorial-document-summarizer/TutorialDocumentSummarizer.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/tutorial-chat-assistant/TutorialChatAssistant.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/tool-calling-foundry-local-web-server/ToolCallingFoundryLocalWebServer.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/tool-calling-foundry-local-sdk/ToolCallingFoundryLocalSdk.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/nuget.config Formatting/newline normalization.
samples/cs/native-chat-completions/NativeChatCompletions.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/model-management-example/ModelManagementExample.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/live-audio-transcription/LiveAudioTranscriptionExample.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/foundry-local-web-server/FoundryLocalWebServer.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/embeddings/Embeddings.csproj Updates Windows target framework version for WinML acceleration.
samples/cs/Directory.Packages.props Pins Microsoft.AI.Foundry.Local.Core.WinML to 1.0.0 for samples.
samples/cs/audio-transcription-example/AudioTranscriptionExample.csproj Updates Windows target framework version for WinML acceleration.
samples/cpp/verify-winml/README.md Documentation for the new C++ WinML verification sample.
samples/cpp/verify-winml/main.cpp New C++ WinML EP verification sample implementation.
samples/cpp/verify-winml/CMakeLists.txt CMake project for building the new C++ verify-winml sample.
samples/cpp/live-audio-transcription/README.md Switches build instructions to CMake and documents runtime/native DLL placement.
samples/cpp/live-audio-transcription/main.cpp Improves model alias handling and error messaging for missing live-audio model.
samples/cpp/live-audio-transcription/CMakeLists.txt Adds a CMake project for the C++ live-audio-transcription sample.
.pipelines/templates/build-core-steps.yml Updates WinML build/test/publish TFMs used by the pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/cpp/src/foundry_local_manager.cpp Outdated
Comment thread sdk/cpp/src/catalog.cpp Outdated
Comment thread samples/cs/verify-winml/VerifyWinML.csproj
Comment thread samples/python/verify-winml/src/app.py
Comment thread samples/rust/verify-winml/Cargo.toml Outdated
Comment thread samples/README.md Outdated
Only read FOUNDRY_WINDOWS_AI_MACHINELEARNING_VERSION when --winml is enabled so a globally-set environment variable does not break standard installs.

Co-authored-by: Copilot <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 74 out of 74 changed files in this pull request and generated 1 comment.

Comment thread sdk/python/src/detail/utils.py Outdated
- Python: prefer exact filename matches in _find_file_in_package and rename the WinML runtime temp file so a leftover .tmp (from an interrupted install) cannot be mistaken for the real DLL by the fuzzy *filename* glob; mark the success path explicitly so the temp cleanup only runs on failure.

- C++: skip DirectML.dll during the WinML copy loop instead of copying it and then removing it post-build.

Co-authored-by: Copilot <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 74 out of 74 changed files in this pull request and generated 2 comments.

Comment thread sdk/rust/build.rs Outdated
Comment thread sdk/rust/build.rs
- Drop always_extract: true on Microsoft.ML.OnnxRuntime.Foundry in the WinML build path. The WinML runtime NuGet (always_extract: true) still re-extracts every build to keep packages_require_extraction true and overwrite any stale runtime DLL; ORT itself doesn't need to redownload on every build.

- Make DirectML.dll cleanup best-effort with a cargo warning instead of expect()/panic, so a locked DLL (common on Windows when a prior process still holds a handle) doesn't fail the entire build script.

- samples/README.md: correct C# sample count (13, not 14).

Co-authored-by: Copilot <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 74 out of 74 changed files in this pull request and generated no new comments.

Comment thread sdk/deps_versions_winml.json Outdated
Comment thread sdk/rust/README.md Outdated
- Revert C# catalog ordering change (preserve-Core-order) and its test. The change is preserved on branch bhamehta/cs-catalog-preserve-order for a future PR.

- sdk/deps_versions_winml.json: revert foundry-local-core nuget/python versions back to 1.1.0 since they are overridden in CI.

- Rename FOUNDRY_WINDOWS_AI_MACHINELEARNING_VERSION to FOUNDRY_LOCAL_WINDOWS_AI_MACHINELEARNING_VERSION for consistency with the FOUNDRY_LOCAL_ prefix convention. Updates all SDKs (Python, Rust, JS, C++ CMake) and their READMEs.

Co-authored-by: Copilot <[email protected]>
Per offline guidance, the C++ SDK will be replaced shortly, so this PR no longer changes any sdk/cpp/* files. Revert all sdk/cpp/* edits to match origin/main, drop the WinML-specific CMake module, and remove the C++ verify-winml sample (which depended on those SDK changes via add_subdirectory). The pre-existing samples/cpp/live-audio-transcription sample is untouched, and the C++ row in samples/README.md is removed since this PR no longer contributes new C++ samples.

Co-authored-by: Copilot <[email protected]>
Five files revert to origin/main since their changes are not required by the WinML 2.0 preview samples work:

- sdk/js/native/foundry_local_napi.c: the optional execute_command_with_binary fix targeted Microsoft.AI.Foundry.Local.Core.WinML 1.0.0 (which omitted the symbol). The PR now pins to 1.1.0, which exports it, so the fix is dead code. The accompanying ~225-line refactor is unrelated cleanup.

- sdk/js/test/foundryLocalManager.test.ts, sdk/js/test/model.test.ts: hoist getTestManager() into before hooks, raise the suite timeout, and add skip-if-cached-models-missing logic. General test hygiene, unrelated to WinML 2.0.

- samples/js/copilot-sdk-foundry-local/src/app.ts: comment wording change in a sample that does not use WinML.

- samples/cs/Directory.Packages.props: restore Betalgo.Ranul.OpenAI 9.2.0. Verified locally that 9.2.0 restores cleanly on net9.0-windows10.0.18362.0; the earlier downgrade was incidental.

Co-authored-by: Copilot <[email protected]>
samples/cpp/live-audio-transcription already exists on main but is missing from the per-language sample table. Add a one-line row so the table is consistent with the other languages.

Co-authored-by: Copilot <[email protected]>
bmehta001 and others added 3 commits May 22, 2026 10:02
DownloadProgressCallback has been std::function<bool(float percentage)> since PR #683 (Cross Platform C++ SDK), but the lambda example in the README still doesn't return a value, so the example fails to compile. Add an explicit return true to follow the cancellation API contract (return true to continue, false to cancel).

Co-authored-by: Copilot <[email protected]>
If the foundry-local-core-winml wheel ships a well-formed payload, the bundled Microsoft.Windows.AI.MachineLearning.dll lives in the same directory as Microsoft.AI.Foundry.Local.Core.dll. os.add_dll_directory(core_dir) already covers it, so the dedicated winml_runtime field on NativeBinaryPaths and the matching branch in get_native_binary_paths() were always a no-op for DLL loading and only added a fail-fast verification for a scenario the upstream pipelines do not produce.

Remove the field, the branch in all_dirs(), and the CLI's 'missing WinML runtime' detection. Keep the --verbose 'WinML   : <path>' print as an inline _find_file_in_package() lookup so the dynamic --winml-runtime-version override still shows the resolved path.

_install_winml_runtime_from_nuget(), --winml-runtime-version, FOUNDRY_LOCAL_WINDOWS_AI_MACHINELEARNING_VERSION, the exact-match-first preference in _find_file_in_package, and the .winml-runtime- temp prefix are unchanged.

Co-authored-by: Copilot <[email protected]>
The Python CLI runtime-version override was an opt-in mechanism to swap Microsoft.Windows.AI.MachineLearning.dll for a specific NuGet version after pip install. Removing it for now since no in-repo CI/sample/test exercises it, the equivalent install-time overrides on JS and Rust (FOUNDRY_LOCAL_WINDOWS_AI_MACHINELEARNING_VERSION env var) are still available, and foundry-local-install itself is a dev/CI helper with no current consumers in this repo. If we revisit the dynamic override in the future it can land in its own focused PR with an end-to-end test.

Net effect: sdk/python/src/detail/utils.py reverts to origin/main.

Co-authored-by: Copilot <[email protected]>
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