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

[XPUPTI] Limit the number of events recorded for XPU_DRIVER activity. - #1570

Draft
tsocha wants to merge 1 commit into
pytorch:mainfrom
intel-staging:dev/tsocha/limit-xpu-driver
Draft

tsocha wants to merge 1 commit into
pytorch:mainfrom
intel-staging:dev/tsocha/limit-xpu-driver

Conversation

@tsocha

@tsocha tsocha commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Currently PTI reports 200+ types of events for XPU_DRIVER activity type.
This PR reduce it to 20 related to launching kernels.
It will reduce size of the trace and limit the noise caused by L0 calls.

Narrow XPU_DRIVER to PTI's GPU_OPERATION_CORE class. The class filter has to follow ptiViewEnable(), which enables all api ids and clears the granularity flag; the first granular call then resets the group to all-disabled before enabling its class.

zeCommandQueueExecuteCommandLists submits work to the GPU but is absent from PTI's class list, so enable it explicitly until that is fixed upstream.

Narrow XPU_DRIVER to PTI's GPU_OPERATION_CORE class. The class filter has to
follow ptiViewEnable(), which enables all api ids and clears the
granularity flag; the first granular call then resets the group to
all-disabled before enabling its class.

zeCommandQueueExecuteCommandLists submits work to the GPU but is absent
from PTI's class list, so enable it explicitly until that is fixed
upstream.
@meta-cla meta-cla Bot added the cla signed label Sep 21, 2026
@tsocha

tsocha commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot label 'ciflow/xpu'

@pytorch-bot

pytorch-bot Bot commented Sep 21, 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 Sep 21, 2026 •

Copy link
Copy Markdown

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

@tsocha

tsocha commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@gujinghui please review.

XPUPTI_CALL(ptiViewEnableDriverApi(
/*enable=*/1,
PTI_API_GROUP_LEVELZERO,
pti_api_id_driver_levelzero::zeCommandQueueExecuteCommandLists_id));

@gujinghui gujinghui Sep 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@tsocha Should we ask the PTI team to add this API to the PTI_API_CLASS_GPU_OPERATION_CORE list?

Ideally, we should avoid hardcoding specific API names in pytorch/kineto. Asking the PTI team to handle this internally on their end would save us the effort of maintaining this custom bypass in the future.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@tsocha Could you help address my below questions with this change? Thanks.

  1. If the kernel is launched by SYCL API, both SYCL kernel launch and L0 kernel launch will be traced, or only traces the SYCL kernel launch?
  2. If a lib launches kernel with L0 API directly, will the kernel launch be traced?
  3. All other implicit L0 calls will be hidden, for example, the event creations, host synchronization?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@tsocha @gujinghui Yes - adding zeCommandQueueExecuteCommandLists to PTI_API_CLASS_GPU_OPERATION_CORE (in PTI ) makes sense and this is to add one line.

@tsocha can you pls do it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pti_api_id_driver_levelzero::zeCommandQueueExecuteCommandLists_id will be added into PTI_API_CLASS_GPU_OPERATION_CORE soon, but it won't be available until new oneAPI will be used in PyTorch.
Are you OK to keep it here for now?

  1. SYCL will produce L0 kernel launch event so it will be traced.
  2. It should be captured by XPU_DRIVER activity. list of events
  3. Yes, it will be hidden. For synchronization events I need to create a follow-up PR to enable XPU_SYNC activity type by default, it have to be enabled in PyTorch.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for quick response.

Yes, it will be hidden. For synchronization events I need to create a follow-up PR to enable XPU_SYNC activity type by default, it have to be enabled in PyTorch.

@tsocha Can we have this first? The SYNC activity is important.

pti_api_id_driver_levelzero::zeCommandQueueExecuteCommandLists_id will be added into PTI_API_CLASS_GPU_OPERATION_CORE soon, but it won't be available until new oneAPI will be used in PyTorch.
Are you OK to keep it here for now?

We'd better have the fix in PTI first. @jfedorov May I know the plan for upcoming PTI release? Thanks.

@ryanzhang22

Copy link
Copy Markdown
Contributor

@tsocha @gujinghui Just a heads up on #1571.

We are planning to lock this repo tomorrow -- you'll need to recreate this PR in pytorch/pytorch on Monday if this hasn't landed by then. Dir structure and everything should be the same, so it should be trivial to copy the changes over. Thanks!

@tsocha

tsocha commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@ryanzhang22
Thank you for the reminder.
I wanted to pass the review process before the lock.

I will migrate this PR to the PyTorch repository when all issues will be resolved.

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