# US 2025/0378338 A1 · Model training method and apparatus based on hybrid parallelism manner, and device

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0378338 A1
- Document ID: US20250378338A1
- Status: Published application
- Kind: A1
- Application number: 19/301,010
- Filed: 2025-08-15
- Published: 2025-12-11
- Earliest claimed: 2023-02-16
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Fanxin LI; Shixiong ZHAO; Heming CUI; Sen WANG; Li CHEN; Gong ZHANG
- Web page: https://patentgrep.com/patent/US20250378338A1

## CPC

- G06F 9/5066: {Algorithms for mapping a plurality of inter-dependent sub-tasks onto a plurality of physical CPUs (mappping at compile time, see G06F8/451)}
- G06N 3/084: Backpropagation, e.g. using gradient descent
- G06F 9/5038: {considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration (scheduling strategies G06F9/4881 and subgroups)}
- G06N 3/045: Combinations of networks
- G06N 3/063: using electronic means
- G06N 3/098: Distributed learning, e.g. federated learning
- G06F 2209/5017: Task decomposition
- G06F 2209/509: Offload
- G06F 2209/541: Client-server
- G06N 3/0475: Generative networks
- G06N 3/09: Supervised learning
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

This application discloses a model training method and apparatus based on a hybrid parallelism manner. In this method, a neural network model is divided into a plurality of pipeline stages, and each pipeline stage includes a plurality of sub-stages of the neural network model. Computing nodes corresponding to the plurality of pipeline stages are invoked in a hybrid parallelism manner according to a sequence of sub-stages in the neural network model. When iterative training is performed on a network layer in a corresponding pipeline stage, because sub-stages at same locations in adjacent pipeline stages are consecutive in the neural network model, the computing node does not need to wait for completion of forward propagation of a previous pipeline stage, and can perform forward propagation on the corresponding pipeline stage only after forward propagation of the 1st sub-stage in the previous pipeline stage is completed.

## Claims

### Claim 1

A model training method based on a hybrid parallelism manner, wherein the hybrid parallelism manner comprises a data parallelism manner and a pipeline parallelism manner, and the method comprises:
determining a plurality of pipeline stages of a neural network model in the pipeline parallelism manner, wherein each pipeline stage comprises a plurality of sub-stages of the neural network model, sub-stages at same locations in adjacent pipeline stages are consecutive in the neural network model, and the sub-stage comprises at least one network layer of the neural network model; and
invoking, in the hybrid parallelism manner according to a sequence of sub-stages in the neural network model, computing nodes corresponding to the plurality of pipeline stages, to perform iterative training on network layers in the corresponding pipeline stages.

### Claim 2 (depends on 1)

The method according to claim 1, wherein determining the plurality of pipeline stages of the neural network model in the pipeline parallelism manner comprises:
determining a plurality of slices of the neural network model, wherein each slice comprises a plurality of consecutive network layers in the neural network model;
partitioning each of the plurality of slices, to obtain a plurality of sub-stages of each slice, wherein network layers in adjacent sub-stages are consecutive; and
combining sub-stages at same locations in the plurality of slices to form a pipeline stage.

### Claim 3 (depends on 1)

The method according to claim 1, wherein invoking, in the hybrid parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, to perform iterative training on the network layers in the corresponding pipeline stages comprises:
in any iterative training process, invoking, in the pipeline parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, and sequentially obtaining gradient information of each sub-stage in a corresponding pipeline stage for a plurality of data batches; and
updating, in the data parallelism manner, model parameters of a network layer in one sub-stage based on gradient information of the sub-stage for the plurality of data batches, each time the gradient information of the sub-stage for the plurality of data batches is obtained.

### Claim 4 (depends on 3)

The method according to claim 3, wherein invoking, in the pipeline parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, and sequentially obtaining the gradient information of each sub-stage in the corresponding pipeline stage for the plurality of data batches comprises:
for any sub-stage in any pipeline stage, each time a forward data batch of the sub-stage is obtained, invoking a first computing node, and performing forward propagation computation on the forward data batch based on model parameters of a network layer in the sub-stage, to obtain a forward computation result of the sub-stage, wherein the first computing node is a computing node corresponding to the pipeline stage, and the forward data batch is any data batch in the plurality of data batches when the sub-stage is the 1st sub-stage of the neural network model, or the forward data batch is a forward computation result of a previous sub-stage of the sub-stage in the neural network model when the sub-stage is not the 1st sub-stage; and
each time a backward data batch of the sub-stage is obtained, invoking the first computing node, performing backward propagation computation on the backward data batch based on the model parameters of the sub-stage to obtain a backward computation result of the sub-stage, and obtaining gradient information of the sub-stage based on the backward computation result, wherein the backward data batch is obtained based on the forward computation result of the sub-stage when the sub-stage is the last sub-stage of the neural network model, or the backward data batch is a backward computation result of a next sub-stage of the sub-stage in the neural network model when the sub-stage is not the last sub-stage.

### Claim 5 (depends on 4)

The method according to claim 4, wherein the computing nodes corresponding to the plurality of pipeline stages are located on different computing devices, computing nodes corresponding to a same pipeline stage are located on a same computing device, and the method further comprises:
if the sub-stage is not the last sub-stage of the neural network model, synchronizing the forward computation result of the sub-stage in the first computing node to a second computing node through a point-to-point communication operation in a first communication library, wherein the second computing node is a computing node corresponding to a pipeline stage to which the next sub-stage of the sub-stage in the neural network model belongs; and
if the sub-stage is not the 1st sub-stage of the neural network model, synchronizing the backward computation result of the sub-stage in the first computing node to a third computing node through the communication operation, wherein the third computing node is a computing node corresponding to a pipeline stage to which the previous sub-stage of the sub-stage in the neural network model belongs.

### Claim 6 (depends on 3)

The method according to claim 3, wherein the neural network model is a copy of a target neural network model, and the target neural network model has a plurality of copies; and
updating, in the data parallelism manner, the model parameters of the network layer in the sub-stage based on the gradient information of the sub-stage for the plurality of data batches, each time the gradient information of the sub-stage for the plurality of data batches is obtained comprises:
each time the gradient information of the sub-stage in the plurality of copies for the plurality of data batches is obtained, summing up the gradient information of the sub-stage in the plurality of copies for the plurality of data batches through an all-reduce operation in a second communication library to obtain total gradient information of the sub-stage, and updating the model parameters of the network layer in the sub-stage based on the total gradient information.

### Claim 7

A model training apparatus, wherein the model training apparatus comprises a memory and a processor;
the memory is configured to store a program or instructions, and the program or the instructions, when executed, cause the processor to:
determine a plurality of pipeline stages of a neural network model in the pipeline parallelism manner, wherein each pipeline stage comprises a plurality of sub-stages of the neural network model, sub-stages at same locations in adjacent pipeline stages are consecutive in the neural network model, and the sub-stage comprises at least one network layer of the neural network model; and
invoke, in the hybrid parallelism manner according to a sequence of sub-stages in the neural network model, computing nodes corresponding to the plurality of pipeline stages, to perform iterative training on network layers in the corresponding pipeline stages.

### Claim 8 (depends on 7)

The apparatus according to claim 7, wherein determining the plurality of pipeline stages of the neural network model in the pipeline parallelism manner comprises:
determining a plurality of slices of the neural network model, wherein each slice comprises a plurality of consecutive network layers in the neural network model;
partitioning each of the plurality of slices, to obtain a plurality of sub-stages of each slice, wherein network layers in adjacent sub-stages are consecutive; and
combining sub-stages at same locations in the plurality of slices to form a pipeline stage.

### Claim 9 (depends on 7)

The apparatus according to claim 7, wherein invoking, in the hybrid parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, to perform iterative training on the network layers in the corresponding pipeline stages comprises:
in any iterative training process, invoking, in the pipeline parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, and sequentially obtaining gradient information of each sub-stage in a corresponding pipeline stage for a plurality of data batches; and
updating, in the data parallelism manner, model parameters of a network layer in one sub-stage based on gradient information of the sub-stage for the plurality of data batches, each time the gradient information of the sub-stage for the plurality of data batches is obtained.

### Claim 10 (depends on 9)

The apparatus according to claim 9, wherein invoking, in the pipeline parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, and sequentially obtaining the gradient information of each sub-stage in the corresponding pipeline stage for the plurality of data batches comprises:
for any sub-stage in any pipeline stage, each time a forward data batch of the sub-stage is obtained, invoking a first computing node, and performing forward propagation computation on the forward data batch based on model parameters of a network layer in the sub-stage, to obtain a forward computation result of the sub-stage, wherein the first computing node is a computing node corresponding to the pipeline stage, and the forward data batch is any data batch in the plurality of data batches when the sub-stage is the 1st sub-stage of the neural network model, or the forward data batch is a forward computation result of a previous sub-stage of the sub-stage in the neural network model when the sub-stage is not the 1st sub-stage; and
each time a backward data batch of the sub-stage is obtained, invoking the first computing node, performing backward propagation computation on the backward data batch based on the model parameters of the sub-stage to obtain a backward computation result of the sub-stage, and obtaining gradient information of the sub-stage based on the backward computation result, wherein the backward data batch is obtained based on the forward computation result of the sub-stage when the sub-stage is the last sub-stage of the neural network model, or the backward data batch is a backward computation result of a next sub-stage of the sub-stage in the neural network model when the sub-stage is not the last sub-stage.

### Claim 11 (depends on 10)

The apparatus according to claim 10, wherein the computing nodes corresponding to the plurality of pipeline stages are located on different computing devices, computing nodes corresponding to a same pipeline stage are located on a same computing device, and the method further comprises:
if the sub-stage is not the last sub-stage of the neural network model, synchronizing the forward computation result of the sub-stage in the first computing node to a second computing node through a point-to-point communication operation in a first communication library, wherein the second computing node is a computing node corresponding to a pipeline stage to which the next sub-stage of the sub-stage in the neural network model belongs; and
if the sub-stage is not the 1st sub-stage of the neural network model, synchronizing the backward computation result of the sub-stage in the first computing node to a third computing node through the communication operation, wherein the third computing node is a computing node corresponding to a pipeline stage to which the previous sub-stage of the sub-stage in the neural network model belongs.

### Claim 12 (depends on 9)

The apparatus according to claim 9, wherein the neural network model is a copy of a target neural network model, and the target neural network model has a plurality of copies; and
updating, in the data parallelism manner, the model parameters of the network layer in the sub-stage based on the gradient information of the sub-stage for the plurality of data batches, each time the gradient information of the sub-stage for the plurality of data batches is obtained comprises:
each time the gradient information of the sub-stage in the plurality of copies for the plurality of data batches is obtained, summing up the gradient information of the sub-stage in the plurality of copies for the plurality of data batches through an all-reduce operation in a second communication library to obtain total gradient information of the sub-stage, and updating the model parameters of the network layer in the sub-stage based on the total gradient information.

### Claim 13

A non-transitory computer-readable storage medium, wherein the storage medium stores at least one piece of program code, and the at least one piece of program code, when read by a processor, cause the processor to:
determine a plurality of pipeline stages of a neural network model in the pipeline parallelism manner, wherein each pipeline stage comprises a plurality of sub-stages of the neural network model, sub-stages at same locations in adjacent pipeline stages are consecutive in the neural network model, and the sub-stage comprises at least one network layer of the neural network model; and
invoke, in the hybrid parallelism manner according to a sequence of sub-stages in the neural network model, computing nodes corresponding to the plurality of pipeline stages, to perform iterative training on network layers in the corresponding pipeline stages.

### Claim 14 (depends on 13)

The storage medium according to claim 13, wherein determining the plurality of pipeline stages of the neural network model in the pipeline parallelism manner comprises:
determining a plurality of slices of the neural network model, wherein each slice comprises a plurality of consecutive network layers in the neural network model;
partitioning each of the plurality of slices, to obtain a plurality of sub-stages of each slice, wherein network layers in adjacent sub-stages are consecutive; and
combining sub-stages at same locations in the plurality of slices to form a pipeline stage.

### Claim 15 (depends on 13)

The storage medium according to claim 13, wherein invoking, in the hybrid parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, to perform iterative training on the network layers in the corresponding pipeline stages comprises:
in any iterative training process, invoking, in the pipeline parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, and sequentially obtaining gradient information of each sub-stage in a corresponding pipeline stage for a plurality of data batches; and
updating, in the data parallelism manner, model parameters of a network layer in one sub-stage based on gradient information of the sub-stage for the plurality of data batches, each time the gradient information of the sub-stage for the plurality of data batches is obtained.

### Claim 16 (depends on 15)

The storage medium according to claim 15, wherein invoking, in the pipeline parallelism manner according to the sequence of the sub-stages in the neural network model, the computing nodes corresponding to the plurality of pipeline stages, and sequentially obtaining the gradient information of each sub-stage in the corresponding pipeline stage for the plurality of data batches comprises:
for any sub-stage in any pipeline stage, each time a forward data batch of the sub-stage is obtained, invoking a first computing node, and performing forward propagation computation on the forward data batch based on model parameters of a network layer in the sub-stage, to obtain a forward computation result of the sub-stage, wherein the first computing node is a computing node corresponding to the pipeline stage, and the forward data batch is any data batch in the plurality of data batches when the sub-stage is the 1st sub-stage of the neural network model, or the forward data batch is a forward computation result of a previous sub-stage of the sub-stage in the neural network model when the sub-stage is not the 1st sub-stage; and
each time a backward data batch of the sub-stage is obtained, invoking the first computing node, performing backward propagation computation on the backward data batch based on the model parameters of the sub-stage to obtain a backward computation result of the sub-stage, and obtaining gradient information of the sub-stage based on the backward computation result, wherein the backward data batch is obtained based on the forward computation result of the sub-stage when the sub-stage is the last sub-stage of the neural network model, or the backward data batch is a backward computation result of a next sub-stage of the sub-stage in the neural network model when the sub-stage is not the last sub-stage.

### Claim 17 (depends on 16)

The storage medium according to claim 16, wherein the computing nodes corresponding to the plurality of pipeline stages are located on different computing devices, computing nodes corresponding to a same pipeline stage are located on a same computing device, and the method further comprises:
if the sub-stage is not the last sub-stage of the neural network model, synchronizing the forward computation result of the sub-stage in the first computing node to a second computing node through a point-to-point communication operation in a first communication library, wherein the second computing node is a computing node corresponding to a pipeline stage to which the next sub-stage of the sub-stage in the neural network model belongs; and
if the sub-stage is not the 1st sub-stage of the neural network model, synchronizing the backward computation result of the sub-stage in the first computing node to a third computing node through the communication operation, wherein the third computing node is a computing node corresponding to a pipeline stage to which the previous sub-stage of the sub-stage in the neural network model belongs.

### Claim 18 (depends on 15)

The storage medium according to claim 15, wherein the neural network model is a copy of a target neural network model, and the target neural network model has a plurality of copies; and
updating, in the data parallelism manner, the model parameters of the network layer in the sub-stage based on the gradient information of the sub-stage for the plurality of data batches, each time the gradient information of the sub-stage for the plurality of data batches is obtained comprises:
each time the gradient information of the sub-stage in the plurality of copies for the plurality of data batches is obtained, summing up the gradient information of the sub-stage in the plurality of copies for the plurality of data batches through an all-reduce operation in a second communication library to obtain total gradient information of the sub-stage, and updating the model parameters of the network layer in the sub-stage based on the total gradient information.
