Trace the Target Program

Updated at:
Copy as MD

1. PPU activity tracing

asys collects trace data for both HGGC and mainstream GPUs. Use the -t option to specify the trace items to capture. If no trace items are specified, asys collects hggc,hgtx,acdnn,acblas by default. The following table lists the PPU-related trace items supported by the --trace option.

Supported trace items

Description

hggc

Execution time and call stack details for HGGC runtime/driver APIs

Execution time and call stack details for mainstream GPU runtime/driver APIs

PPU execution details: kernel/memcpy/memset

Correlation between HGGC APIs and PPU execution

acdnn

Execution time of cuDNN APIs

acblas

Execution time of cuBLAS APIs

hgvideo

Execution time for HG-Encode APIs

Execution time for HG-ACVID APIs

Execution time for HG-JPEG APIs

PPU execution details: video encoding/decoding

Correlation between video APIs and PPU execution

pccl

Execution time for each PCCL communication phase

You can control the scope of data collected for the hggc trace item by using the --hggc-trace-set option to enable specific trace subsets. Specify multiple subsets separated by a comma (,), for example: --hggc-trace-set=kernel-activity,kernel-api

HGGC trace subset

Description

kernel-activity

Collects information about kernel execution on the PPU.

memory-activity

Collects information about memory operations on the PPU.

kernel-api

Collects execution information for kernel-related APIs on the CPU.

memory-api

Collects execution information for memory-related APIs on the CPU.

default-set

Default. Includes all selectable trace subsets and other HGGC trace data.

If you want to specifically disable the collection of certain APIs in the hggc trace item, you can configure the ASIGHT_HGGC_TRACE_BLACKLIST environment variable to specify a list of APIs to disable, where multiple API names are separated by a ,, for example: export ASIGHT_HGGC_TRACE_BLACKLIST=cudaEventQuery,cuEventQuery.

1.1 Device-side PPU activity

1.1.1 PPU activity

Required asys option: --trace hggc

In the GUI tool, a collected report displays PPU activity in the following hierarchy:

image

For easier viewing, a single timeline may be drawn across multiple rows. For example, in the figure above, add_kernel appears not only in its own row but also in the Kernels and Stream rows. If a context contains multiple streams, an [All Stream] row appears, which shows an aggregated view of all streams.

Tips:

  • If a device has only one context, the Context node is hidden, and its underlying stream nodes are displayed directly. Similarly, if a context has only one stream, the Stream node is also hidden.

  • The displayed PPU device index is the physical index and is not affected by the CUDA_VISIBLE_DEVICES environment variable.

A percentage appears before each PPU node name, indicating the node's duration relative to its parent. Using a stream node as an example, the calculation is:

stream duration percentage = 100.0 * stream duration / context duration
stream duration = total duration of all events in the stream
context duration = total duration of all events in the context

Therefore, 50.3% Stream 8 means that the total duration of all events in this stream is 50.3% of the total duration of all events in the context.

Tips: For the Kernel HGTX nodes under Kernels, the percentage is calculated differently. The denominator is the Stream node, not the parent node.

Tips:After applying a Filter, the duration percentages of PPU nodes are recalculated and re-sorted based on the filtered range.

The PPU Device row summarizes activity for the entire device, showing two layers: kernel execution on top and memory operations on the bottom. Different colors are used to distinguish memory operation types, such as HtoD/DtoH/DtoD and Pinned/Pageable, as shown in the figure:

image

1.1.2 PPU graph

Required asys option: --trace hggc

Timeline View supports showing graph timelines independently to help you analyze graph execution. If the report includes graph data, a graph node appears under the stream node. The hierarchy is:

  • Graph Group

    • Graph

      • Graph Exec

For graph timelines, Timeline View shows the Graph ID and Graph Exec ID, as shown in the figure:

image

The PPU Device row also shows an aggregated view of graph activity.

image

1.1.3 PPU video

Required asys option: --trace hgvideo

asys also supports collecting video activity data on the PPU and showing related timelines to help you analyze video processing performance, as shown in the figure:

image

A Video node appears under the stream node, showing all video activity in the current stream. Similar to kernel timelines, video activity is also rolled up to the PPU Device node. When you select a time range, the tooltip shows the percentage of video activity, as shown in the figure:

image

1.2 Host-side API calls

1.2.1 HGGC API

Required asys option: --trace hggc

The Thread node shows HGGC calls. You can view kernel dispatch duration and memory operation start time in HGGC:

image

1.2.2 acdnn

Required asys option: --trace acdnn

After collection is enabled, the acdnn timeline appears under the Thread node:

image

1.2.3 acblas

Required asys option: --trace acblas

After collection is enabled, the acblas timeline appears under the Thread node:

image

1.2.4 Video API

Required asys option: --trace hgvideo

After this option is enabled, calls to Video APIs, including Encode, Decode, and HGJPEG APIs, appear as shown below:

image

1.3 Host and device navigation

Asight Systems displays the correlation between host-side APIs and device-side activities and lets you navigate between them:

image

In the figure above, clicking cudaLaunchKernel highlights the corresponding kernel on the device. You can use the Go to Host API or Go to Device Activity options in the context menu to navigate between them.

1.4 Switching API and kernel names

You can change how launch API names are displayed by navigating to Tools > Options > Systems Profile > HGGC API Name Mode. The options are:

  • Show Host API Name

  • Show Launched Kernel Name

1.5 Dependencies between PPU activities

Kernels on different streams on the PPU can establish execution dependencies via cudaEventRecord and cudaStreamWait. Timeline View can display these dependencies. To do so, use the context menu on a PPU activity timeline or a related Event API timeline and select Show Dependencies:

image

For timelines that depend on event-related APIs, Timeline View uses an orange curve to show the dependency between them, as shown in the figure:

imageTimelines unrelated to the dependency are grayed out. Hovering over the curve displays details about the dependency. Clicking the curve highlights the timelines related to that dependency path. Dependencies between kernels on the same stream and dependencies on the default stream are represented by a green curve:

image

When an activity depends on multiple events across multiple streams, the display shows:

  • The last event in the dependency chain from other streams.

  • Events from the same stream as the queried activity are not shown.

By default, only Effective Dependencies are shown. For example, when you query a kernel's dependencies, the view shows dependencies that existed from the kernel API launch until the PPU began executing the kernel. These are the dependencies that delayed the kernel's execution.

To view all dependencies (including logical dependencies that have already completed), go to Tools > Options > Systems Profile and set HGGC Dependency Display Mode to All.

Tips: Dependencies are computed from trace data in the report. If multiple threads contend when operating on HGGC streams, the displayed dependencies may be inaccurate.

1.6 In-depth kernel analysis

If a kernel underperforms and requires in-depth analysis, select it in Timeline View and choose Analyze the Selected Kernel with Asight Compute from the context menu. This action copies a command for generating an Asight Compute report. Run this command in the Asight Compute command-line tool. You can then open the generated report in the Asight Compute GUI tool for further analysis.

image

image

2. PPU metric tracking

asys periodically collects various runtime metrics from a device, such as resource utilization and I/O throughput, and displays how they change over time in the Asight Systems GUI:

image

Metrics in the same category are grouped for display and support two aggregation views: Overlay and Stacked. Use the --ppu-metrics-device option to specify the list of devices to sample. To sample all devices, use --ppu-metrics-device all. For example:

asys profile -t hggc --ppu-metrics-device all python test_linear.py

The preceding command uses the default metric set to sample all devices. To specify a metric set to collect, use the --ppu-metrics-set option. For example, use --ppu-metrics-set throughput to collect the I/O throughput metric set:

asys profile -t hggc --ppu-metrics-device all --ppu-metrics-set throughput python test_linear.py

You can use the --ppu-metrics-device help option to query the list of available devices. You can specify multiple devices and use , as a separator. For example, --ppu-metrics-device 0,1 collects performance metrics for only devices 0 and 1:

root@02892cb56ba5:~# asys profile --ppu-metrics-device help
Possible --ppu-metrics-device values are:
    all: Select all supported PPUs
    none: Disable PPU Metrics [Default]
    device ID list: comma separated device ID list(eg.: 0,1)

Available PPU metrics sampling devices are:
    0: PPU, PCI Bus ID: 00000000:10:00.0
    1: PPU, PCI Bus ID: 00000000:11:00.0
    2: PPU, PCI Bus ID: 00000000:CE:00.0
    3: PPU, PCI Bus ID: 00000000:CF:00.0

Device metrics are sampled periodically. The default sampling frequency is 1,000 samples per second (1 kHz). You can change this using the --ppu-metrics-frequency option. For example, --ppu-metrics-frequency 10000 sets the sampling frequency to 10 kHz.

asys supports a wide range of device metrics. However, the capacity limit for performance data collection restricts the number of metrics you can collect at once. To manage this, asys provides several predefined metric sets. To see the available metric sets, use the --ppu-metrics-set help option:

root@02892cb56ba5:~# asys profile --ppu-metrics-set help
Possible --ppu-metrics-set values are:
 ---------------- ---------------------------------------- --------------------------------------------
  Identifier       Description                              Enabled Metrics
 ---------------- ---------------------------------------- --------------------------------------------
  summary          Collect clock / memory / CU activity /   ce__cycles_elapsed.avg.per_second
                   Bus throughput information.              ce__cycles_active.avg.pct_of_peak_sustained_elapsed
                                                            gd__dispatch_count.avg.pct_of_peak_sustained_elapsed
                                                            ce__warps_active_accumulated.avg.pct_of_peak_sustained_elapsed
                                                            ce__warps_inactive_cu_active_accumulated.avg.pct_of_peak_sustained_elapsed
                                                            ce__warps_inactive_cu_idle_accumulated.avg.pct_of_peak_sustained_elapsed
                                                            cu__cycles_active.avg.pct_of_peak_sustained_elapsed
                                                            cu__ws_issue_active.avg.pct_of_peak_sustained_elapsed
                                                            cu__we_pipe_tensor_cycles_active.avg.pct_of_peak_sustained_elapsed
                                                            dram__exclude_hbm_bytes_read.sum.pct_of_peak_sustained_elapsed
                                                            dram__exclude_hbm_bytes_write.sum.pct_of_peak_sustained_elapsed
...
  throughput       Collect DRAM / PCIe / ICN link           kvd__transaction_hit_rate.pct
                   throughput information.                  ksd__transaction_hit_rate.pct
                                                            l2__transaction_hit_rate.pct
                                                            dram__exclude_hbm_bytes_read.sum.pct_of_peak_sustained_elapsed
                                                            dram__exclude_hbm_bytes_write.sum.pct_of_peak_sustained_elapsed
                                                            pcie__read_bytes.avg.pct_of_peak_sustained_elapsed
                                                            pcie__write_bytes.avg.pct_of_peak_sustained_elapsed
                                                            icnltx__bytes.sum.pct_of_peak_sustained_elapsed
                                                            icnlrx__bytes.sum.pct_of_peak_sustained_elapsed
...

You can also specify a custom list of metrics to collect. To view descriptions for all supported metrics, use the --ppu-metrics-list help option:

root@02892cb56ba5:~# asys profile --ppu-metrics-list help
Possible --ppu-metrics-list values are:

ce__cycles_active.avg
    Display Name:
        ce__cycles_active.avg
    Unit: cycle
    Description:
        # of cycles active on CE across CEs
...
kvd__transaction_hit_rate.pct
    Display Name:
        kvd__transaction_hit_rate.pct
    Unit: %
    Description:
        (%) hit rate of KVD cacheable requests
...

To specify a custom metric list, use the --ppu-metrics-list option with a comma-separated list of metrics. asys combines any metrics specified with --ppu-metrics-list with the metric set from --ppu-metrics-set. For example, --ppu-metrics-list ce__cycles_active.avg,kvd__transaction_hit_rate.pct collects CE utilization and KVD cache hit rate:

asys profile -t hggc --ppu-metrics-device all --ppu-metrics-set none --ppu-metrics-list ce__cycles_active.avg,kvd__transaction_hit_rate.pct python test_linear.py

Due to the device's capacity limit for performance data collection, any custom metric list specified with --ppu-metrics-list must not exceed this limit. To verify your list, use the --check-ppu-metrics-list option with a comma-separated list of metrics:

root@02892cb56ba5:~# asys profile --check-ppu-metrics-list ce__cycles_active.avg,kvd__transaction_hit_rate.pct,pu__we_average_warps_issue_stalled_compute_sfu_raw_per_issue_active.ratio
Check sampling metrics list result: PASS.
Metrics list is suitable for PPU sampling capacity.

Tips: asys may fail to collect device runtime metrics if another application is using the PPU performance data collection resources. This can occur for the following reasons:

  • Another asys application is collecting device runtime metrics.

  • Another acu application is collecting trace data.

  • DCGM is collecting profiling metrics. To pause it, run dcgmi profile --pause.

  • You can use PPU-SMI to check whether the PPU performance counter and the HGML GPM service are busy.

    • Run ppu-smi -q to query the status of the PPU performance counter.

    • Run ppu-smi gpm --get-sample-state to check if the HGML GPM service is enabled. If enabled, it occupies the PPU performance counter.

    • You can run ppu-smi gpm -s 0 to pause the HGML GPM service, which releases the PPU performance counter.

3. HGTX tracing

Asight Systems supports HGTX tracing to annotate the timeline. It supports custom domains and the push/pop and start/end APIs. The following example shows how to use HGTX:

#include <nvtx3/nvToolsExt.h>

for (int index = 0; index < 1000; ++index) {
    nvtxRangePushA("Loop");
    nvtxRangePushA("DoProcess");
    DoProcess();
    nvtxRangePop();
    ...
    nvtxRangePop();
}

This code pushes two nested HGTX ranges, Loop and DoProcess. The inner DoProcess() function calls some HGGC APIs. To collect the HGTX trace, run the following command:

asys profile -t hgtx -o test_report sample

The GUI then displays the data as follows:

image

The outer NVTX timeline is displayed above the inner NVTX timeline, creating a hierarchical view. The Loop timeline contains the DoProcess timeline, which in turn contains the timelines for the innermost runtime API calls. Asight also supports collecting and displaying user-specified colors.

image

4. OS runtime tracing

OS runtime tracing (OSRT) reveals why CPU threads are suspended, for example, during calls to pthread_mutex_lock or sleep. To collect OSRT, add osrt to the -t trace option:

  • Use --osrt-threshold to specify the collection threshold.

  • Use --osrt-backtrace-threshold to specify the call stack backtrace threshold.

For example:

asys profile -t osrt --osrt-backtrace-threshold 80000 python /test_script/ops/test_linear.py

View the OSRT timeline in the GUI:

image

5. CPU and thread activity

Asight Systems tracks how threads are scheduled on CPU cores. With asys, you can use the--sample or -s option to collect data on your application's execution across all system CPUs. This feature also periodically samples CPU execution call stacks and aggregates the collected information to provide function duration statistics.

For example, the following command collects CPU execution information and specifies the call stack sampling period:

asys profile -s process-tree -b dwarf --sample-period 2000000 python test_linear.py
  • -s process-tree collects CPU scheduling traces for the application's process and its child and descendant processes.

  • -b dwarf enables CPU call stack sampling. This option is enabled by default and can be omitted.

  • --sample-period 2000000 specifies the sampling period for each CPU call stack, in CPU execution cycles.

  • --sample-backtrace-depth specifies the depth of the CPU sampling call stack. The default is 24.

Tips:

  • Enabling CPU execution sampling significantly increases the report file size. A smaller --sample-period value adds overhead to your application.

  • The operating system may limit the sampling frequency specified by the --sample-period option, resulting in a lower actual frequency than configured.

  • Specifying a short sampling period with --sample-period may cause some sample points to be dropped due to throughput limitations.

5.1 CPU activity

This feature requires one of the following options:

  • --sample process-tree: Collects the process tree.

  • --sample system-wide: Collects all processes on the system.

After you enable CPU sampling, you can view the CPU activity:

image

In the figure above, the CPU Group row shows the overall CPU activity. Each node below it represents the workload of a specific core. A high occupancy in the timeline indicates that the core was busy during that period, while blank areas indicate that the core was idle. The activity of the main process is shown in dark blue, and the activity of child processes is shown in black. The color-coded label for each CPU core corresponds to its representation in the thread rows. The tooltip on the timeline shows which process and thread are currently executing on the CPU:

image

Select "Go to Thread Row" from the context menu to jump to the corresponding thread row:

image

Tip: CPU sampling uses a high sampling rate and increases the report file size. If you do not need CPU sampling, pass -s none in the asys command to disable it.

5.2 Thread scheduling

This feature requires one of the following options:

  • --sample process-tree: Collects the process tree.

  • --sample system-wide: Collects all processes on the system.

The following image shows the thread timeline with CPU sampling enabled:

image

The child nodes of a thread row show calls to various APIs. The thread row itself displays the thread's execution on CPU cores across four sub-rows:

image

From top to bottom, these are:

  • CPU utilization: Shows how the thread uses CPU resources.

  • CPU core: Indicates which core the thread is scheduled on. Its color corresponds to the label on the CPU core node.

  • Thread state, which has three values:

    • runningimage

    • unscheduledimage

    • waitingimage

  • Calling OSRTimage

  • Backtrace sample point: Marks where a backtrace was sampled. The tooltip shows detailed call stack information.

Hover over an item to view more details.

If CPU sampling is disabled but OSRT collection is enabled, Asight Systems estimates the thread state based on OSRT execution. It estimates the thread state by classifying time spent in OSRT calls as CPU idle and time spent outside these calls as CPU busy, as shown in the following figure:

image

In this case, the thread state has two values:

  • possibly runningimage

  • possibly waitingimage

When only backtrace sampling is enabled, the thread row displays sample points:

image

You can view function duration statistics for the application in the Function View at the bottom of the GUI:

image

6. API call stack tracing

asys supports API call stack tracing for APIs such as HGGC, OSRT, ACDNN, ACBLAS, CUDNN, and CUBLAS. You can configure asys to capture call stacks only for API calls exceeding a runtime threshold and control the maximum backtrace depth. After enabling API call stack tracing, you can analyze function calls in the GUI's Function View using flame graphs, icicle graphs, and the Top Down, Bottom Up, and Flat tables.

6.1 Collect HGGC call stacks

To collect HGGC traces and call stacks, use the following command:

asys profile -t hggc --hggcbacktrace all:1000 --hggc-backtrace-depth 24 python test_linear.py
  • -t hggc enables HGGC tracing.

  • --hggcbacktrace all:1000 captures the call stack for all HGGC API calls whose runtime exceeds 1,000 nanoseconds (ns).

  • --hggc-backtrace-depth 24 sets the maximum backtrace depth for the HGGC call stack to 24 frames.

Hover over the timeline to view the call stack:

image

6.2 Collect OSRT call stacks

To collect OSRT traces and call stacks, use the following command:

asys profile -t osrt --osrt-backtrace-threshold 80000 --osrt-backtrace-depth 24 python /test_script/ops/test_linear.py
  • -t osrt enables OSRT tracing.

  • --osrt-backtrace-threshold 80000 collects the call stack for OSRT API calls whose runtime exceeds 80,000 nanoseconds (ns).

  • --osrt-backtrace-depth 24 sets the maximum backtrace depth for the OSRT call stack to 24 frames.

The call stack is shown below:

image

6.3 Collect ACDNN and ACBLAS call stacks

To collect ACDNN and ACBLAS traces and call stacks, use the following command:

asys profile -t acdnn,acblas --acompute-backtrace-threshold 80000 python /test_script/ops/test_linear.py
  • -t acdnn,acblas enables ACDNN and ACBLAS tracing.

  • --acompute-backtrace-threshold 80000 collects the call stack for ACDNN and ACBLAS API calls whose runtime exceeds 80,000 nanoseconds (ns).

The call stack is shown below:

image

7. Memory usage tracking

7.1 Tracking PPU memory usage

asys profiles an application's device memory usage. It captures call stack information during memory allocation and deallocation, and aggregates it to provide usage statistics. Enable this feature with the --hggc-memory-usage option, for example:

asys profile -t hggc --hggc-memory-usage true python test_linear.py

When memory usage tracking is enabled, Asight Systems displays PPU memory usage on the timeline, so you can analyze memory consumption, as shown below:

image

The Device memory usage row shows PPU memory usage throughout the program's execution. Its features include:

  • Correlation with HGGC APIs.

  • Support for call stacks.

  • Display of memory allocation and deallocation events in the Events View.

When a PPU memory allocation fails, a small red dot appears on the Device memory usage row:

image

The Device Memory View provides a Top Down/Bottom Up/Flat table.

Tips:

  • Use the --hggc-backtrace-depth option to control the backtrace depth for call stack collection. The default depth is 24 frames. For example, --hggc-backtrace-depth 50 sets the maximum backtrace depth to 50 frames.

  • This feature does not capture device memory that the HGGC destructor deallocates at process termination.

7.1.1 Memory timeline

Expand the Device memory usage row or click the Toggle memory timeline details button on the right to display the Memory Timeline, as shown below:

image

This view shows the details of each memory allocation, including its allocation and deallocation times. Very small memory allocations are merged and displayed at the top.

In addition to the normal mode, this view supports two other modes: grouping mode and group-colored mode.

Grouping mode

This mode groups memory allocations by module, such as a PyTorch module or a communication library module. This lets you view the memory usage of a specific module, as shown below:

image

Click the button to the right of the mode switch combo box to open the grouping rules dialog, where you can configure the grouping rules:

image

The rules are matched sequentially from top to bottom. Each memory allocation can belong to only one group. You can click a color block to change the group's color.

Group-colored mode

This mode is a combination of normal mode and grouping mode. Each memory allocation is still displayed individually, but is colored according to the group it belongs to, as shown below:

image

7.2 Sampling host memory usage

asys can periodically sample an application's CPU-side system memory usage. Use the --host-memory-sampling option to enable sampling and the --host-memory-sampling-frequency option to control its frequency, for example:

asys profile -t hggc --host-memory-sampling true --host-memory-sampling-frequency 500 python test_linear.py

Sampling a process's system memory usage data lets you view how its CPU-side memory usage changes over time in the Asight Systems GUI:

image

Two types of memory usage are displayed:

  • Resident set size: The actual physical memory usage.

  • Water mark: The peak physical memory usage during the profiling period.

Tips: asys can sample the system memory usage of an application's process tree (the root process and its child and descendant processes). When a system-wide trace is enabled (-s system-wide), the system memory sampling feature is disabled.

7.3 Tracking heap memory usage

asys profiles an application's usage of CPU-side dynamically allocated memory (heap memory), such as memory allocated with malloc or new. It captures call stack information during these allocations and aggregates the data to provide usage statistics. Enable this feature with the --heap-memory-usage option, for example:

asys profile --heap-memory-usage true python test_linear.py

Profiling heap memory usage lets you view how each process's heap memory consumption changes over time in the Asight Systems GUI:

image

Click a point in time on the Heap memory usage row to view information about the process's heap memory usage up to that point in time, such as a flame graph or ice graph. This feature supports memory leak analysis and provides statistics on memory volume and allocation counts. For example:

image

You can use the --heap-sampling-interval-bytes option to adjust the average sampling interval in bytes for dynamically allocated memory usage in asys. A smaller sampling interval improves the collection accuracy for smaller dynamic memory allocations, but it also significantly increases the performance overhead of asys tracing and collection.

Use the --heap-backtrace-depth option to adjust the backtrace depth for heap memory call stack collection and the --heap-report-interval option to adjust the aggregation interval for heap memory usage information. For example:

asys profile --heap-memory-usage true --heap-sampling-interval-bytes 16777216 --heap-backtrace-depth 50 --heap-report-interval 2 python test_linear.py
  • --heap-memory-usage true: Enables heap memory usage profiling.

  • --heap-sampling-interval-bytes 16777216: Sets the average sampling interval in bytes to 16 MiB.

  • --heap-report-interval 2: Sets the interval for aggregating and recording information about dynamic memory usage to 2 ms.

Tips:

  • You can use the --heap-sampling-interval-bytes option to set the average sampling interval in bytes. Asys may consolidate reports for dynamically allocated memory usage that is smaller than this threshold to reduce the performance overhead of tracing and collection.

  • Setting --heap-sampling-interval-bytes=1 forces asys to profile every heap memory allocation. This significantly increases profiling overhead and is not recommended for profiling complex applications.

7.4 Pinned memory usage analysis

asys profiles an application's usage of pinned memory. It captures call stack information during pinned memory allocation and deallocation, and aggregates it to provide usage statistics. By default, asys enables pinned memory profiling when both the --hggc-memory-usage (for device memory) and --host-memory-sampling (for CPU-side system memory) options are enabled, for example:

asys profile -t hggc --hggc-memory-usage true --host-memory-sampling true python test_linear.py

Profiling pinned memory usage lets you view how each process's pinned memory usage changes over time in the Asight Systems GUI. You can also view summarized device memory usage information for each API in the application, as shown below:

image

This view shows how pinned memory usage changes over time. The tooltip shows details about the corresponding allocation or deallocation event, including call stack information. Pinned memory events can also be displayed in the Events View. The Host Pinned Memory View provides a flame graph, an ice graph, or a Top Down/Bottom Up/Flat table.

Tips:

  • Use the --hggc-backtrace-depth option to control the backtrace depth for call stack collection. The default depth is 24 frames. For example, --hggc-backtrace-depth 50 sets the maximum backtrace depth to 50 frames.

  • You can simultaneously collect device and pinned memory usage. Separate multiple options with a comma (,), for example, --hggc-memory-usage device,pinned.

  • This feature does not capture pinned memory that the HGGC destructor deallocates at process termination.

8. Python tracing

8.1 Collect Python call stacks

8.1.1 Python Sampling

asys periodically collects the call stack of Python scripts at runtime, including function names, filenames, and line numbers. The collected data appears in the Asight Systems GUI:

image

Enable periodic call stack collection with the --python-sampling option and control the sampling frequency with --python-sampling-frequency. For example:

asys profile --python-sampling true --python-sampling-frequency 1000 python launch.py
  • --python-sampling true: Enables periodic collection of the Python call stack. The default is true.

  • --python-sampling-frequency 1000: Controls the sampling frequency. The valid range is from 1 Hz to 1 kHz. The default is 500 samples per second (500 Hz).

  • --python-backtrace-depth: Specifies the call stack depth for Python Sampling. The default is 24.

8.1.2 Python Backtrace

When tracing specific events, asys collects the current Python call stack and combines it with the C call stack to display the full call chain.

image

Enable this feature with the --python-backtrace=hggc option and control the call stack depth with --python-backtrace-depth. Currently, Python Backtrace supports the following trace items:

  • hggc

    For example:

    asys profile --python-backtrace=hggc python launch.py
  • device memory / pinned memory

    For example:

    asys profile --hggc-memory-usage=true --host-memory-sampling=true --python-backtrace=hggc python launch.py

Note:

  • asys Python call stack collection currently supports Python versions 3.8 to 3.12.

  • asys does not support Python call stack collection for applications launched with aliased Python interpreters (interpreters not named python or python3).

8.2 Python Functions Trace

asys lets you collect execution information for Python functions without modifying their source code. This information appears as HGTX ranges:

image

Use the --python-functions-trace option to specify functions to trace using one of the following modes:

Value

Description

none

Default. No functions are traced.

all

Traces all Python functions.

module:<module_name>

Traces all functions in the specified module(s). You can specify parent modules. Separate multiple modules with a comma, for example: module:torch,threading.

<json_file>

Traces only the functions specified in the JSON file.

Use --python-functions-threshold to set a runtime threshold that triggers function tracing. The unit is nanoseconds (ns) and the default is 80,000 ns. When specifying functions in a JSON file, you can use one of three methods:

  • Specify only the module. This traces all functions within that module and its sub-modules. For example, specifying 'torch' also traces all functions in 'torch.nn'.

    [
      {    
        "module": "torch.nn.functional"
      },
      {
        "module": "threading"
      }
    ]
  • Specify a list of function names under a fully qualified module name. You can also define a custom domain (the default is 'Python Hgtx').

    [
      {    
        "module": "torch.nn.functional",
        "domain": "Torch Domain",
        "functions": ["sigmoid","log_softmax"]
      }
    ]
  • Within the functions list, you can override attributes for a specific function. If you specify a module for a function, it overrides the parent module setting. If you specify a domain, the function will be displayed in multiple domains.

    [
      {    
        "module": "torch.nn.functional",
        "domain": "Parent Domain",
        "functions": ["sigmoid", {"function": "Adadelta.step", "module": "torch.optim.adadelta", "domain": "Child Domain"}]
      }
    ]

You can combine these methods in the JSON file. If there are conflicting specifications, the last one specified takes precedence.

For example, to trace all functions in the torch module and set the API runtime threshold to 1,000 ns:

asys profile --python-functions-trace module:torch --python-functions-threshold 1000 python xx.py

Note:

  • asys Python Functions Trace supports Python 3.8 and later versions.

  • In multi-threading scenarios, tracing of a new child thread may be delayed.

  • asys does not support specifying functions within the __main__ module.

  • Function tracing may be inaccurate before and after the application forks.

9. PCCL activity tracking

asys can collect PCCL activity events to monitor PCCL activity. To enable collection, use the -t pccl option. For example:

asys profile -t pccl hggc python test_pccl.py

The timeline is shown in the figure below:

image

The PCCL timeline is organized by channel, and then by pipeline within each channel.

10. Tracking RDMA NIC performance metrics

asys can periodically collect performance metrics for RDMA NICs in the system, such as bytes sent and received, average packet size, and congestion control information. The Asight Systems GUI displays these metrics over time:

image

The following metrics can be displayed:

  • Network receive rate

  • Network send rate

  • Receive packet size

  • Send packet size

  • Receive CNP rate

  • Send CNP rate

  • Send wait

When you select a time range, a tooltip displays the average network transfer rate for that period, as shown below:

image

Use the --nic-metrics option to enable performance metrics collection for network devices. asys then collects data from all network devices and displays the active ones in the GUI. For example:

asys profile --nic-metrics true ./all_reduce_perf
  • --nic-metrics true: Enables performance metrics collection for network devices.

Use the --nic-device-include option to specify which network devices to monitor. This option accepts one or more regular expressions to match against device names. To specify multiple regular expressions, separate them with a comma. asys monitors a network device if its name matches any of the specified regular expressions. For example:

asys profile --nic-metrics true --nic-device-include "bond" ./all_reduce_perf
  • --nic-device-include "bond": Collects metrics for network devices whose names contain "bond".

asys profile --nic-metrics true --nic-device-include "bond,eth" ./all_reduce_perf
  • --nic-device-include "bond,eth": Collects metrics for network devices whose names contain "bond" or "eth".

Use the --nic-metrics-frequency option to set the sampling frequency. The valid range is 1 Hz to 100 kHz, with a default of 1 kHz.

asys profile --nic-metrics true --nic-metrics-frequency 10000 ./all_reduce_perf

Note: Due to limitations in the RDMA driver interface, the actual sampling frequency may not reach the configured value. If the specified sampling frequency exceeds the maximum supported frequency, asys collects data at the driver's maximum supported frequency.