Skip to content

js: add foundry-local-sdk-winml SKU mirroring the python wheel pattern#804

Draft
bmehta001 wants to merge 1 commit into
bhamehta/flcore/winml-2-ep-downloadsfrom
bhamehta/flcore/js-winml-sku
Draft

js: add foundry-local-sdk-winml SKU mirroring the python wheel pattern#804
bmehta001 wants to merge 1 commit into
bhamehta/flcore/winml-2-ep-downloadsfrom
bhamehta/flcore/js-winml-sku

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

Summary

Adds a Windows-only foundry-local-sdk-winml npm package so JS callers can install WinML EP support out of the box, mirroring the existing python wheel pattern (foundry-local-sdk vs foundry-local-sdk-winml).

Why

The standard foundry-local-sdk npm tarball ships foundry_local.dll alone. The WinML 2.x bootstrapper's LoadLibraryW("Microsoft.Windows.AI.MachineLearning.dll") therefore failed silently on JS callers — they only ever saw CUDA + WebGPU, never OpenVINO / NvTensorRTRTX. The vitest discoverEps test only asserts shape (Array.isArray(eps) === true), not contents, so this gap was never caught in CI.

The python wheel has had this split for a while (foundry-local-sdk vs foundry-local-sdk-winml); this PR brings the JS SDK to parity.

What changes

File Change
steps-build-js.yml New isWinML parameter. When true, stages Microsoft.Windows.AI.MachineLearning.dll next to foundry_local.dll in prebuilds/<plat>-<arch>/. WinML DLL is signed by Microsoft via NuGet — intentionally excluded from the ESRP signing pattern (no re-sign).
steps-pack-js.yml New isWinML parameter. Rewrites the package name to foundry-local-sdk-winml via npm pkg set name=... before npm pack; restricts the prebuilds-source list to win-x64 + win-arm64.
stages-js.yml Refactored to take variant: base | winml. Base = existing 4-platform stages (unchanged). WinML = new js_build_winml_win_x64, js_build_winml_win_arm64, js_test_winml_win_x64, js_pack_winml consuming cpp-native-win-*-winml artifacts, producing js-prebuild-winml-win-* + js-sdk-winml.
stages-sdk-v2.yml Invoke stages-js.yml twice (base + winml), matching the C# and Python coordinators.
sdk_v2/js/README.md Document the two SKUs at the top, mirroring the python README's variant table.

Distribution flow

Standard SKU WinML SKU
Package name foundry-local-sdk foundry-local-sdk-winml
Platforms win-x64, win-arm64, linux-x64, osx-arm64 win-x64, win-arm64 (build-only on arm64)
Bundled DLLs (per platform) foundry_local.dll (size unchanged) foundry_local.dll + Microsoft.Windows.AI.MachineLearning.dll (~922 KB)
Install-time downloads (install-native.cjs) ORT + GenAI from NuGet (~91 MB) ORT + GenAI from NuGet (~91 MB)
EPs discovered out of the box CUDA + WebGPU CUDA + WebGPU + OpenVINO + NvTensorRTRTX

The WinML DLL is small enough (~922 KB) to bundle inline — no install-time network hop for WinML. ORT/GenAI are still NuGet-downloaded at install time for both SKUs.

Pairs with

This PR is stacked on top of #788 (WinML 2.x EP downloads). Specifically the fix at 01a2725 (winml: load WinML DLL from foundry_local.dll's own directory), which makes the WinML bootstrapper resolve Microsoft.Windows.AI.MachineLearning.dll relative to foundry_local.dll's own directory via GetModuleHandleExW + LoadLibraryExW(LOAD_WITH_ALTERED_SEARCH_PATH). Without that fix the WinML DLL would not be found at runtime even when bundled next to foundry_local.dll.

When #788 merges, this PR's base should be re-pointed to main.

Validation

  • All four YAML files parse via yaml.safe_load.
  • npm pkg set name=foundry-local-sdk-winml + npm pkg get name verified locally (mechanism is idempotent; package.json round-trips cleanly back to foundry-local-sdk).
  • The new stage layout mirrors the existing stages-python.yml variant pattern exactly — same base | winml if-block split and same artifact-name convention.

End-to-end verification (the WinML JS tarball returns 4 EPs) will happen on the first pipeline run after this PR's CI. Locally, the same code path was verified in #788 via npm run copy-native:dev (which already bundles the WinML DLL) — the new pipeline staging matches the dev script's layout byte-for-byte.

Out of scope

  • No public API changes.
  • install-native.cjs unchanged. The WinML DLL is bundled at pack time, not downloaded at install time.
  • copy-native.mjs (dev-only) unchanged — it already includes the WinML DLL for local testing.
  • pack-prebuilds.mjs (not used by the pipeline) unchanged.

The standard `foundry-local-sdk` npm package ships `foundry_local.dll`
alone, so JS callers who installed from npm only ever saw the CUDA + WebGPU
execution providers — the WinML 2.x bootstrapper's `LoadLibraryW` call for
`Microsoft.Windows.AI.MachineLearning.dll` would silently fail (the DLL
was not in the tarball). This mirrors the same gap the python wheel solved
by publishing a separate `foundry-local-sdk-winml` package.

Add a Windows-only WinML SKU built from the existing
`cpp-native-win-x64-winml` / `cpp-native-win-arm64-winml` pipeline
artifacts:

- `steps-build-js.yml`: new `isWinML` parameter; when true, also stage
  `Microsoft.Windows.AI.MachineLearning.dll` next to `foundry_local.dll`
  in `prebuilds/<plat>-<arch>/`. The WinML DLL is signed by Microsoft via
  NuGet, so it is intentionally excluded from the ESRP signing pattern.
- `steps-pack-js.yml`: new `isWinML` parameter; rewrites the package
  name to `foundry-local-sdk-winml` via `npm pkg set name=...` before
  `npm pack`, and restricts the prebuilds-source list to win-x64 +
  win-arm64. Mirrors python's `FL_PYTHON_PACKAGE_NAME` mechanism but uses
  npm's first-class JSON editor instead of a PEP-517 shim.
- `stages-js.yml`: refactor to take a `variant: base | winml` parameter
  (mirroring `stages-python.yml`). Base = existing 4-platform stages.
  WinML = new `js_build_winml_win_x64`, `js_build_winml_win_arm64`,
  `js_test_winml_win_x64`, `js_pack_winml` stages consuming the
  `cpp-native-win-*-winml` artifacts and producing
  `js-prebuild-winml-win-*` + `js-sdk-winml`.
- `stages-sdk-v2.yml`: invoke `stages-js.yml` twice (base + winml),
  matching the C# and Python coordinators.
- `sdk_v2/js/README.md`: document the two SKUs at the top, mirroring the
  python README's variant table.

The WinML DLL (~922 KB) is bundled in the tarball because it is small
enough to ship inline and avoids any install-time network hop for WinML
support. `install-native.cjs` is unchanged — it still downloads ORT +
GenAI at install time for both SKUs.

This commit pairs with 01a2725 ("winml: load WinML DLL from foundry_local.dll's own directory")
from the WinML 2.x EP downloads PR. With that fix + this packaging change,
`npm install foundry-local-sdk-winml` returns all four execution providers
(CUDA, WebGPU, OpenVINO, NvTensorRTRTX) out of the box.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vercel

vercel Bot commented Jun 15, 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, Comment Jun 15, 2026 8:01pm

Request Review

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.

1 participant