feat(sysinfo): add ep filter to resolve_device#459
Merged
Conversation
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.
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.
Contributor
Author
|
With this change, |
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.
Contributor
Author
|
zheng's pr will address this |
DingmaomaoBJTU
approved these changes
May 14, 2026
DingmaomaoBJTU
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an optional
epkeyword toresolve_device. When set, bothavailable_devicesandavailable_epsare narrowed:available_devicesis 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_epsis filtered to just that EP, intersected with what is actually available on the system.This lets callers like
winml perf --ep qnn --device autoauto-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
TestResolveDeviceWithEpclass covers:ep=\"qnn\"filters available_devices to[\"npu\", \"gpu\"]ep=\"qnn\"on a GPU-only system auto-picksgpuep=\"dml\"filters to[\"gpu\"]onlyep=\"vitisai\"when not actually available → empty available_eps + warning + auto fallback to cpuep=\"tpu\"(unknown) raisesValueErrorep=\"QNN\"(case-insensitive) worksep=\"qnn\" + device=\"cpu\"returns\"cpu\"per user override but with the existing no-compatible-EP warningFull unit suite: 4643 passed, no regressions.