Skip to content

fix(build): forward --ep; require explicit device + ep in resolve_device#947

Draft
xieofxie wants to merge 3 commits into
mainfrom
hualxie/build_forward_ep
Draft

fix(build): forward --ep; require explicit device + ep in resolve_device#947
xieofxie wants to merge 3 commits into
mainfrom
hualxie/build_forward_ep

Conversation

@xieofxie

@xieofxie xieofxie commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Two related fixes around EP handling, after winml build -m ... --ep openvino --device npu --compile silently ignored --ep.

1. winml build dropped --ep

The build command passed only device/precision to generate_build_config — never ep — so the requested EP never reached config generation. Now ep is forwarded.

2. resolve_device made device + ep both required, and all callers fixed

resolve_device(device, *, ep) previously defaulted device="auto" (and ep had recently become required, leaving several callers passing neither — latent TypeErrors, plus 8 failing test_device.py tests). Both are now required, so an omission is a call error instead of a silent ep=None / device="auto". This is the root-cause class behind bug #931 / the build drop: implicit EP resolution.

Callers that relied on the old defaults now pass ep=None explicitly where no EP filter is intended:

  • analyzer auto-device resolution (rule-file selection)
  • build's ep is None auto-EP resolution
  • eval device resolution
  • compile-stage device resolution (the EP comes from ep_config)
  • test_device.py call sites

Notes

An earlier iteration of this branch added a compile-availability gate + an optimize-stage tweak; those were reverted in favor of the centralized signature enforcement above, which is cleaner and catches the whole class of bug at the boundary.

Verification

  • winml build --ep openvino --device npu --compile now consults the EP (fails on absent NPU, as expected) instead of silently ignoring --ep.
  • Full suites green: tests/unit/{commands,sysinfo,compiler,analyze,config} (2500+ passed). 3 new build tests + the test_device.py call sites updated.

Related: #931 (fixed in #941).

…ilability

`winml build` dropped --ep when auto-generating a config — it passed only
device/precision to generate_build_config, so the requested EP never reached
config generation. With an explicit --device that isn't present, config gen then
resolved the device with ep=None and failed immediately with a device-availability
error, silently ignoring --ep
(e.g. `winml build -m microsoft/resnet-50 --ep openvino --device npu --compile`).

- Forward `ep` into generate_build_config so the EP shapes the generated config.
- Add an early, compile-gated EP-availability check after config validation: a
  compile build physically instantiates the EP, so an unavailable EP/device now
  fails fast (before export) instead of deep in the compile stage. A no-compile
  build only produces a portable, analyzed ONNX and may target a device absent on
  the build machine (cross-compile), so it is allowed to proceed.
- Stop the optimize-stage device resolution from availability-failing: it only
  needs a concrete device name for the analyzer's rule-data lookup, so it no
  longer passes ep or rejects an absent explicit device.

Verified end-to-end: `--compile --device npu --ep openvino` (no NPU) now fails
before export with the EP respected; `--no-compile` proceeds to export the
portable model.

Related to the EP-threading family (#931).
@xieofxie xieofxie requested a review from a team as a code owner June 23, 2026 08:34
@xieofxie xieofxie marked this pull request as draft June 23, 2026 09:18
resolve_device(device, *, ep) now takes both device and ep as required args, so
an omission is a call error instead of a silent ep=None / device="auto". Several
callers still relied on the old defaults (latent TypeErrors) — pass ep=None
explicitly where no EP filter is intended:

- analyzer: auto-device resolution for rule-file selection
- build: the ep-is-None auto-EP resolution
- eval: device resolution
- compile stage: device resolution (EP comes from ep_config)
- test_device.py: resolve_device call sites

Also keeps the build command forwarding --ep to generate_build_config, and drops
the compile-availability gate / optimize-stage tweak from earlier on this branch
— requiring explicit device+ep is the cleaner, centralized enforcement.
@xieofxie xieofxie changed the title fix(build): forward --ep to config generation; gate compile builds on EP availability fix(build): forward --ep; require explicit device + ep in resolve_device Jun 23, 2026
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