Use the CPU/GPU performance analysis skill
CPU/GPU performance analysis combines task metrics, exception events, logs, and profiling data to help you query task and resource status, locate task exceptions, and pinpoint the performance bottleneck of compute tasks, and provides key evidence, impact scope, and source-code-level optimization suggestions. This topic describes how to query tasks and troubleshoot exceptions, collect and analyze profiling data, view the results, and verify the optimization effect in the SysAgent conversation box.
Scenarios
CPU/GPU performance analysis applies to the following issues:
-
You need to query the status of GPU tasks and resources, or locate task exceptions, alerts, and log issues.
-
A compute task runs slower, but the location of the bottleneck is not yet clear.
-
The training iteration time increases or the throughput decreases.
-
The inference performance degrades.
-
You need to analyze exceptions by combining task metrics, logs, and execution paths.
-
After you adjust the code or configuration, you need to verify the performance change.
This skill is intended for GPU cluster platform O&M engineers, on-duty SREs, task owners, and training and inference engineers.
Preparations
-
Make sure that the target instance or GPU cluster belongs to the current account and is accessible.
-
Make sure that the target GPU cluster is managed in the Operating System Console, and install the required components and enable GPU-related capabilities as prompted on the page. For more information, see Component management.
-
If you need to receive results in an IM tool, make sure that a Lark or DingTalk bot has been integrated. For more information, see Integrate an IM bot.
-
Do not enter sensitive information such as AccessKey pairs, passwords, or tokens in the request.
Query tasks and locate exceptions
You can start from the task list and gradually ask about the resource usage, health status, exception alerts, and logs of a specific task to quickly locate task exceptions. The following are common request examples. When you use them, replace the cluster, instance, and task identifiers with the actual information:
-
Query the task list and resources: Show me the GPU tasks that exist. What GPU training tasks are in cluster cluster-xxxx? View the GPU tasks on instance i-xxxx. How many GPU cards does cluster cluster-xxxx have?
-
Query the status of a single task: View the running status, instance, and GPU usage of task task-xxxx. Has this task recently had alerts or resource exceptions? What is the resource consumption of the GPU training cluster?
-
Task health check: Perform a health check on task task-xxxx.
-
In-depth analysis of exception alerts: Has cluster cluster-xxxx had any exception alerts in the last day? If there are exceptions, perform an in-depth analysis of the causes.
-
Task log analysis: Show me the cluster in which task task-xxxx resides, and pull the logs of the last 10 minutes. You can also directly upload a log file for SysAgent to analyze.
We recommend that each request include at least the cluster, task, or instance identifier, the exception time range, and the conclusion that you expect. After you locate the specific task and bottleneck symptom, you can continue to collect and analyze profiling data as described in "Submit an analysis request".
Submit an analysis request
Performance analysis usually consists of two steps: first initiate profiling collection, and then ask about a specific stage based on the analysis ID.
-
Log on to the Alibaba Cloud Operating System Console and open the SysAgent conversation box.
-
Click Skills and select CPU/GPU performance analysis.
-
When you initiate collection, enter the target instance or task identifier, the region, the PID, the collection duration, and the performance exception symptoms.
-
If you already have a profiling analysis ID, enter the analysis ID and specify the task stage, metrics, or code paths that you want to focus on.
-
After you confirm that the information is correct, click Send.
The following are common request examples. When you use them, replace the instance, region, PID, task, and analysis ID with the actual information:
-
Collection (slower iteration): Collect the AI profiling data of instance i-xxxx, and specify the region, PID, and collection duration (for example, 10 seconds). The training iteration time of this task has increased recently. Focus on analyzing the performance bottleneck.
-
Collection (decreased throughput): Collect the AI profiling data of PID xxx on instance i-xxxx (specify the region) for 10 seconds. The samples throughput of this task has decreased. Locate the stage where the bottleneck is.
-
Analysis (locate the stage): Analyze the cause of the increased time consumption of the forward stage in profiling analysis ID prof-xxxx, and provide the key evidence, impact scope, and optimization direction. Do not perform code, configuration, or task changes.
-
Analysis (compare bottlenecks): For profiling analysis ID prof-xxxx, compare the time consumption of each stage, determine whether the main bottleneck is in computing, communication, memory, or I/O, and explain the basis for the judgment.
-
Combine task context: Based on the recent running metrics and logs of task task-xxxx, determine whether the increased iteration time is caused by a performance bottleneck, and collect AI profiling data for further analysis if necessary.
We recommend that each request include at least the target object, the exception time range, and the expected conclusion. When you already have profiling data or logs, specify the task, time range, and exception symptoms that the data corresponds to, and avoid mixing the analysis of data from different stages.
View the analysis results
After the analysis is complete, the results are presented in the following parts. Check them in sequence:
-
Analysis object: Confirm that the task, time range, and task stage are consistent with the request.
-
Analysis conclusion: View the located bottleneck or candidate causes.
-
Key evidence: Check the task metrics, exception events, logs, call stacks, or code paths. The profiling timeline can be used to view the evidence of performance hotspots, but the conclusion is still based on the text description.
-
Impact scope: Confirm the affected task stage, compute resources, or code paths.
-
Optimization suggestions: View the code, configuration, or running mode that is suggested to be adjusted.
-
Information gap: View the data or reproduction conditions that still need to be supplemented.
SysAgent does not automatically modify code, change configurations, or restart tasks. Assess the business impact and implement the suggestions on your own.
Verify the optimization effect
-
Record the iteration time, throughput, or inference performance metrics before the analysis.
-
Select an optimization suggestion that is consistent with the key evidence, and confirm the change impact and rollback measures.
-
Implement the confirmed code or configuration adjustment.
-
Rerun the same task stage.
-
Compare the metrics before and after the adjustment, and collect profiling data again as needed.
FAQ
-
The task cannot be located: check the task information and supplement the content that can locate the target.
-
Profiling data cannot be collected: check the task status and collection scope, and resubmit.
-
The results do not cover the exception: supplement the time of occurrence of the exception, the performance change, and the comparison metrics.
-
The conclusion has insufficient evidence: supplement the metrics, exception events, logs, or profiling data.
-
No improvement after optimization: roll back the changes that do not meet expectations, and reanalyze based on the new data.