Quick Start with Graph Profiling#
PTI profiles the GPU work that applications run as graphs: Level Zero native graphs, SYCL™ graphs, and XPU graphs in PyTorch®. PTI reports individual, node-level GPU operations through the same PTI_VIEW_DEVICE_GPU_* views as other GPU work.
On-Demand Profiling#
With on-demand profiling, you can enable profiling at any time, including after the graph is created or executed. PTI reports every execution of the graph while profiling is enabled. With native graphs on a supported GPU and driver (see Graph Support), this works out of the box, without needing additional PTI API calls or environment variables.
Without on-demand profiling, PTI reports a graph only if profiling was enabled before the graph was created. Call ptiViewEnable for the PTI_VIEW_DEVICE_GPU_* views first, then create the graph.
Graph Support#
On-demand profiling requires Level Zero driver version 1.15.39122+12 or newer. To check the version, run sycl-ls (the value in brackets on each level_zero:gpu line) or, in PyTorch, print torch.xpu.get_device_properties().driver_version.
Graph or command list |
Linux® |
Windows |
Intel® Data Center GPU Max Series |
|---|---|---|---|
Level Zero native graph |
On demand (1) |
On demand (1) |
Not supported |
SYCL graph created as a Level Zero native graph |
On demand (1, 2) |
On demand (1, 2) |
Not supported |
XPU graph ( |
On demand (1, 2, 3) |
On demand (1, 2, 3) |
Uses legacy SYCL graphs (5) |
Legacy SYCL graph |
On demand with environment variables (4) |
Enable views first (5) |
Enable views first (5) |
Level Zero command list created with |
On demand (6) |
On demand (6) |
Not supported |
Requires Intel® Arc™ B-Series Graphics or newer GPUs. No environment variables are needed.
Requires the SYCL runtime from Intel® oneAPI DPC++/C++ Compiler 2026.1.1 or newer. See SYCL Graphs.
PyTorch 2.14 also needs an upgrade of
intel-ptianddpcpp-cpp-rt. See PyTorch XPU Graphs.Set
NEOReadDebugKeys=1andExperimentalFlatCommandListApiRecording=1. These environment variables do not work on Windows.Call
ptiViewEnablefor thePTI_VIEW_DEVICE_GPU_*views before creating the graph. On-demand profiling is not available.Create the command list with
zeCommandListCreateand theZE_COMMAND_LIST_FLAG_ENABLE_COMMAND_VISITflag. No environment variables are needed.
SYCL Graphs#
A SYCL graph is a Level Zero native graph when it is created with the enable_native_recording property, and a legacy SYCL graph otherwise. Native recording requires an in-order queue; on other queues, recording throws a sycl::exception:
namespace sycl_ext = sycl::ext::oneapi::experimental;
sycl::queue queue{sycl::property::queue::in_order{}};
// Level Zero native graph
sycl_ext::command_graph native_graph{
queue, {sycl_ext::property::graph::enable_native_recording{}}};
// Legacy SYCL graph
sycl_ext::command_graph legacy_graph{queue};
In SYCL and Level Zero applications, enable the views with the ptiView API as shown in Quick Start with ptiView API.
PyTorch XPU Graphs#
PyTorch 2.14 and newer captures XPU graphs (torch.xpu.XPUGraph and torch.xpu.graph) as Level Zero native graphs by default, except on Intel Data Center GPU Max Series, where it uses legacy SYCL graphs.
PyTorch 2.15 and newer needs no upgrade: PyTorch 2.15 installs intel-pti 1.1.0 and SYCL runtime 2026.1.2, which profile native graphs.
PyTorch 2.14 installs intel-pti 1.0.1 and SYCL runtime 2026.1.0, which do not profile native graphs. As a workaround, upgrade both in the PyTorch environment:
pip install --upgrade "intel-pti==1.2.1" "dpcpp-cpp-rt==2026.1.1"
pip reports dependency conflicts with the versions PyTorch 2.14 pins; the upgrade still succeeds.
Example: Profiling a PyTorch XPU Graph#
This script captures an XPU graph before the profiler starts, then profiles five replays of it. With on-demand profiling (see Graph Support), the trace shows the graph’s kernels for every replay:
import torch
from torch.profiler import ProfilerActivity, profile
x = torch.randn(512, 512, device="xpu")
# Warm up on a side stream before capturing the graph.
s = torch.xpu.Stream()
s.wait_stream(torch.xpu.current_stream())
with torch.xpu.stream(s):
y = torch.relu(x @ x) + 1
torch.xpu.current_stream().wait_stream(s)
# Capture the graph before the profiler starts.
g = torch.xpu.XPUGraph()
with torch.xpu.graph(g):
y = torch.relu(x @ x) + 1
# Profile five replays of the graph.
with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.XPU]) as prof:
for _ in range(5):
g.replay()
torch.xpu.synchronize()
prof.export_chrome_trace("xpu_graph_trace.json")
Open xpu_graph_trace.json in Perfetto, as described in Quick Start with the PyTorch Profiler on Intel GPUs. Each replay appears as one urEnqueueGraphExp call, and the graph’s three kernels appear for every replay. The first execution of a graph is slow while profiling is active; when measuring overhead, exclude it (see Known Issues).