MindStudio Profiling Tool Interface (msPTI) is a set of profiling APIs provided by MindStudio for Ascend devices. You can use msPTI to build profilers for NPU applications.
msPTI is for common scenarios. Profiling tools developed with msPTI APIs can be used in inferencetraining scenarios in different frameworks.
msPTI provides the following functions:
msPTI provides a set of C-based APIs and a set of Python APIs with the C-based API functions as the underlying logic.
For details about the mapping between AI processors and Ascend products, see Ascend Product Overview.
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
x |
|
x |
The samples of msPTI Python APIs depend on the PyTorch framework and torch_npu plugin. Ensure that they have been installed. For details, see "Installing PyTorch" in Ascend Extension for PyTorch.
msPTI cannot be used with any other profilers. Otherwise, the profile data will be lost.
This section provides examples of using msPTI APIs.
Sample Building and Execution
source /usr/local/Ascend/cann/set_env.sh
The msPTI sample code is integrated in the CANN Toolkit development kit and stored in the ${install_path}/tools/mspti/samples directory.
Replace ${install_path} with the path for storing files after the CANN software is installed. For example, if the installation is performed by the root user, the path is /usr/local/Ascend/cann.
cd ${install_path}/tools/mspti/samples/callback_domain
bash sample_run.sh
The following table describes the samples provided currently.
Sample |
Description |
|---|---|
Demonstrates the Callback API function. You can call msptiEnableDomain to perform callback operations before and after the runtime API. |
|
Demonstrates the function of combining the callback and mstx APIs. You can use the callback and mstx APIs to profile operator data before and after the runtime launch kernel. Demonstrates the usage of userdata in callback. You can use userdata to transparently transmit configurations or specific running parameters. |
Sample |
Description |
|---|---|
Demonstrates the basic functions of the Activity API. It shows how to profile kernels and memory. Demonstrates the basic running of the Activity API and describes the basic usage of the Activity API, including the memory allocation of the activity buffer and the logic of buffer consumption. |
|
Demonstrates the basic functions of the Activity API. It shows how to use the correlationId field to correlate the API with the kernel data. Demonstrates the correlation between the runtime API delivery and the actual kernel execution data. After the association, the delivery and execution of operators can be one-to-one mapped, which facilitates performance bottleneck analysis. |
|
Demonstrates the msPTI external correlation function. Demonstrates the usage of msptiActivityPopExternalCorrelationId and msptiActivityPushExternalCorrelationId. You can use it to correlate various APIs to trace function call stacks. |
|
Demonstrates the basic functions of the Activity APIs and shows how to use the HCCL switch to collect communication data. |
|
Demonstrates how msPTI controls the mstxDomain function. You can enable or disable the function to control domain profiling. You can use the msPTI switch to enable or disable profiling in real time, reducing performance loss. |
Sample |
Description |
|---|---|
Demonstrates the basic usage of Monitor. You can use KernelMonitor and HcclMonitor to obtain the time consumed by compute operators and communication operators. |
|
Demonstrates the basic usage of MstxMonitor. You can use mstx to collect the time consumed by a specific operator (for example, matmul). |