This section describes the optimization items that can be used to shorten the resumable training time on PyTorch, including Fault Detection Time, Collective Communication Initialization Time, Training Rollback and Checkpoint Loading Time, and Operator Building Time.
A parameter plane network fault in a cluster may not affect a training job. Therefore, the cluster scheduling components do not forcibly interrupt the job. When the parameter plane network fault affects a training job, the network timeout mechanism of collective communication is triggered. After a default waiting period of 30 minutes, the cluster scheduling components can detect the fault and trigger resumable training. To solve this problem, the PyTorch Adapter plugin (torch_npu) provides a watchdog fault detection function to determine if training jobs are affected and to reduce fault detection time. For details, see Table 1.
Function |
Watchdog fault detection |
|---|---|
Function Highlights |
When training is started, a monitoring thread is started at the same time to continuously obtain communication exceptions and job execution exceptions. After a fault is detected, an exception is quickly thrown, the training process is terminated, and rescheduling is triggered. |
Instructions |
Only PyTorch 1.11.0, 2.1.0, and later versions are supported. The version of torch_npu must be later than 6.0.RC1. |
Key Operation |
In PyTorch 2.1.0 and later versions, watchdog fault detection is enabled by default. You do not need to manually configure environment variables. (Optional) To disable watchdog fault detection, modify the following environment variables in the shell startup script, for example, train_start.sh. ... # env for breakpoint ckpt export RESUME_MODE_ENABLE=1 export HCCL_ASYNC_ERROR_HANDLING=0 # For details about this environment variable, see Table 5. |
Parallel Store multi-thread link setup optimization: When PyTorch creates communication groups, TCP Store is used for information exchange. As the job scale increases, the information processing performance of the native TCP Store degrades, leading to prolonged times for creating communication groups. To solve this problem, torch_npu supports the optimized Parallel Store built on the native TCP Store. For details, see Table 2.
Function |
Parallel Store |
|---|---|
Function Highlights |
During multiple threads process link setup, this function can reduce both the waiting time of the link setup request queue and the overall link setup time. |
Instructions |
For PyTorch 1.11.0, the version of torch_npu must be later than 6.0.RC1. For PyTorch 2.1.0 or later, the version of torch_npu must be later than 6.0.RC3. |
Key Operation |
In the shell script (for example, train_start.sh) for starting training, change the torchrun command to torch_npu_run. For example: Change torchrun train.py --train_parameter=xxx .... To torch_npu_run train.py --train_parameter=xxx .... |
Function |
Native HCCL link setup performance optimization |
|---|---|
Function Highlights |
By asynchronously completing collective communication information negotiation, multiple threads reduce both the negotiation time and the overall link setup time. |
Instructions |
Only CANN 8.0.RC2 and later versions are supported. |
Key Operation |
None |
Function |
Link setup in RankTable mode |
|---|---|
Function Highlights |
Ascend Operator is used to generate a collective communication configuration file for PyTorch tasks to shorten cluster communication link setup time. |
Instructions |
The version of torch_npu must be later than 6.0.RC3. |
Key Operation |
|
Function |
Asynchronous checkpoint saving |
|---|---|
Function Highlights |
After checkpoints are obtained from the NPU, they are asynchronously written to storage to minimize training loss and the storage period for each checkpoint saving, thereby reducing the training rollback time. |
Instructions |
Only cluster scheduling components and MindIO components of 6.0.RC2 and later are supported. |
Key Operation |
For details about how to install and use MindIO, see Checkpoint Saving, Loading, and Optimization. |
Function |
Efficient checkpoint recovery |
|---|---|
Function Highlights |
MindIO stores the latest checkpoint in memory. During fault recovery, the checkpoint can be read directly from memory, reducing checkpoint reading time. |
Instructions |
Only cluster scheduling components and MindIO components of 6.0.RC2 and later are supported. |
Key Operation |
For details about how to install and use MindIO, see Checkpoint Saving, Loading, and Optimization. |
The operator binary and operator building cache are incompatible. Select either of them.
Function |
Operator binary |
|---|---|
Function Highlights |
During operator building, the preset operator binary is loaded in advance so that the operator can be executed without building. |
Instructions |
Only CANN 8.0.RC2 and later versions are supported. |
Key Operation |
In the Python startup script, add the operator binary configuration command to enable operator binary. torch.npu.set_compile_mode(jit_compile=False) |
Function |
Operator building cache |
|---|---|
Function Highlights |
During operator building, the operator building cache file saved on the storage device is loaded, which can reduce the building time. |
Instructions |
Only CANN 8.0.RC2 and later versions are supported. |
Key Operation |
|