Inferensys

Glossary

Execution Trace

An execution trace is a chronological record of the sequence of instructions, memory accesses, and function calls executed by a program, used to analyze the runtime behavior and performance of NPU workloads.
Product manager reviewing autonomous task execution dashboard on laptop, completed tasks visible, casual work session.
PERFORMANCE PROFILING AND AUTO-TUNING

What is Execution Trace?

A foundational tool for analyzing the runtime behavior of programs on specialized hardware accelerators like Neural Processing Units (NPUs).

An execution trace is a chronological, low-level record of the sequence of instructions, memory accesses, and function calls executed by a program on a processor. For NPU acceleration, this detailed log captures the precise flow of kernel execution, data movement between memory hierarchies, and hardware events, enabling engineers to reconstruct the exact runtime behavior of a workload. It is the raw data source for performance profiling and bottleneck analysis, moving beyond aggregate metrics to provide a step-by-step account of computation.

Analyzing an execution trace allows performance engineers to identify specific inefficiencies such as memory access patterns causing poor coalescing, pipeline stalls due to dependencies, or suboptimal workgroup scheduling. By correlating trace events with hardware performance counters, engineers can pinpoint whether a kernel is compute-bound or memory-bound. This granular insight is critical for auto-tuning parameters like tile size and vectorization factor, and for validating the effectiveness of kernel fusion and other compiler optimizations on the target NPU architecture.

PERFORMANCE PROFILING AND AUTO-TUNING

Key Components of an Execution Trace

An execution trace is a granular, chronological log of a program's runtime behavior. For NPU workloads, it provides the foundational data required for performance analysis, bottleneck identification, and auto-tuning. The following components are essential for a comprehensive trace.

01

Instruction Stream

The sequential record of every machine instruction executed by the NPU's cores. This is the most fundamental component, showing the exact flow of control.

  • Opcode and Operands: Captures the operation type (e.g., FMA, LOAD, STORE) and its associated data sources/destinations.
  • Program Counter (PC): Tracks the memory address of each instruction, enabling reconstruction of the execution path.
  • Branch Resolution: Logs the outcome of conditional branches, revealing control flow divergence and potential thread divergence inefficiencies.

This stream is critical for verifying compiler output and identifying unexpected instruction sequences.

02

Memory Access Log

A detailed record of all data movement operations, including addresses, sizes, and latencies. This is paramount for diagnosing memory-bound kernels.

  • Access Pattern: Shows whether loads/stores are contiguous (enabling memory coalescing) or scattered.
  • Hierarchy Level: Indicates whether an access hit in L1/L2 cache or required a fetch from global memory, directly impacting the cache hit rate.
  • Bank Conflicts: Flags simultaneous accesses to the same memory bank within a shared memory region, which serialize execution.

Analyzing this log reveals opportunities to optimize data layout, tiling, and prefetching.

03

Function Call Stack

A hierarchical record of subroutine invocations, including entry/exit timestamps and parameters. This contextualizes low-level events within the program's logical structure.

  • Call Graph: Maps the relationships between functions, showing which high-level operations lead to specific kernel launches.
  • Nested Timing: Allows for attribution of execution time to specific functions, facilitating hotspot identification.
  • Kernel Launch Parameters: Records the configuration (grid size, block size) for each dispatched kernel, which is the target for auto-tuning.

This stack is essential for creating flame graphs and understanding performance at the application level.

04

Hardware Performance Counters

Metrics collected from specialized processor registers that count low-level architectural events. These provide quantitative insight into hardware resource utilization.

  • Compute Metrics: Floating-point operations (FLOPs), integer operations, and compute throughput (e.g., FLOPS achieved).
  • Memory Metrics: Cache misses at each level, memory bandwidth utilization, and DRAM transaction counts.
  • Execution Metrics: Pipeline stall cycles, warp/wavefront issue efficiency, and occupancy levels.

Integrating these counters with the instruction stream enables precise bottleneck analysis, distinguishing between compute-bound and memory-bound phases.

05

Timeline and Synchronization Events

A temporally ordered log of events with nanosecond-resolution timestamps. This reveals parallelism, dependencies, and idle periods.

  • Kernel Execution Windows: Visualizes when each kernel starts and stops, showing potential for concurrent kernel execution.
  • Memory Transfer Phases: Shows overlapping of computation with host-to-device (H2D) and device-to-host (D2H) data transfers under asynchronous execution.
  • Synchronization Points: Records barriers, locks, and atomic operations that can cause threads to wait, indicating resource contention or serialization.

This timeline is crucial for optimizing workload scheduling and achieving full NPU utilization.

06

Metadata and Execution Context

Ancillary data that provides essential context for interpreting the raw trace, ensuring reproducibility and accurate analysis.

  • Hardware Identification: NPU model, driver version, and core clock frequency at capture time.
  • Software Environment: Compiler version, framework (e.g., TensorFlow, PyTorch), and kernel binary hash.
  • Input Tensor Characteristics: Shapes, data types (e.g., FP16, INT8), and memory layouts of the workload's inputs.
  • Trace Capture Parameters: Sampling rate (for sampling profiler traces) or instrumentation mode (for instrumentation profiler traces).

This context allows performance engineers to correlate behavior across runs and different hardware platforms.

PERFORMANCE PROFILING

How Execution Tracing Works for NPUs

Execution tracing is a fundamental technique for understanding and optimizing the runtime behavior of workloads on Neural Processing Units (NPUs).

An execution trace is a chronological, low-level record of the sequence of instructions, memory accesses, and function calls executed by a program on an NPU. Unlike aggregated performance counters, a trace provides a detailed, temporal view of execution, enabling engineers to reconstruct the exact flow of operations. This granular data is essential for identifying pipeline stalls, thread divergence, and inefficient memory access patterns that hinder performance.

Tracing is typically implemented via hardware event streams or instrumented software emulation, capturing events like kernel launches, memory coalescing successes, and cache hits/misses. By analyzing this timeline, performance engineers can pinpoint hotspots, understand resource contention, and validate the effectiveness of auto-tuning parameters. The trace serves as the ground truth for building accurate performance models and conducting bottleneck analysis to transition workloads from memory-bound to compute-bound states.

PERFORMANCE PROFILING AND AUTO-TUNING

Primary Use Cases for Execution Traces

Execution traces provide a granular, chronological record of program activity on an NPU, enabling engineers to move beyond aggregate metrics and diagnose the root causes of performance issues.

01

Bottleneck Identification and Analysis

Execution traces are the primary tool for distinguishing between compute-bound and memory-bound kernels. By analyzing the sequence of instructions and memory accesses, engineers can pinpoint the exact cause of pipeline stalls. For example, a trace showing frequent, long-latency accesses to global memory followed by idle compute units clearly indicates a memory bandwidth bottleneck. This analysis directly informs optimization strategies like memory coalescing or increasing cache hit rates.

02

Thread Divergence and Warp Efficiency

Traces reveal the dynamic execution path of individual threads within a warp or wavefront. This is critical for identifying thread divergence, where conditional branches (e.g., if/else statements) cause threads within the same warp to serialize their execution, drastically reducing parallel efficiency. By visualizing which threads are active at each cycle, engineers can restructure algorithms or data layouts to maintain high occupancy and ensure all threads in a warp follow the same execution path as much as possible.

03

Validating Auto-Tuning Results

Auto-tuning systems like a kernel tuner use parameter search across a configuration space (e.g., workgroup size, tile size) to find optimal settings. An execution trace provides the definitive proof of why one configuration outperforms another. Instead of just seeing a final runtime, engineers can examine traces to verify that the chosen configuration successfully increased memory coalescing, reduced pipeline stalls, or improved cache hit rates. This moves optimization from a black-box search to an explainable, engineering-driven process.

04

Memory Access Pattern Optimization

The most detailed use case involves analyzing the exact pattern of loads and stores. Traces can show:

  • Non-coalesced memory accesses that fracture a single wide transaction into many small, inefficient ones.
  • Bank conflicts in shared memory that serialize access.
  • Inefficient reuse patterns that cause unnecessary data movement across the memory hierarchy. By studying these patterns, engineers can apply transformations like loop tiling (tile size selection) or data layout restructuring to create sequential, aligned access patterns that maximize memory bandwidth utilization.
05

Concurrency and Scheduling Analysis

For complex workloads using asynchronous execution or concurrent kernels, traces provide a timeline view of kernel launches, data transfers, and synchronization events. This allows engineers to:

  • Identify gaps of idle hardware between kernels.
  • Detect resource contention between concurrently running kernels.
  • Verify that computation is effectively overlapped with data transfer (hiding latency).
  • Optimize the scheduling order and dependencies to maximize NPU utilization and overall throughput.
06

Creating and Refining Performance Models

Execution traces serve as ground-truth data for building and calibrating analytical performance models. By correlating observed execution times and stall cycles in the trace with kernel parameters (e.g., input size, workgroup size) and hardware events, engineers can create models that predict performance for new configurations. This is a key technique in advanced auto-tuning methods like Bayesian Optimization, where an accurate model guides the search towards promising regions of the configuration space without exhaustive profiling.

COMPARISON

Execution Trace Collection Methods

A comparison of the primary techniques used to capture chronological records of NPU program execution for performance analysis and debugging.

MethodHardware-Based TracingSoftware-Based InstrumentationHybrid (Hardware + Software)

Collection Mechanism

Dedicated on-chip trace units (e.g., ETB, PTM)

Code instrumentation (probes, hooks) or binary rewriting

Hardware trace packets augmented with software metadata

Granularity

Cycle-accurate instruction & memory access

Function/API call, user-defined regions

Instruction stream with annotated high-level events

Overhead

< 1% (dedicated hardware)

5-50% (varies by instrumentation density)

1-10% (hardware overhead + minimal software)

Data Volume

High (raw bitstream)

Low to Medium (structured events)

Medium (raw stream + filtered events)

Required Hardware Support

Mandatory (NPU trace IP)

None

Mandatory (NPU trace IP)

Post-Processing

Complex decoding with vendor tools

Minimal (structured logs)

Moderate (correlation and symbol resolution)

Debug Symbol Integration

Post-capture, requires symbol files

At capture time

Post-capture correlation

Real-Time Analysis

Limited (streaming to host)

Yes (in-process callbacks)

Yes (software component can filter/analyze)

EXECUTION TRACE

Frequently Asked Questions

A glossary of key terms and concepts related to Execution Trace, a critical tool for analyzing and optimizing the performance of workloads on Neural Processing Units (NPUs).

An Execution Trace is a chronological, low-level record of the sequence of instructions, memory accesses, and function calls executed by a program on a processor, such as a Neural Processing Unit (NPU). It provides a detailed, step-by-step log of runtime behavior, capturing events like kernel launches, memory transfers, and synchronization points. Unlike summary profiling data, a trace offers a temporal view, essential for identifying patterns of inefficiency, pipeline stalls, and resource contention. In NPU performance analysis, traces are used to reconstruct the exact flow of execution, enabling engineers to pinpoint latency bottlenecks, optimize memory coalescing, and validate auto-tuning results by showing how parameter changes affect the actual instruction stream and hardware utilization.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.