Skip to content

feat(sysinfo): add ep filter to resolve_device#459

Merged
xieofxie merged 7 commits into
mainfrom
hualxie/fix_perf
May 14, 2026
Merged

feat(sysinfo): add ep filter to resolve_device#459
xieofxie merged 7 commits into
mainfrom
hualxie/fix_perf

Conversation

@xieofxie

@xieofxie xieofxie commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an optional ep keyword to resolve_device. When set, both available_devices and available_eps are narrowed:

  • available_devices is filtered to the device types the EP can target (per _EP_DEVICE_MAP). E.g., ep=\"qnn\" keeps only [\"npu\", \"gpu\"]; ep=\"dml\" keeps only [\"gpu\"].
  • available_eps is filtered to just that EP, intersected with what is actually available on the system.

This lets callers like winml perf --ep qnn --device auto auto-resolve to a sensible device type without considering EPs that won't actually be used.

The new parameter is keyword-only and defaults to None, so existing callers are unchanged.

Tests

New TestResolveDeviceWithEp class covers:

  • ep=\"qnn\" filters available_devices to [\"npu\", \"gpu\"]
  • ep=\"qnn\" on a GPU-only system auto-picks gpu
  • ep=\"dml\" filters to [\"gpu\"] only
  • ep=\"vitisai\" when not actually available → empty available_eps + warning + auto fallback to cpu
  • ep=\"tpu\" (unknown) raises ValueError
  • ep=\"QNN\" (case-insensitive) works
  • ep=\"qnn\" + device=\"cpu\" returns \"cpu\" per user override but with the existing no-compatible-EP warning

Full unit suite: 4643 passed, no regressions.

When ep is set, available_devices is narrowed to the device types the
EP can target (per _EP_DEVICE_MAP) and available_eps is narrowed to
just that EP. This lets callers like 'winml perf --ep qnn --device auto'
resolve to the correct device type without considering EPs that won't
be used.
@xieofxie xieofxie requested a review from a team as a code owner May 7, 2026 06:52
hualxie and others added 4 commits May 7, 2026 15:10
WinMLSession._EP_NAME_MAP and the new _EP_SHORT_TO_FULL in
sysinfo/device.py held the same data. Promote it to a public
EP_SHORT_TO_FULL in sysinfo (the right layer — sysinfo already owns
EP-device knowledge), import it from session.py, and add the missing
CUDAExecutionProvider entry to _EP_DEVICE_MAP for consistency.
Updated 6 sites: config/build.py (x2), commands/config.py, commands/perf.py
(x3). Skipped commands/eval.py (no --ep flag) and analyze/analyzer.py
(ep is the full ORT name there, not the short form resolve_device expects).

Updated test_auto_auto_still_calls_resolve_device assertion for the new
ep=None kwarg.
@xieofxie

xieofxie commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

With this change, --ep cpu will work correct. If without, it will be resolved to qnn + npu for device auto

setup_method now starts a patch that replaces _get_available_eps with a
mock returning frozenset(), and teardown_method stops it. Tests still
override per-call via 'with patch(...)' (patches stack), but the real
function is never reachable from within these test classes.
@xieofxie

xieofxie commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

zheng's pr will address this

@xieofxie xieofxie closed this May 7, 2026
@xieofxie xieofxie reopened this May 14, 2026
@xieofxie xieofxie merged commit 58b49bc into main May 14, 2026
9 checks passed
@xieofxie xieofxie deleted the hualxie/fix_perf branch May 14, 2026 02:51
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.

2 participants