aitune.torch.performance.runtime_profile
aitune.torch.performance.runtime_profile
PyTorch Profiler capture helpers for performance profiles.
Module Contents
Classes
Functions
Data
PROFILER_KEY_AVERAGES_ROW_LIMIT
API
Bases: typing.TypedDict
Structured warning emitted in PerformanceProfile.data["warnings"].
Sum of one region’s profiler events within one profiled run. Shares are derived at to_dict() time.
Fold one profiler event into this aggregate.
Serialize to the JSON-facing dict shape, computing shares relative to the run timing.
Portion of one profiled run not attributed to any topmost-owned region, per time domain.
Serialize to the JSON-facing dict shape, omitting unavailable device timing.
Per-run timing block. device_time_us is None when the profiler reported no device time.
Serialize to the JSON-facing dict shape, omitting unavailable device timing.
Data captured from one PyTorch Profiler run plus its derived analysis.
Return True if a strict CPU ancestor of event is another AOT-region event.
Walks cpu_parent up to (but not past) the profiled-run marker. The first
ancestor matching :data:AOT_MODULE_REGION_PREFIX means this event is
already enclosed by another AOT region in this run and its time would be
double-counted if aggregated independently.
Decide what to do with one AOT-prefixed event.
Returns None if the event is nested under another AOT event (skip),
the string "unmapped" if it has no profiled-run ancestor, or
(run_index, region_id) for aggregation.
Walk events once and bucket each region event (AOT or untuned) into its run.
Events matching AOT_MODULE_REGION_PREFIX are tracked as AOT regions; events
matching UNTUNED_MODULE_REGION_PREFIX are tracked as untuned regions. AOT
events that cannot be mapped to a profiled-run ancestor are counted as
unmapped; untuned events without a profiled-run ancestor are silently dropped
(they fire outside the measured window, e.g. during warmup setup).
Nested AOT events — an AOT-region event whose nearest AOT ancestor (before the
profiled-run marker) is also an AOT-region event — are skipped from
aggregation: the enclosing AOT region already owns that work, and counting
both would double-count and break sum(fractions) + residual ≈ 1.0. The
wrapper’s name is still recorded in _observed_aot_region_names only if at
least one non-nested event was seen, so a wrapper that ever owned time
appears in the regions metadata; one that only fired nested under another
does not.
Decide what to do with one untuned-prefixed event.
Return one bounded view over profiler key averages.
Return the profiled run index that owns an event, walking CPU parents.
Build the timing record for one profiled run.
Serialize one PyTorch Profiler key-average row.
Return observed AOT-managed module region names in profiler event order.
Run warmup + measured iterations under PyTorch Profiler.
PyTorch Profiler drives the iteration phases via torch.profiler.schedule:
warmup_runs user-requested warmup iterations during which the profiler is
idle (no event capture, no overhead), followed by 1 profiler-internal warmup
iteration that absorbs the profiler’s buffer-allocation cost, followed by
measured_runs recorded iterations. Only the recorded iterations contribute
events to the captured trace and analysis.
discovery_root selects the object from which to discover top-level untuned
module candidates for forward-hook instrumentation. Pass None to skip
untuned instrumentation entirely (used for pure-callable targets and tests).
Return bounded summaries from PyTorch Profiler’s own aggregate events.
Return per-run timing and aggregated region measurements (AOT and untuned) plus residual.
Return observed untuned module region paths in profiler event order.
Return structured warnings for report integrity issues.
Return the stable region id for an AOT-managed module name.
Return positive PyTorch Profiler device time in microseconds when present.
Read a profiler event numeric attribute as a float.
Return whether a profiler event is a CPU-side event with parent ancestry.
Return profiler activities supported by the current runtime.
Return the profiler event device type label.
Return the stable region id for an untuned module path.