fix(session): suppress VerifyEachNodeIsAssignedToAnEp warning for explicit EP#571
Open
DingmaomaoBJTU wants to merge 1 commit into
Open
fix(session): suppress VerifyEachNodeIsAssignedToAnEp warning for explicit EP#571DingmaomaoBJTU wants to merge 1 commit into
DingmaomaoBJTU wants to merge 1 commit into
Conversation
…licit EP Two changes to _build_session_options: 1. Remove no-ep discovery path (added in ef2db0b). When no --ep is given, the intent is "prefer this device" — policy-based selection (set_provider_selection_policy) is the right abstraction. Using add_provider_for_devices in this path triggered VerifyEachNodeIsAssignedToAnEp because shape ops fell back to CPU without CPU being a registered provider. 2. For the explicit EP path, register CPUExecutionProvider as a second provider after the primary EP. Shape-related ops are intentionally assigned to CPU by ORT even when targeting NPU/GPU; registering CPU explicitly gives those nodes a valid home and silences the warning without suppressing ORT logs globally. Also removes test_device_only from TestFindEpDevice — the device-only call path (_find_ep_device with ep_name=None and a concrete device) no longer has a production caller after the no-ep discovery block is removed. TODO: re-verify once zheng's PR is merged, in case upstream ORT changes affect how add_provider_for_devices interacts with CPU fallback.
xieofxie
reviewed
May 15, 2026
| _eps_initialized: bool = False | ||
|
|
||
| # EP short name -> ORT full provider name (for add_provider_for_devices matching) | ||
| _EP_NAME_MAP: ClassVar[dict[str, str]] = { |
Contributor
There was a problem hiding this comment.
use definition from constant.py
xieofxie
reviewed
May 15, 2026
| # Register CPU as explicit fallback so shape-related ops | ||
| # have a registered home and VerifyEachNodeIsAssignedToAnEp | ||
| # does not warn about unassigned nodes. | ||
| cpu_dev = self._find_ep_device(ep_name="CPUExecutionProvider", device="cpu") |
Contributor
There was a problem hiding this comment.
maybe only change this line only
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.
Problem
winml perf -m microsoft/resnet-50 --device npu --iterations 100emits a yellow ORT warning:Root cause
Two issues introduced in #404 and #440:
Issue 1 — no-ep discovery path used
add_provider_for_devices.When no
--epflag is given,ef2db0badded an EP discovery step that calledadd_provider_for_devices([matched])with a single EP device. Any node that couldn't run on that EP (e.g. shape ops on NPU) fell back to CPU without CPU being a registered provider, triggeringVerifyEachNodeIsAssignedToAnEp.Issue 2 — explicit EP path registers only one provider.
When
--device npuis used, the build config always setsresolved_ep="qnn", so the session always hits the explicit EP path.6b8b004correctly narrowed_find_ep_deviceto return QNN-on-NPU (instead of QNN-on-CPU as before). But with only QNN-on-NPU registered, shape ops have no registered home when they fall back to CPU → warning fires.Fix
Remove no-ep discovery block. Without
--ep, fall straight toset_provider_selection_policy(PREFER_*). This is the correct abstraction when the user's intent is "prefer this device", not "use this exact EP".Register CPU as explicit fallback in the explicit EP path. After registering the primary EP via
add_provider_for_devices, also registerCPUExecutionProvider. Shape-related ops assigned to CPU now have a valid registered provider, silencing the warning without touching log severity levels.Note
TODO: re-verify once zheng's PR is merged — upstream ORT changes may affect how
add_provider_for_devicesinteracts with CPU fallback registration.