Skip to content
This repository was archived by the owner on Sep 30, 2026. It is now read-only.

[xpupti] Report the hardware engine per GPU op via PTI v2 records - #1555

Merged
ryanzhang22 merged 1 commit into
pytorch:mainfrom
intel-staging:dev/adrianos/xpupti-engine-ids
Sep 4, 2026
Merged

ryanzhang22 merged 1 commit into
pytorch:mainfrom
intel-staging:dev/adrianos/xpupti-engine-ids

Conversation

@aostrowski-hbn

@aostrowski-hbn aostrowski-hbn commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Why

Intel GPU traces put one swim lane per SYCL queue. A SYCL queue is a software
queue: the driver maps its operations onto hardware engines, several queues can
share one engine, and a single queue's copies can be spread over several copy
engines. Nothing in the trace says which engine an operation actually ran on, so
two questions users regularly ask cannot be answered from a trace today:

  • Did these two overlapping slices really run concurrently, or are they on the
    same engine with misleading timestamps?
  • Did this copy ride a dedicated copy engine, or the compute engine?

Both matter when judging compute/copy overlap. On parts that expose a single
compute engine, overlapping SYCL-queue lanes do not imply concurrent execution
at all — and there is currently no way to tell that from the trace.

How

PTI 1.0 introduced v2 device activity records (pti_view_record_kernel_v2 and
friends) which extend the v1 layout with the hardware engine an operation ran
on. They are a binary extension of v1, reported under the same view kinds, so
the plugin only changes the record type it casts to — no new view kinds to
enable, no change in collection.

The engine is then emitted as per-op metadata:

  • engine_ordinal — the engine group (compute, copy, …)
  • engine_index — the engine within that group

matching how Level Zero reports command queue groups.

Swim lanes are deliberately left unchanged: still one per SYCL queue, named
Stream <id>, mirroring how CUDA lays out streams.

Alternative considered and rejected: keying swim lanes on the engine

Splitting lanes per hardware engine is worse in both directions:

  • When more than one copy engine is enabled, the Level Zero adapter
    round-robins a single queue's copies across them
    (ur_queue_group_t::getQueueIndex). Measured on Intel Data Center GPU Max
    Series with UR_L0_USE_COPY_ENGINE=0:7: the 32 copies of one in-order
    queue
    landed on 8 different engines — one main copy engine plus seven
    link copy engines. Engine-keyed lanes would shred that single stream across
    eight tracks. (With default settings the same queue stays on a single copy
    engine, so this is configuration-dependent — but the configuration is a plain
    environment variable.)
  • Conversely, on parts that expose a single compute engine, all compute lanes
    collapse into one, merging genuinely distinct queues.

Ordering is preserved either way: even with the copies spread over eight
engines, the trace shows zero overlapping copy slices, because the in-order
queue serialises them. So an engine axis does not buy overlap insight that the
queue axis lacks — which is the other reason to keep it out of the lane key.

Per-op metadata gives the same information without changing the shape of the
trace, and keeps the lane axis (the SYCL queue) the one that actually separates
independent streams of work.

Naming the engine type in the lane label was also dropped: it needs an
additional PTI query and buys nothing once lanes are not engine-keyed.

Tests

XpuptiActivityHandlersTest gains three cases:

  • KernelActivityExposesEngineIds
  • MemoryCopyActivityExposesEngineIds
  • SwimLanesStayPerSyclQueueNotPerEngine — pins the lane behaviour: a kernel and
    a copy on different engines but the same SYCL queue must share one lane,
    named Stream 64.

ZeroDurationMemoryCopyOmitsBandwidth moves to the v2 record type: a hand-built
v1 record would now be read past its end.

Built and ran on Intel Data Center GPU Max Series against PTI 1.2.0 —
XpuptiActivityHandlersTest 13/13 pass.

Note on the minimum PTI version

Building the xpupti plugin now requires PTI 1.0 or newer, which is where the
v2 records were introduced.

Why:
Intel GPU traces show one swim lane per SYCL queue, which does not reveal
which hardware engine an operation actually ran on. Analysing compute/copy
overlap needs that mapping: on platforms that expose a single compute
engine, overlapping SYCL-queue lanes do not imply concurrent execution.

How:
Consume the PTI v2 device activity records (pti_view_record_kernel_v2 and
friends), which extend the v1 layout with the engine an operation ran on,
and emit engine_ordinal/engine_index as per-op metadata. The v2 records are
a binary extension of v1 under the same view kinds, so only the record type
changes. Swim lanes stay one per SYCL queue, named "Stream <id>", to match
how CUDA lays out streams. Building the plugin now requires PTI 1.0 or
newer, which is where the v2 records were introduced.
@meta-cla meta-cla Bot added the cla signed label Sep 1, 2026
@aostrowski-hbn

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "ciflow/xpu"

@aostrowski-hbn

Copy link
Copy Markdown
Contributor Author

@jgong5 @EikanWang @gujinghui — CI is green; requesting an Intel PR approver review for the Draft→Open gate.

@aostrowski-hbn
aostrowski-hbn marked this pull request as ready for review September 4, 2026 07:48
@aostrowski-hbn

Copy link
Copy Markdown
Contributor Author

@ryanzhang22 @scotts please review

@ryanzhang22
ryanzhang22 merged commit 8b682ab into pytorch:main Sep 4, 2026
14 checks passed
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Sep 4, 2026
  Includes the following commits:

  - [xpupti] Report the hardware engine per GPU op via PTI v2 records (pytorch/kineto#1555) 8b682ab
  - [Kineto] Reintroduce Windows timestamp fix in CUPTI test (pytorch/kineto#1556) 95fbe6f
  - [xpupti] Support more than 1 device in ptiMetricsScopeConfigure (pytorch/kineto#1479) 29a6d74
  - [XPUPTI] Fix buffer lifetime and report processed-record stats with some minor improvements. (pytorch/kineto#1553) 33b47f8
  - [XPU] Improve include hygiene in the XPU PTI Kineto plugin (pytorch/kineto#1548) 760cbb0
Pull Request resolved: #196015
Approved by: https://github.com/Skylion007
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
  Includes the following commits:

  - [xpupti] Report the hardware engine per GPU op via PTI v2 records (pytorch/kineto#1555) 8b682ab
  - [Kineto] Reintroduce Windows timestamp fix in CUPTI test (pytorch/kineto#1556) 95fbe6f
  - [xpupti] Support more than 1 device in ptiMetricsScopeConfigure (pytorch/kineto#1479) 29a6d74
  - [XPUPTI] Fix buffer lifetime and report processed-record stats with some minor improvements. (pytorch/kineto#1553) 33b47f8
  - [XPU] Improve include hygiene in the XPU PTI Kineto plugin (pytorch/kineto#1548) 760cbb0
Pull Request resolved: pytorch#196015
Approved by: https://github.com/Skylion007
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants