Skip to content

[xpupti] Fix CPU->GPU flow links via activity type, not an API-name allowlist#1467

Open
aostrowski-hbn wants to merge 1 commit into
pytorch:mainfrom
aostrowski-hbn:adrianos/pytorchdgq-9509-flow-withargsexp
Open

[xpupti] Fix CPU->GPU flow links via activity type, not an API-name allowlist#1467
aostrowski-hbn wants to merge 1 commit into
pytorch:mainfrom
aostrowski-hbn:adrianos/pytorchdgq-9509-flow-withargsexp

Conversation

@aostrowski-hbn

@aostrowski-hbn aostrowski-hbn commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

The XPU profiler marked a host record as the start of a CPU→GPU ("ac2g") flow arrow by exact-matching its API name against a hardcoded allowlist (correlateRuntimeOps_). That list did not contain urEnqueueKernelLaunchWithArgsExp — the launch API used by the 2025.3+ SYCL runtime — so kernel launches stopped emitting a flow start (ph:"s") and the host→device arrow disappeared from the trace.

Approach

Rather than add the new name to the list (which needs a new entry on every UR API rename/addition), decide the flow start from the record’s activity type: only host runtime (XPU_RUNTIME) records start a flow.

  • The runtime view is already filtered to work-submitting APIs via ptiViewEnableRuntimeApiClass(PTI_API_CLASS_GPU_OPERATION_CORE).
  • Driver (XPU_DRIVER) records share the runtime record’s correlation id and must not also start a flow, or the trace gets a duplicate flow start.

This removes the name allowlist entirely (robust to future UR renames) and extracts the check into a static startsFlow() for unit testing. Net −35 lines.

Note: this supersedes the original allowlist patch on this branch, following @mschilli’s suggestion to key off GPU_OPERATION_CORE / activity type instead of maintaining a name list. The XPU_DRIVER-exclusion guard is what prevents the duplicate-flow-start collision that a bare flow.start = 1 would cause.

No PTI version gate needed

ptiViewEnableRuntimeApiClass / PTI_API_CLASS_GPU_OPERATION_CORE exist since PTI 0.12.0 and are already called unconditionally on main; this change references no PTI symbol (only the Kineto ActivityType enum), so it builds on all currently-supported PTI versions (0.15–0.18 verified reasoning; 0.18 built).

Test Plan

XpuptiFlowCorrelationTest now asserts runtime records start a flow while driver and device records do not (hardware-free, in the CTest set).

Verified on Intel Data Center GPU Max (PVC), oneAPI 2026.0 / PTI 0.18:

  • XpuptiFlowCorrelationTest passes; full xpupti ctest 10/10 passes.
  • Rebuilt PyTorch against the patched kineto and ran a mixed workload (H2D copy, add/relu/matmul/reduction, D2H copy): every kernel and memcpy gets exactly one host→device arrow, with zero Perfetto flow errors (no flow_duplicate_id) and no PyTorch duplicate-flow-start warnings.

@meta-cla meta-cla Bot added the cla signed label Jul 6, 2026
@aostrowski-hbn aostrowski-hbn marked this pull request as draft July 6, 2026 15:04
…llowlist

The XPU profiler marked a host record as the start of a CPU->GPU ("ac2g")
flow arrow by exact-matching its API name against a hardcoded allowlist
(correlateRuntimeOps_). That list did not contain
urEnqueueKernelLaunchWithArgsExp -- the launch API used by the 2025.3+
SYCL runtime -- so kernel launches stopped emitting a flow start (ph:"s")
and the host->device arrow disappeared from the trace.

Instead of extending the name list (which needs a new entry on every UR
API rename/addition), decide the flow start from the record's activity
type: only host runtime (XPU_RUNTIME) records start a flow. The runtime
view is already filtered to work-submitting APIs via
ptiViewEnableRuntimeApiClass(PTI_API_CLASS_GPU_OPERATION_CORE), and driver
(XPU_DRIVER) records -- which share the runtime record's correlation id --
must not also start a flow, or the trace gets a duplicate flow start.

This removes the name allowlist entirely (robust to future UR renames) and
extracts the check into a static startsFlow() for unit testing. The gtest
XpuptiFlowCorrelationTest now asserts runtime records start a flow while
driver and device records do not.

Verified on Intel Data Center GPU Max (PVC), oneAPI 2026.0 / PTI 0.18:
- XpuptiFlowCorrelationTest passes; full xpupti ctest 10/10 passes.
- Rebuilt PyTorch against the patched kineto and ran a mixed workload
  (H2D copy, add/relu/matmul/reduction, D2H copy): every kernel and memcpy
  gets exactly one host->device arrow, with zero Perfetto flow errors
  (no flow_duplicate_id) and no PyTorch duplicate-flow-start warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aostrowski-hbn aostrowski-hbn force-pushed the adrianos/pytorchdgq-9509-flow-withargsexp branch from 3bae3a3 to 1d31654 Compare July 6, 2026 15:33
@aostrowski-hbn aostrowski-hbn changed the title [xpupti] Add urEnqueueKernelLaunchWithArgsExp to flow-link allowlist [xpupti] Fix CPU->GPU flow links via activity type, not an API-name allowlist Jul 6, 2026
@aostrowski-hbn aostrowski-hbn marked this pull request as ready for review July 6, 2026 15:39
@aostrowski-hbn

aostrowski-hbn commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@ryanzhang22 please import and review

@aostrowski-hbn

Copy link
Copy Markdown
Contributor Author

@pytorchbot label ciflow/xpu

@pytorch-bot

pytorch-bot Bot commented Jul 8, 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 Jul 8, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/xpu

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@gujinghui

Copy link
Copy Markdown

@ryanzhang22 @divyanshk @scotts This PR is ready for your review. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants