Skip to content

fix(sysinfo): raise on explicit device with no compatible EP (#431)#660

Merged
timenick merged 1 commit into
mainfrom
zhiwang/fix-issue-431-resolve-device-raise
May 19, 2026
Merged

fix(sysinfo): raise on explicit device with no compatible EP (#431)#660
timenick merged 1 commit into
mainfrom
zhiwang/fix-issue-431-resolve-device-raise

Conversation

@timenick
Copy link
Copy Markdown
Collaborator

Closes #431.

Summary

  • winml config --device npu previously logged a warning and exited 0 with an unusable config when no NPU EP (QNN / VitisAI / OpenVINO) was advertised. The failure surfaced later at compile/inference time, far from the misconfiguration.
  • resolve_device() now raises ValueError for explicit device requests with no compatible EP. commands/config.py and commands/build.py already route ValueError to click.UsageError → non-zero exit with a clean message naming the missing EPs.
  • --device auto is unchanged: it still walks the priority list and falls through to GPU/CPU when an NPU EP is missing (acceptance criterion 3).

Before / after

Before (on a box with NPU silicon but no QNN/VitisAI/OpenVINO):

$ winml config -m microsoft/resnet-50 --device npu --precision int8 -o out.json
WARNING - Device 'npu' requested but no compatible EP found. ...
✅ Config saved to: out.json       ← exit 0, but the config is unusable

After:

$ winml config -m microsoft/resnet-50 --device npu --precision int8 -o out.json
Error: Device 'npu' requested but no compatible EP is available.
Compatible EPs: ['VitisAIExecutionProvider', 'QNNExecutionProvider', 'OpenVINOExecutionProvider'].
Available EPs: ['CPUExecutionProvider', 'DmlExecutionProvider'].
$ echo $?
2

Previously `resolve_device("npu")` logged a warning and returned the
requested device anyway when no NPU EP (QNN/VitisAI/OpenVINO) was
advertised. Callers happily wrote a config naming an unavailable EP,
turning a recoverable misconfiguration into a confusing compile/inference
failure later.

For explicit device requests (non-``auto``), raise ``ValueError`` instead
so ``winml config --device npu ...`` exits non-zero with a message naming
the EPs the user needs to install. The existing ``except ValueError`` in
``commands/config.py`` and ``commands/build.py`` already routes this to a
clean ``click.UsageError`` — no caller changes required.

``--device auto`` is intentionally unchanged: it walks the priority list
and falls through to GPU/CPU when an NPU EP is missing.
@timenick timenick requested a review from a team as a code owner May 19, 2026 03:56
@timenick timenick merged commit 1e55d53 into main May 19, 2026
9 checks passed
@timenick timenick deleted the zhiwang/fix-issue-431-resolve-device-raise branch May 19, 2026 05:45
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.

fix: winml config --device npu silently succeeds when no NPU EP is available

2 participants