Repository navigation
Add Intel GPU profiling mode via iaprof - #1059
Conversation
…frequency arg instead
There was a problem hiding this comment.
🟡 Changes recommended
Snapshot timeout cleanup can leave stale process and reader state, causing an additional profiling cycle to fail.
1 open finding
What changed in this PR
Adds Intel Xe GPU EU-stall profiling through an external iaprof process.
Changes:
- Adds GPU profiling mode, CLI options, and metadata.
- Implements
iaprofparsing, process lifecycle, and profile generation. - Generalizes system profilers and adds comprehensive tests.
| File | Description |
|---|---|
gprofiler/consts.py |
Defines GPU mode and frequency limits. |
gprofiler/main.py |
Integrates GPU CLI behavior and metadata. |
gprofiler/profilers/__init__.py |
Exports the Intel GPU profiler. |
gprofiler/profilers/factory.py |
Selects generic system profilers by mode. |
gprofiler/profilers/iaprof.py |
Implements the GPU profiler. |
gprofiler/profilers/perf.py |
Migrates perf to the shared system-profiler base. |
gprofiler/profilers/profiler_base.py |
Introduces SystemProfilerBase. |
gprofiler/utils/iaprof.py |
Parses streamed iaprof records. |
gprofiler/utils/iaprof_process.py |
Manages the long-lived iaprof process. |
tests/test_iaprof.py |
Tests output parsing and snapshots. |
tests/test_iaprof_process.py |
Tests process lifecycle and recovery. |
tests/test_iaprof_profiler.py |
Tests profiler behavior and CLI validation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if args.frequency is None: | ||
| args.frequency = DEFAULT_GPU_PROFILING_FREQUENCY | ||
| elif args.frequency > MAX_GPU_PROFILING_FREQUENCY: | ||
| parser.error(f"-f|--frequency cannot exceed {MAX_GPU_PROFILING_FREQUENCY} in gpu profiling") |
There was a problem hiding this comment.
Should we error out if the result is requested to upload to the backend at this time?
There was a problem hiding this comment.
The result can be uploaded to the backend without issues. It just appears as a CPU flame graph, so we may need to visually differentiate on the performance studio side.
| "sampling_frequency": self.system_profiler._frequency, | ||
| } | ||
| ) | ||
| elif isinstance(self.system_profiler, SystemProfilerBase): |
There was a problem hiding this comment.
This is specific to iaprof profiler?
There was a problem hiding this comment.
No, this covers both perf and iaprof since they are now both considered "system" profilers.
|
In general, looks good to me with 2 minor questions |

This adds
--mode=gpu, which profiles EU stalls on Intel GPUs (Xe-based arch) using an external iaprof executable. The collected profile conforms to gProfiler's existing stack-sampling format so that GPU flame graphs can be viewed in an unmodified Performance Studio.Description
Additions
IaprofProfiler(gprofiler/profilers/iaprof.py)iaprofprocess.iaprof2026.3 or newer, checked withiaprof --version.--iaprof-pathand--iaprof-eu-stall-subsample(default 100).IaprofProcess(gprofiler/utils/iaprof_process.py)stdouton a background thread and stores the counts per PID.gprofiler/utils/iaprof.pyparses iaprof's output into per-PID counters.gprofiler/main.py)-f/--profiling-frequencysetsiaprof's output interval in GPU mode. The default is 100 Hz, which is matchesiaprof's default 10 ms interval.--rootlessand--alloc-interval.iaprof_version,iaprof_output_interval_msandiaprof_eu_stall_subsample.tests/test_iaprof.py: parsertests/test_iaprof_process.py: the process managementtests/test_iaprof_profiler.py: the profiler subsystem and CLI argsChanges to shared code
SystemProfilerBase: a new base class for the exclusive system-profiler slot.Perf(SystemProfiler) andIaprofProfilerboth inherit from it. It also lets a system profiler add its own profile metadata.get_profilers(): selects the system profiler bySystemProfilerBaseinstead ofSystemProfiler. A profiler that doesn't support the current mode is now skipped with a debug log instead of a warning.--max-system-processes-for-system-profilersnow applies only toperf._snapshot():local_end_timeis now computed after the system-profiler result is collected to fix a bug where in GPU mode, no process profilers ran to take up the snapshot duration, so profiles got identical start and end times.perf.CPU and allocation modes behave the same as before.
Current Limitations
iaprofis not bundled. It must be installed separately and selected with--iaprof-path.perfand the language profilers are disabled.profile_requestvalidation only acceptscpu,allocationandnone.iaprofrestart, kernels loaded before the restart may not be attributed.Manual Testing
Tested end-to-end on a local machine with an Intel B580 running a simple SYCL matrix multiply benchmark. Test produced flame graphs in a locally-deployed version of the Performance Studio.