Skip to content

feat(monitor): query all NPU/GPU engines and take max utilization#716

Merged
xieofxie merged 3 commits into
mainfrom
hualxie/multi_pdh
May 25, 2026
Merged

feat(monitor): query all NPU/GPU engines and take max utilization#716
xieofxie merged 3 commits into
mainfrom
hualxie/multi_pdh

Conversation

@xieofxie
Copy link
Copy Markdown
Contributor

@xieofxie xieofxie commented May 25, 2026

Summary

  • PdhPoller previously locked onto a single engine per adapter (first alphabetical Compute* for NPU, 3D for GPU). On NPUs with multiple Compute_* engines, work scheduled to a non-monitored engine read as 0% utilization; on GPUs where DML lands on a Compute engine, the 3D-only query missed the activity entirely.
  • build_adapter_query now takes engine_types: tuple[str, ...] and registers one util_<engtype> + running_time_<engtype> counter per matching engine. build_npu_query covers all Compute_*; build_gpu_query covers both 3D and Compute_*.
  • PdhPoller._poll_loop aggregates samples with max() across util_* keys — each counter is a per-engine ratio over the same sample window, so max reports the most-loaded engine. Summing percentages would exceed 100% on multi-engine adapters and duplicate the signal that running-time already provides.
  • running_time_delta_ns sums per-engine deltas — Running Time is wall-clock ns per engine, and engines are independent HW that can run in parallel, so total adapter compute time is additive.
  • Adapter resolution (resolve_adapter_luid) is untouched; this only changes how counters are registered and aggregated for the resolved adapter.

🤖 Generated with Claude Code

@xieofxie xieofxie requested a review from a team as a code owner May 25, 2026 03:33
@xieofxie
Copy link
Copy Markdown
Contributor Author

Also tested vitisa, migraphx

timenick

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

@timenick timenick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two findings on the multi-engine PDH aggregation: the PR is about aggregation correctness, so I want it pinned by tests and documented for future readers.

Comment thread src/winml/modelkit/session/monitor/_pdh.py
Comment thread src/winml/modelkit/session/monitor/_pdh.py
@xieofxie xieofxie merged commit 8d21fd2 into main May 25, 2026
9 checks passed
@xieofxie xieofxie deleted the hualxie/multi_pdh branch May 25, 2026 05:53
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