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

[XPUPTI] Fix buffer lifetime and report processed-record stats with some minor improvements. - #1553

Merged
ryanzhang22 merged 2 commits into
pytorch:mainfrom
intel-staging:dev/tsocha/xpupti-fix
Sep 2, 2026
Merged

ryanzhang22 merged 2 commits into
pytorch:mainfrom
intel-staging:dev/tsocha/xpupti-fix

Conversation

@tsocha

@tsocha tsocha commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Port the CUPTI completed-buffer fix to the XPU plugin: activityBuffers() now returns already-completed buffers when nothing is in flight, clearActivities() drops them on the early-return path, and bufferCompleted() rejects unknown buffer pointers instead of dereferencing an invalid map iterator.

Replace processActivities()' std::pair<int, int> return with a named ActivitiesStats struct and log the record count/byte total, wiring up LOGGER_OBSERVER_ADD_EVENT_COUNT which XPU never reported.

Match the signature convention used by XpuptiActivityApi::processActivities and avoid copying the std::function on every call. The handler is only invoked in-scope, never stored.

Port the CUPTI completed-buffer fix to the XPU plugin: activityBuffers()
now returns already-completed buffers when nothing is in flight,
clearActivities() drops them on the early-return path, and
bufferCompleted() rejects unknown buffer pointers instead of
dereferencing an invalid map iterator.

Replace processActivities()' std::pair<int, int> return with a named
ActivitiesStats struct and log the record count/byte total, wiring up
LOGGER_OBSERVER_ADD_EVENT_COUNT which XPU never reported.

Match the signature convention used by XpuptiActivityApi::processActivities
and avoid copying the std::function on every call. The handler is only
invoked in-scope, never stored.
@meta-cla meta-cla Bot added the cla signed label Aug 31, 2026
@tsocha

tsocha commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

@aostrowski-hbn @gujinghui Please review.

@tsocha

tsocha commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot label 'ciflow/xpu'

@pytorch-bot

pytorch-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

The ciflow label(s) ciflow/xpu will be added, but CI won't be triggered until the workflows are approved (scroll to the bottom of this page).

Please ping one of the reviewers if you do not have access to approve and run workflows.

@pytorch-bot

pytorch-bot Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@tsocha tsocha changed the title {XPUPTI] Fix buffer lifetime and report processed-record stats with some minor improvements. [XPUPTI] Fix buffer lifetime and report processed-record stats with some minor improvements. Aug 31, 2026
@tsocha
tsocha marked this pull request as ready for review September 2, 2026 08:02
@tsocha

tsocha commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@ryanzhang22 @scotts Could you review this PR, please?

@ryanzhang22
ryanzhang22 merged commit 33b47f8 into pytorch:main Sep 2, 2026
12 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
@tsocha
tsocha deleted the dev/tsocha/xpupti-fix branch September 7, 2026 12:59
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