Resumable Training APIs

taskd.python.toolkit.recover_module.recover_manager. DLRecoverManager (Internal, Do Not Call)

Function Description

The DLRecoverManager class provides APIs related to process-level recovery and process-level online recovery. The client imports it into the client code as a Python package.

The APIs provided by the DLRecoverManager class may throw exceptions. The caller is responsible for catching and handling these exceptions.

init(self, info: pb.ClientInfo, server_addr: str)

Constructs a DLRecoverManager for subsequent communication.

Table 1 Parameters

ParameterTypeDescription
infopb.ClientInfo

info.jobId: str type, the job ID.

info.role: str type, the client role.

server_addrstrServer address

register(self, request: pb.ClientInfo) -> pb.Status

Registers a client. The server performs pre-recovery initialization operations for the job specified by the request.

Table 2 Parameters

ParameterTypeDescription
requestpb.ClientInfo

request.jobId: str type, job ID.

request.role: str type, client role.

Table 3 Return value description

Return Value TypeDescription
Status

Status.info: str type, return information description.

Status.code: int type. 0 indicates success; other values indicate failure. For details about return codes, see Return Codes.

def start_subscribe(self, frame: str = "pytorch")

The client and server establish a gRPC persistent connection, through which the server communicates unidirectionally with the client. For example, when a fault occurs, the server sends the client information such as a training stop signal and global faulty process rank.

Table 4 Parameters

ParameterTypeDescription
framestrIndicates the AI framework used by the job.

init_clusterd(self)

Initializes the ClusterD server status on the client side to ensure normal registration and connection establishment for subsequent jobs.

report_stop_complete(code: int, msg: str, fault_ranks: dict) -> int

Function Description

The client reports to the server that the job process has stopped. Typically, after the client receives a stop training signal from the server, the client stops the training job process and then reports to the server that the job process has stopped.

Input Parameters

Table 1 Parameter description

ParameterTypeDescription
codeintStatus code
msgstrReturn information
fault_ranksdictRank fo the faulty process

Return Value

Table 2 Return value description

Return Value TypeDescription
int0 indicates success, and other return values indicate failure. For details about return codes, see Return Codes.

report_recover_strategy(fault_ranks: dict, strategy_list: list) -> int

Function Description

The client provides the server with the recovery strategies it supports, so that the server can select the optimal recovery strategy. The server then sends it to the client through the persistent connection established by start_subscribe.

Input Parameters

Table 1 Parameter Description

ParameterTypeDescription
fault_ranksdictRank of the faulty process
strategy_listlistRecovery strategy list

Return Value

Table 2 Return value description

Return Value TypeDescription
int0 indicates success, and other return values indicate failure. For details about return codes, see Return Codes.

report_recover_status(code: int, msg: str, fault_ranks: dict, strategy: str) -> int

Function Description

The client reports the job recovery status to the server.

Input Parameters

Table 1 Parameter description

ParameterTypeDescription
codeintStatus code
msgstrReturn information
fault_ranksdictRank of the faulty process
strategystrRecovery strategy

Return Value

Table 2 Return value description

Return Value TypeDescription
int0 indicates success, and other return values indicate failure. For details about return codes, see Return Codes.

report_process_fault(fault_ranks: dict) -> int

Function Description

The client reports a service-plane fault in the job process. When the client detects a fault first, it reports the information of the rank where the service-plane fault occurred to the server.

Input Parameters

Table 1 Parameter description

ParameterTypeDescription
fault_ranksdictRank of the faulty process

Return Value

Table 2 Return value description

Return Value TypeDescription
int0 indicates success, and other return values indicate failure. For details about return codes, see Return Codes.

taskd.python.framework.agent.ms_mgr.msrun_plugin. MSRunPlugin

The MSRunPlugin class provides MindSpore process management functions. It is called by MindSpore and integrated into the MindSpore package.

register_callbacks(self, operator, func)

Function Description

Registers a process management function with TaskD for subsequent use in managing the process lifecycle.

Input Parameters

Table 1 Parameter description

ParameterTypeDescription
operatorstringThe type of callback currently being injected.
  • KILL_WORKER: Registers a stop method for the MindSpore process to stop a specific training process.
  • START_ALL_WORKER: Registers a start method for the MindSpore process to start all processes on the current node.
  • MONITOR: Registers a monitoring method for the MindSpore process to return information about each rank process on the current node.
  • START_WORKER_LIST: Registers a start method for the MindSpore process to start some processes on the current node.
funcFunctionThe function callback for the currently registered function

start(self)

Calls the MSRunPlugin start method to allow TaskD to take over MindSpore training process management.

init(self)

Constructs the MSRunPlugin class for subsequent instantiation and invocation by the user.