Hybrid expert model operating method and system

By employing a hybrid parallel strategy DP+TP and TP+EP in the MoE model, the computational efficiency and speed issues of the MoE model in a multi-node environment are solved, and efficient MoE model operation is achieved.

CN123180218APending Publication Date: 2026-11-27HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510688818.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-26
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

When the MoE model runs on multiple computing nodes, the unreasonable use of memory, computing, and communication resources leads to reduced computing efficiency, slower computing speed, and greater communication latency, which affects business operations.

Method used

The hybrid parallel strategies DP+TP and TP+EP are adopted to execute the computation of the attention network and the expert network in parallel on multiple computing nodes, respectively. This approach makes reasonable use of memory, computing, and communication resources and decouples the parallel strategies of the attention network and the expert network to achieve efficient operation.

Benefits of technology

This improves the computational efficiency and speed of the MoE model across multiple computing nodes, ensuring the efficient operation of the MoE model while balancing the computational efficiency and communication overhead of the computing nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123180218A_ABST
    Figure CN123180218A_ABST
Patent Text Reader

Abstract

The application provides a running method and system of a MoE model. The method comprises: in multiple computing nodes, adopting a hybrid parallel strategy DP+TP for an attention network, so that the multiple computing nodes are divided into i first computing node sets; each first computing node set obtains first model parameters; model parameters of the attention network are divided into i first model parameters; each computing node in each first computing node set obtains first data; input data of the attention network are divided into j first data; and then the multiple computing nodes perform parallel computation of the attention network. In addition, in the multiple computing nodes, another parallel strategy is adopted for an expert network, so that each computing node in the multiple computing nodes obtains second model parameters, the second model parameters being part of model parameters of the multiple expert networks; and then the multiple computing nodes perform parallel computation of the expert network. The MoE model can be efficiently run on the multiple computing nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to the method and system for operating the MoE model. Background Technology

[0002] Mixture-of-expert (MoE) models include multiple expert networks and have a large parameter scale. Furthermore, MoE models can perform computations using only a subset of the expert networks during operation. Thus, while the large parameter scale enhances the model's inference capabilities, the computational load during MoE model operation does not increase significantly, ensuring efficient training and fast inference.

[0003] The MoE model can run on a system comprising multiple computing nodes (also known as a computing cluster). These nodes collaborate to complete computational tasks, improving computational efficiency and speed, thus enabling efficient MoE operation. However, running a MoE model across multiple nodes involves utilizing their memory, computational, and communication resources. Improper use of any one of these resources can lead to reduced computational efficiency, slower speeds, and higher communication latency, increasing the runtime of the MoE model and impacting business operations. Therefore, there is an urgent need for methods and systems that can efficiently utilize the memory, computational, and communication resources of multiple computing nodes to achieve efficient MoE model operation. Summary of the Invention

[0004] This application provides a method and system for running a hybrid expert model, which can efficiently run the MoE model by making reasonable use of the memory resources of multiple computing nodes, the computing resources of multiple computing nodes, and the communication resources between multiple computing nodes.

[0005] Firstly, a method for operating a MoE model is provided. The MoE model includes an attention network and a MoE layer, and the MoE layer includes multiple expert networks. The method includes: each first set of computing nodes in multiple computing nodes obtains first model parameters; the multiple computing nodes are divided into i first sets of computing nodes, and the model parameters of the attention network are divided into i parts of first model parameters, where i is an integer greater than 1; each computing node in each first set of computing nodes obtains first data, and the input data of the attention network is divided into j parts of first data, where j is an integer greater than 1; each computing node in multiple computing nodes obtains second model parameters, which are partial parameters of the model parameters of the multiple expert networks; the computing nodes in multiple computing nodes process the obtained first data according to the obtained first model parameters to obtain the attention network processing result of the input data; at least some computing nodes in multiple computing nodes process the attention network processing result according to the obtained second model parameters to obtain the expert network processing result.

[0006] In this scheme, a hybrid parallel strategy (DP+TP) is employed for the attention network across multiple computing nodes, allowing multiple nodes to perform the attention network computation in parallel. Similarly, a separate parallel strategy can be used for the expert network across multiple computing nodes, enabling them to perform the expert network computation in parallel. This decouples the parallel strategies of the attention network and the expert network, allowing each network to achieve optimal performance in a distributed computing scenario. Furthermore, the DP+TP hybrid parallel strategy for the attention network can rationally utilize the memory resources, computational resources, and communication resources of multiple computing nodes based on the granularity of the data processed by the attention network. This balances computational efficiency and communication overhead, ensuring efficient computation of the attention network for the MoE model.

[0007] In some possible implementations, multiple expert networks include multiple routing expert networks, and multiple computing nodes are divided into m second sets of computing nodes, where the first set of computing nodes is not entirely identical to the second set of computing nodes. Each computing node in the multiple computing nodes obtains second model parameters, including: each computing node in each second set of computing nodes obtains third model parameters. The multiple routing expert networks are divided into m sets of routing expert networks, and the model parameters of each set of routing expert networks are divided into n sets of third model parameters, where the second model parameters include the third model parameters; where m is an integer greater than 1, and n is an integer greater than 1.

[0008] In this scheme, a hybrid parallel strategy (TP+EP) is adopted for the routing expert network across multiple computing nodes, allowing multiple computing nodes to perform the computation of the routing expert network in parallel. This enables the rational use of memory resources, computational resources, and communication resources among multiple computing nodes, based on the granularity of the data processed by the routing expert network, the number of routing expert networks, and the number of model parameters. This balances load balancing and computational efficiency, ensuring the efficient computation of the routing expert network for the MoE model.

[0009] In some possible implementations, the multiple expert networks include multiple shared expert networks, and the multiple computing nodes are divided into x sets of third computing nodes, where the first set of computing nodes is not exactly the same as the third set of computing nodes; each computing node in the multiple computing nodes obtains second model parameters, including: each computing node in each set of third computing nodes obtains fourth model parameters; the multiple shared expert networks are divided into x sets of shared expert networks, and the model parameters of each set of shared expert networks are divided into y sets of fourth model parameters, where the second model parameters include the fourth model parameters; where x is an integer greater than 1, and y is an integer greater than 1.

[0010] In this scheme, a hybrid parallel strategy (TP+EP) is employed across multiple computing nodes to perform computations on multiple shared expert networks. This allows for the parallel execution of these shared expert network computations by multiple computing nodes. By considering the granularity of the data processed by the shared expert networks, the number of shared expert networks, and the number of model parameters, the scheme rationally utilizes the memory resources, computational resources, and communication resources of multiple computing nodes. This balances load balancing and computational efficiency, ensuring the efficient operation of the shared expert networks for the MoE model. Furthermore, since the routing expert network processes data with different granularity than the shared expert network, different parallel strategies can be applied to them in this scheme. This further optimizes resource utilization, ensuring the efficient operation of both the shared and routing expert networks for the MoE model.

[0011] In some possible implementations, the multiple expert networks include at least one shared expert network, and the multiple computing nodes are divided into z sets of fourth computing nodes, wherein the first set of computing nodes is not exactly the same as the fourth set of computing nodes. Each computing node in the multiple computing nodes obtains second model parameters, including: each computing node in each set of fourth computing nodes obtains fifth model parameters, and the model parameters of at least one shared expert network are divided into z sets of fifth model parameters, wherein the second model parameters include the fifth model parameters; where z is an integer greater than 1.

[0012] In this scheme, a parallel strategy (TP) is employed on at least one shared expert network across multiple computing nodes, allowing multiple computing nodes to execute the computation of the shared expert network in parallel. This enables the rational use of memory resources, computational resources, and communication resources among multiple computing nodes, based on the granularity of the data processed by the shared expert network, the number of shared expert networks, and the number of model parameters. This balances load balancing and computational efficiency, ensuring the efficient operation of the shared expert network for the MoE model. Furthermore, since the granularity of the data processed by the routing expert network differs from that of the shared expert network, different parallel strategies can be applied to the routing expert network and the shared expert network in this scheme. This further enhances resource utilization, ensuring the efficient operation of both the shared expert network and the routing expert network for the MoE model.

[0013] In some possible implementations, at least some of the computing nodes in the plurality of computing nodes process the attention network processing results according to the acquired second model parameters, including: each computing node in each fourth computing node set acquires second data, and the attention network processing results are divided into k parts of second data; the computing nodes in the plurality of computing nodes process the acquired second data according to the acquired fifth model parameters to obtain a shared expert network processing result, the expert network processing result including the shared expert network processing result.

[0014] In this scheme, a hybrid parallel strategy DP+TP is adopted for at least one shared expert network across multiple computing nodes, allowing multiple computing nodes to execute the computation of the shared expert network in parallel. This enables more rational use of the memory resources, computational resources, and communication resources between multiple computing nodes, based on the granularity of the data processed by the shared expert network, the number of shared expert networks, and the number of model parameters of the shared expert networks. This better ensures the efficient computation of the shared expert network for running the MoE model.

[0015] In some possible implementations, the method further includes: determining at least one of the following based on at least one of the following: the model structure of the MoE model, the computing power of multiple computing nodes, the communication link information between multiple computing nodes, and the operating requirements of the MoE model: the first model parameter of each first computing node set, the first data of each computing node, the second model parameter of each computing node, and the second data of each computing node.

[0016] In this scheme, based on at least one of the above aspects, it can more effectively combine various factors that may affect the rational use of memory resources, computing resources, and communication resources between multiple computing nodes, thereby enabling the determination of a more accurate and reasonable parallel strategy and better ensuring the efficient operation of the MoE model.

[0017] In some possible implementations, j satisfies at least one of the following: the difference between the batch size of the input data of the MoE model and j is less than a first threshold; j is greater than i when the communication time of the MoE model is greater than the time for transporting the model parameters of the MoE model.

[0018] In this scheme, j represents the parallelism of the attention network's parallel strategy DP, and the parallelism of DP is determined based on the batch size of the input data of the MoE model. This allows for a better determination of the parallelism of DP according to the granularity of the data processed by the attention network. It enables more rational use of the memory resources, computational resources, and communication resources between multiple computing nodes to perform the computation of the attention network in parallel.

[0019] In some possible implementations, the computing nodes in a plurality of computing nodes process the acquired first data according to the acquired first model parameters to obtain the attention network processing result of the input data, including: each computing node in the plurality of computing nodes processes the acquired first data according to the acquired first model parameters to obtain a first processing result; the plurality of computing nodes aggregate the first processing results of the plurality of computing nodes through reduce-scatter communication, so that each computing node in the plurality of computing nodes obtains a second processing result; the plurality of computing nodes aggregate the second processing results of the plurality of computing nodes through all-gather communication, so that each computing node in the plurality of computing nodes obtains the attention network processing result.

[0020] In this scheme, during the aggregation process to obtain the attention network processing results, the Reduce-Scatter + All-gather hierarchical communication is equivalent to the All-reduce communication, which can achieve the required aggregation effect and avoid redundant communication of the TP and DP domains of the attention network by the All-reduce communication.

[0021] In some possible implementations, at least some of the computing nodes among the multiple computing nodes process the attention network processing results according to the acquired second model parameters to obtain expert network processing results, including: each of the at least some computing nodes processes at least a portion of the data in the attention network processing results according to the acquired second model parameters to obtain a third processing result; the multiple computing nodes aggregate the third processing results of the at least some computing nodes through reduce-scatter communication, so that each of the multiple computing nodes obtains a fourth processing result; the multiple computing nodes aggregate the fourth processing results of the multiple computing nodes through all-gather communication, so that each first computing node in each first computing node set obtains a fifth processing result, and the fifth processing results of the computing nodes in each first computing node set constitute the expert network processing result.

[0022] In this scheme, during the aggregation process to obtain the expert network processing results, the use of Reduce-Scatter + All-gather hierarchical communication is equivalent to using All-reduce communication, which can achieve the required aggregation effect and avoid redundant communication of the TP domain and EP domain of the expert network by All-reduce communication.

[0023] In a second aspect, a system for running a hybrid expert MoE model is provided. The MoE model includes an attention network and a MoE layer, the MoE layer includes multiple expert networks, and the system includes multiple computing nodes. Each computing node among the multiple computing nodes is used to perform the functions performed by each computing node in the running method of the MoE model as described in the first aspect above.

[0024] Thirdly, a computer program product containing instructions is provided, which, when executed by at least one computing node, cause at least one computing node to perform the method of running the MoE model as described in the first aspect.

[0025] Fourthly, a computer-readable storage medium is provided, comprising computer program instructions that, when executed by at least one computing node, enable the at least one computing node to perform the method of operating the MoE model as described in the first aspect.

[0026] Based on the implementation methods provided in the above aspects, this application can be further combined to provide more implementation methods.

[0027] The following description includes more specific details about the implementation methods provided for the above aspects. Attached Figure Description

[0028] Figure 1 An exemplary schematic diagram of the structure of the MoE model provided in the embodiments of this application;

[0029] Figure 2 This is a schematic diagram of the structure of a system for running a MoE model provided in an embodiment of this application;

[0030] Figure 3 An exemplary illustration of the method for running the MoE model provided in the embodiments of this application. Figure 1 ;

[0031] Figure 4 An exemplary illustration of the method for running the MoE model provided in the embodiments of this application. Figure 2 ;

[0032] Figure 5 An exemplary illustration of the method for running the MoE model provided in the embodiments of this application. Figure 3 ;

[0033] Figure 6 An exemplary illustration of the method for running the MoE model provided in the embodiments of this application. Figure 4 ;

[0034] Figure 7 This is a schematic diagram of the structure of a computing node provided in an embodiment of this application. Detailed Implementation

[0035] In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or multiple items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0036] To facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish between identical or similar items with substantially the same function and effect, or to distinguish between objects with different functions and effects. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" are not necessarily different. Furthermore, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is being used as an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present related concepts in a concrete manner for ease of understanding.

[0037] To make the technical solutions of the embodiments of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0038] Mixture-of-expert (MoE) models, based on transformer models, combine multiple expert networks. Each expert network is used on a subset of the input data to collectively perform a task. MoE models can be used for various data processing tasks, such as natural language processing. For example, MoE models can be used as large language models to process one or more types of data, including text, images, and audio.

[0039] Figure 1 An exemplary schematic diagram of the structure of the MoE model is shown. (As shown) Figure 1 As shown, the MoE model comprises multiple modules (e.g., multiple decoders), each module including an attention network (also known as an attention mechanism) and a MoE layer. A MoE layer consists of a gating network (also known as a router) and multiple expert networks (e.g., 8, 16, 64, etc.). Each expert network is an independent sub-network (also known as a sub-model) and can be implemented using various feasible network structures. The gating network can also be implemented using various feasible network structures.

[0040] During the operation of the MoE model, input data is fed into the model and processed sequentially by various modules (such as decoders) to obtain the processed results. Input data can include a batch of data, the batch size of which can be set according to requirements. Each data point in a batch can be a sequence of tokens. A token is a basic unit derived from the partitioning of data; for example, if the data is text, tokens can be words, punctuation marks, numbers, other special characters, etc.

[0041] In each module (e.g., the decoder): the input data of the module is first processed by an attention network to obtain the attention network processing result; then, the attention network processing result is input into the MoE layer, where the gating network determines the expert network used to process each token in the attention network processing result; the gating network can activate the expert network used to process the attention network processing result (a portion of the expert networks in the MoE layer); and each token in the attention network processing result is processed by the corresponding expert network to obtain the processing result of each token; the processing result of the MoE layer (which can be called the expert network processing result) is obtained based on the processing results of all tokens.

[0042] For example, as a case study, the gating network determines that the token "More" is processed by the second expert network, while the token "Parameters" is processed by the first expert network. The way the gating network routes tokens is a key aspect of the MoE layer's usage; the gating network is trained along with the other parts of the MoE model.

[0043] In some implementations, multiple expert networks in a MoE layer can include two types of expert networks: routing expert networks and shared expert networks. Routing expert networks process one or more tokens in the input data of the MoE layer; a MoE layer can include multiple routing expert networks. Shared expert networks process all tokens in the input data of the MoE layer; a MoE layer can include one or more shared expert networks. The processing results of the routing expert networks and the shared expert networks are fused to obtain the processing result of the MoE layer.

[0044] In a specific embodiment, for any token input to the MoE layer, a gating network first determines the matching score between the token and each routing expert network. The matching score reflects the degree of fit between the token and each routing expert network. Then, the gating network selects K routing expert networks (K is an integer greater than or equal to 1) for the token, and these K routing expert networks have the highest matching scores among all routing expert networks. Each of the K routing expert networks selected by the gating network processes the token, obtaining its own processing result. A shared expert network also processes each token, obtaining its own processing result. Finally, the processing results of the K routing expert networks are aggregated, and the aggregated result is then fused with the processing result of the shared expert network to obtain the MoE layer processing result for the token.

[0045] In each module (such as the decoder): the attention network processing results can first undergo residual connection processing (e.g., residual add) and normalization processing (e.g., RMSnorm). The attention network processing results after residual connection processing and normalization processing are then input into the MoE layer for processing. Furthermore, the processing results of the MoE layer can first undergo residual connection processing and normalization processing. The processing results of the MoE layer after residual connection processing and normalization processing can continue to be input into the next model component for processing, such as continuing to be input into the next decoder for processing.

[0046] In the embodiments of this application, the operation process of the MoE model may include the training process of the MoE model and the inference process of the MoE model.

[0047] Based on the aforementioned structure of the MoE model, the MoE model can be obtained by replacing each feedforward neural network (FFN) in the transformer model (which includes multiple modules such as multiple decoders) with a MoE layer. The MoE model can have a large parameter scale, but during operation, only a portion of the expert network is used for computation. Thus, while having a large parameter scale can improve the model's inference ability, the computational load during operation does not increase significantly, ensuring efficient training and fast inference.

[0048] The MoE model can run on a system with multiple computing nodes (also known as a computing cluster). Multiple computing nodes can work together to complete the computational tasks during the operation of the MoE model, thereby improving the computational efficiency and speed of the MoE model.

[0049] However, running the MoE model across multiple computing nodes involves utilizing the memory resources, computational resources, and communication resources of those nodes. If any one of these resources is used inappropriately, it can easily lead to reduced computational efficiency, slower computation speed, and higher communication latency on the multiple computing nodes during MoE model execution. This increases the duration of the MoE model's execution and impacts business operations.

[0050] Based on this, embodiments of this application provide a method for running a MoE model and a system for running a MoE model, which enables multiple computing nodes to jointly complete the computational tasks during the MoE model's operation, thereby improving the computational efficiency and speed. Furthermore, during the joint operation of the MoE model by multiple computing nodes, the system can efficiently utilize the memory resources, computational resources, and communication resources of the multiple computing nodes, ensuring the efficient completion of computational tasks.

[0051] The following section introduces the system used to run the MoE model. Figure 2 A schematic diagram of the system structure for running the MoE model is shown. System 200 (also referred to as a computing cluster) includes multiple computing nodes, such as computing node 1, computing node 2, computing node 3, computing node 4, computing node 5, computing node 6, computing node 7, and computing node 8.

[0052] Multiple computing nodes (such as computing nodes 1 to 8) can form a certain network topology (or interconnection topology) to facilitate communication between multiple processors. The computing nodes can be connected via communication links. Furthermore, various network topologies can be formed by multiple computing nodes, and this application embodiment does not impose any limitations on this.

[0053] As an example, such as Figure 2 As shown in Figure 210, each of the computing nodes 1, 2, 3, 4, 5, 6, 7, and 8 is communicatively connected to every other computing node. This network topology can also be called a fully interconnected network.

[0054] As yet another example, such as Figure 2As shown in Figure 220, compute node 1 is connected to compute node 2, compute node 2 is connected to compute node 3, compute node 3 is connected to compute node 4, compute node 4 is connected to compute node 5, compute node 5 is connected to compute node 6, compute node 6 is connected to compute node 7, compute node 7 is connected to compute node 8, compute node 8 is connected to compute node 1, compute node 2 is connected to compute node 7, and compute node 3 is connected to compute node 6. This network topology can also be called a 2D-mesh.

[0055] The computing node in this application embodiment can be a computing device or a computing chip. Specifically, the computing device can include a terminal device or a network device. The terminal device can include computers, mobile terminals, tablets, laptops, desktop computers, all-in-one computers, augmented reality (AR) devices, virtual reality (VR) devices, mixed reality (MR) devices, extended reality (ER) devices, personal digital assistants (PDAs), ultra-mobile personal computers (UMPCs), etc. Terminal devices can also include edge computing devices (e.g., boxes carrying processing chips). Network devices can include artificial intelligence (AI) servers, blade servers, high-density servers, rack servers, etc. The computing chip can include a central processing unit (CPU), a graphics processing unit (GPU), a tensor processing unit (TPU), a neural network processing unit (NPU), etc. In some embodiments, a processor may include one or more dies, and a computing chip may also include dies in the processor. Each die in the processor can perform computing functions and store data as an independent functional chip.

[0056] It is worth noting that, attached Figure 2 This is merely a schematic diagram of the architecture of a system for running a MoE model provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc. shown in the figure do not constitute any limitation.

[0057] Each computing node in system 200 can be used to acquire data and / or information, process data and / or information, and communicate with other computing nodes to transmit data and / or information, thereby enabling multiple computing nodes to jointly run the MoE model to complete computational tasks. It can be understood that the steps performed by each computing node in the MoE model running method provided in this application are also the functions that the computing nodes can execute. A system composed of computing nodes with the functions performed by each computing node in the MoE model running method can be provided to users as a product to run the MoE model.

[0058] The following details the method for running the MoE model provided in the embodiments of this application. The method for running the MoE model provided in the embodiments of this application can be... Figure 2 The system 200 shown is implemented. The MoE model can be executed by multiple computing nodes. For ease of understanding, the steps of the MoE model execution method when multiple computing nodes execute it are explained below. The steps executed by any one computing node constitute the MoE model execution method executed by that single computing node.

[0059] In this embodiment of the application, multiple computing nodes (e.g.) can be determined. Figure 2 The parallel strategy for running the MoE model is shown in the diagram (computing nodes 1 to 8), and multiple computing nodes can run the MoE model together according to the parallel strategy to complete the computing task.

[0060] The following section introduces some parallel strategies involved in the embodiments of this application. Parallel strategies may include any one or a combination of data parallelism (DP), tensor parallelism (TP), and expert parallelism (EP).

[0061] Dynamic programming (DP) refers to dividing the input data of a model or its network layers into multiple parts, and distributing these parts to multiple computing nodes for parallel computation. Each computing node processes its own data and obtains its result (such as the gradient of the data). The results from all computing nodes are then aggregated through collective communications. The number of parts into which the input data is divided is called the parallelism of DP.

[0062] Parallelism (TP) refers to splitting the model or the model parameters (such as weights, which can be considered as tensors) of a model or its network layers into multiple parts, and then distributing these parts to multiple computing nodes for parallel computation. The number of parts into which the model parameters are divided is called the parallelism of TP.

[0063] EP refers to dividing the multiple expert networks in the MoE layer of a MoE model into multiple expert network sets. Each expert network set may include one or more expert networks, and these expert network sets are distributed among multiple computing nodes for parallel computation. The number of expert network sets obtained by dividing the multiple expert networks can be called the parallelism of EP.

[0064] As mentioned earlier, the MoE model comprises multiple modules (such as decoders), each of which includes an attention network and a MoE layer. A MoE layer consists of a gating network and multiple expert networks (e.g., 8, 16, 64, etc.).

[0065] In some implementations, the attention network in the MoE model can adopt a first parallel strategy, and the multiple expert networks in the MoE layer can adopt a second parallel strategy. The first parallel strategy and the second parallel strategy can be different.

[0066] In some implementations, the attention network in the MoE model can employ a hybrid parallel strategy DP+TP.

[0067] In some implementations, multiple expert networks in the MoE layer (which may refer to multiple routing expert networks in the MoE layer, or multiple shared expert networks in the MoE layer) can adopt a hybrid parallel strategy TP+EP.

[0068] In some implementations, when the MoE layer includes one or more shared expert networks, the shared expert networks can adopt a parallel strategy TP or a hybrid parallel strategy DP+TP.

[0069] In some implementations, the parallel strategies employed by multiple routing expert networks and one or more shared expert networks can be the same or different. For example, multiple routing expert networks may employ a third parallel strategy, while one or more shared experts may employ a fourth parallel strategy. The third and fourth parallel strategies can be the same or different.

[0070] The following combination Figure 3 , Figure 4 , Figure 5 This paper details several parallel strategies that the MoE model may employ, as well as several implementation examples of running the MoE model according to these parallel strategies to complete computational tasks. The following provides methods for running the MoE model (e.g.) Figure 3 , Figure 4 , Figure 5 The running method of the MoE model provided can be used on multiple computing nodes (e.g., Figure 2The MoE model is implemented on computing nodes 1 through 8 as shown. The attention network of each module (such as the decoder) and multiple expert networks of the MoE model can be deployed and run on multiple computing nodes using the running method of the MoE model provided below.

[0071] Figure 3 An exemplary schematic diagram of how the MoE model is run is shown. Figure 1 .exist Figure 3 In the provided method for running the MoE model, the attention network in the MoE model adopts a hybrid parallel strategy DP+TP, and the parallel strategy adopted by the multiple expert networks in the MoE layer is not restricted (for example, any one of the parallel strategies TP and EP can be used, or a hybrid parallel strategy TP+EP, etc.).

[0072] The attention network employs a hybrid parallel strategy DP+TP, where the parallelism of TP is denoted by i, and the parallelism of DP is denoted by j. i is an integer greater than 1, and j is an integer greater than 1.

[0073] Accordingly, the model parameters of the attention network are divided into i parts (each part of the model parameters can be called the first model parameters), multiple computing nodes are divided into i sets of computing nodes (each set of computing nodes can be called the first set of computing nodes), and the input parameters of the attention network are divided into j parts of data (each part of the data can be called the first data).

[0074] In some embodiments, the first set of computing nodes includes computing nodes with a data volume equal to j.

[0075] As an example, in the hybrid parallel strategy DP+TP used for attention networks, the parallelism of TP is i=4 and the parallelism of DP is j=2.

[0076] Thus, the model parameters A of the attention network are divided into four parts: the first model parameter attn TP-0, the first model parameter attn TP-1, the first model parameter attn TP-2, and the fourth model parameter attn TP-3. Multiple computational nodes (including computational nodes 1 through 8) are divided into four first computational node sets: first set 1 (computational node 1, computational node 2), first set 2 (computational node 3, computational node 4), first set 3 (computational node 5, computational node 6), and first set 4 (computational node 7, computational node 8).

[0077] Furthermore, the input data D of the attention network is divided into two parts: the first data D1 and the first data D2.

[0078] like Figure 3As shown, the method for running the MoE model provided in this application may include the following steps.

[0079] Step 310: Each set of first computing nodes obtains one of the first model parameters from the i sets of first model parameters.

[0080] For example: in the first set of computing nodes 1 (computing node 1, computing node 2), computing node 1 and computing node 2 both obtain the first model parameter attn TP-0; in the first set of computing nodes 2 (computing node 3, computing node 4), computing node 3 and computing node 4 both obtain the first model parameter attn TP-1; in the first set of computing nodes 3 (computing node 5, computing node 6), computing node 5 and computing node 6 both obtain the first model parameter attn TP-2; and in the first set of computing nodes 4 (computing node 7, computing node 8), computing node 7 and computing node 8 both obtain the first model parameter attn TP-3.

[0081] Step 320: Each computing node in each set of first computing nodes obtains one piece of first data from j pieces of first data.

[0082] For example: in the first set of computing nodes 1 (computing node 1, computing node 2), computing node 1 obtains the first data D1, and computing node 2 obtains the first data D2; in the first set of computing nodes 2 (computing node 3, computing node 4), computing node 3 obtains the first data D1, and computing node 4 obtains the first data D2; in the first set of computing nodes 3 (computing node 5, computing node 6), computing node 5 obtains the first data D1, and computing node 6 obtains the first data D2; in the first set of computing nodes 4 (computing node 7, computing node 8), computing node 7 obtains the first data D1, and computing node 8 obtains the first data D2.

[0083] Step 330: Each of the multiple computing nodes obtains the second model parameters, which are a subset of the model parameters of the multiple expert networks.

[0084] There are no restrictions on the parallel strategies adopted by multiple expert networks in the MoE layer (for example, any one of the parallel strategies TP and EP can be used, or a hybrid parallel strategy TP+EP, etc.).

[0085] As an example, in some implementations, in step 330, the model parameters of multiple expert networks (which may refer to multiple routing expert networks in the MoE layer, or multiple shared expert networks in the MoE layer) can be divided into multiple parts according to the parallel strategy TP, or multiple expert networks can be divided into multiple expert network sets according to the parallel strategy EP and assigned to multiple computing nodes for computation (at this time, the second model parameters obtained by each computing node are part of the model parameters of multiple expert networks).

[0086] Step 340: The computing nodes among the multiple computing nodes process the acquired first data according to the acquired first model parameters to obtain the attention network processing result of the input data.

[0087] For example: Computing node 1 processes the acquired first data D1 based on the acquired first model parameter attn TP-0 to obtain the first processing result R1;

[0088] Computing node 2 processes the acquired first data D2 based on the acquired first model parameter attn TP-0 to obtain the first processing result R2;

[0089] Computation node 3 processes the acquired first data D1 based on the acquired first model parameter attn TP-1 to obtain the first processing result R3;

[0090] Computation node 4 processes the acquired first data D2 based on the acquired first model parameter attn TP-1 to obtain the first processing result R4;

[0091] Computation node 5 processes the acquired first data D1 based on the acquired first model parameter attn TP-2 to obtain the first processing result R5;

[0092] Computation node 6 processes the acquired first data D2 based on the acquired first model parameter attn TP-2 to obtain the first processing result R6;

[0093] Computation node 7 processes the acquired first data D1 based on the acquired first model parameter attn TP-3 to obtain the first processing result R7;

[0094] Computation node 8 processes the acquired first data D2 based on the acquired first model parameter attn TP-3 to obtain the first processing result R8;

[0095] The first processing results R1, R2, R3, R4, R5, R6, R7, and R8 are aggregated to obtain the attention network processing result.

[0096] Step 350: At least some of the computing nodes among the multiple computing nodes process the attention network processing results according to the acquired second model parameters to obtain the expert network processing results.

[0097] The gating network of the MoE layer determines which expert network (which can be some of the expert networks in the MoE layer) is used to process the results of the attention network. Each token in the attention network processing result is then processed by its corresponding expert network to obtain the processing result for each token. The processing result of the MoE layer (which can be called the expert network processing result) is obtained based on the processing results of all tokens.

[0098] Thus, at least some of the multiple computing nodes acquire the model parameters of the expert network (which may be a portion of the expert network in the MoE layer) used to process the attention network processing results. These at least some computing nodes then process the attention network processing results based on the acquired second model parameters to obtain the expert network processing results.

[0099] In a specific embodiment, each of the at least some computing nodes processes at least a portion of the data (e.g., one or more tokens) in the attention network processing result according to the acquired second model parameters to obtain a third processing result. The expert network processing result is then obtained by aggregating the third processing results from the at least some computing nodes.

[0100] Figure 4 An exemplary schematic diagram of how the MoE model is run is shown. Figure 2 .exist Figure 4 In the provided method for running the MoE model, the attention network in the MoE model adopts a hybrid parallel strategy of DP+TP, and the multiple routing expert networks in the MoE layer adopt a hybrid parallel strategy of TP+EP.

[0101] and Figure 3 Similarly, the attention network employs a hybrid parallel strategy of DP+TP, where the parallelism of TP is denoted by i, and the parallelism of DP is denoted by j. i is an integer greater than 1, and j is an integer greater than 1.

[0102] The hybrid parallel strategy TP+EP is used for multiple routing expert networks. The parallelism of TP is represented by n, and the parallelism of EP is represented by m. n is an integer greater than 1, and m is an integer greater than 1.

[0103] Accordingly, multiple routing experts are divided into m routing expert network sets, multiple computing nodes are divided into m computing node sets (each computing node set here can be called a second computing node set), and the model parameters of each of the routing expert network sets are divided into n parts of model parameters (each part of model parameters here can be called a third model parameter).

[0104] In some embodiments, the second set of computing nodes includes computing nodes with a data volume equal to n.

[0105] In some embodiments, the first set of computing nodes and the second set of computing nodes may be the same or not completely the same.

[0106] As an example, the MoE layer includes 64 routing expert networks. In the hybrid parallel strategy TP+EP used for the 64 routing expert networks, the parallelism of TP is n=2 and the parallelism of EP is m=4.

[0107] Thus, the 64 routing expert networks are divided into Routing Expert Network Set 1 (including Routing Expert Networks E0 to E15), Routing Expert Network Set 2 (including Routing Expert Networks E16 to E31), Routing Expert Network Set 3 (including Routing Expert Networks E32 to E47), and Routing Expert Network Set 4 (including Routing Expert Networks E48 to E63). Multiple computing nodes (including Computing Node 1 to Computing Node 8) are divided into four second computing node sets: Second Computing Node Set 1 (Computing Node 1 and Computing Node 3), Second Computing Node Set 2 (Computing Node 5 and Computing Node 7), Second Computing Node Set 3 (Computing Node 2 and Computing Node 4), and Second Computing Node Set 4 (Computing Node 6 and Computing Node 8).

[0108] Furthermore, the model parameters of each routing expert network set are divided into two parts: third model parameters WE1 and third model parameters WE2.

[0109] like Figure 4 As shown, the method for running the MoE model provided in this application may include the following steps.

[0110] Step 410: For each set of first computing nodes, obtain one of the first model parameters from the i sets of first model parameters.

[0111] The implementation process of steps 410 and 310 is similar, and can be found in [reference needed]. Figure 3 Description of step 310.

[0112] Step 420: Each computing node in each set of first computing nodes obtains one piece of first data from j pieces of first data.

[0113] The implementation process of steps 420 and 320 is similar, and can be found in [reference needed]. Figure 3 Description of step 320.

[0114] Step 430: Each second set of computing nodes obtains model parameters of a routing expert network set, wherein each computing node in the second set of computing nodes obtains one third model parameter from n third model parameters of a routing expert network set.

[0115] For example: in the second set of computing nodes 1 (computing node 1, computing node 3), computing node 1 obtains the third model parameter WE1 of the routing expert network set 1-E0~E15, and computing node 3 obtains the third model parameter WE2 of the routing expert network set 1-E0~E15.

[0116] In the second set of computing nodes 2 (computing node 5 and computing node 7), computing node 5 obtains the third model parameter WE1 of the routing expert network set 2-E16~E31, and computing node 7 obtains the third model parameter WE2 of the routing expert network set 2-E16~E31.

[0117] In the second set of computing nodes 3 (computing node 2 and computing node 4), computing node 2 obtains the third model parameter WE1 of the routing expert network set 3-E32~E47, and computing node 4 obtains the third model parameter WE2 of the routing expert network set 3-E32~E47.

[0118] Computing node 6 in the second set of computing nodes 4 (computing node 6 and computing node 8) obtains the third model parameter WE1 of the routing expert network set 4-E48~E63, and computing node 8 obtains the third model parameter WE2 of the routing expert network set 4-E48~E63.

[0119] Step 440: The computing nodes among the multiple computing nodes process the acquired first data according to the acquired first model parameters to obtain the attention network processing result of the input data.

[0120] The implementation process of steps 440 and 340 is similar, and can be found in [reference needed]. Figure 3 Description of step 340.

[0121] Step 450: At least some of the multiple computing nodes process the attention network processing results according to the acquired second model parameters (including the third model parameters) to obtain the expert network processing results.

[0122] At least some of the multiple computing nodes acquire model parameters of the routing expert network (which may be a portion of the routing expert network in the MoE layer) used to process the attention network processing results. Thus, these at least some computing nodes process the attention network processing results based on the acquired second model parameters (including third model parameters) to obtain the expert network processing results.

[0123] The implementation process of steps 450 and 350 is similar, and can be found in [reference needed]. Figure 3 Description of step 350.

[0124] Figure 5 An exemplary schematic diagram of how the MoE model is run is shown. Figure 3.exist Figure 5 In the provided method for running the MoE model, the attention network in the MoE model adopts a hybrid parallel strategy of DP+TP, and the multiple shared expert networks in the MoE layer adopt a hybrid parallel strategy of TP+EP.

[0125] Figure 4 Methods and Figure 5 These methods can be used in combination. For example, the attention network in the MoE model adopts a hybrid parallel strategy DP+TP, the multiple routing expert networks in the MoE layer adopt a hybrid parallel strategy TP+EP, and the multiple shared expert networks in the MoE layer also adopt a hybrid parallel strategy TP+EP.

[0126] or, Figure 5 The method may also not restrict the parallel strategies adopted by multiple routing expert networks (for example, any one of TP and EP parallel strategies, or a hybrid parallel strategy TP+EP, etc.).

[0127] The hybrid parallel strategy TP+EP is used for multiple shared expert networks. The parallelism of TP is represented by y, and the parallelism of EP is represented by x. x is an integer greater than 1, and y is an integer greater than 1.

[0128] Accordingly, multiple shared expert networks are divided into x sets of shared expert networks, multiple computing nodes are divided into x sets of computing nodes (each set of computing nodes here can be called the third set of computing nodes), and the model parameters of each set of shared expert networks are divided into y sets of model parameters (each set of model parameters here can be called the fourth set of model parameters).

[0129] In some embodiments, the amount of data in the third set of computing nodes is equal to y.

[0130] In some embodiments, the first set of computing nodes and the third set of computing nodes may be the same or not completely the same. The second set of computing nodes and the third set of computing nodes may be the same or not completely the same.

[0131] The implementation method of the hybrid parallel strategy TP+EP adopted by multiple shared expert networks and Figure 4 The implementation of the hybrid parallel strategy TP+EP adopted by multiple routing expert networks is similar, and will not be elaborated here.

[0132] This application also provides an implementation method for running a MoE model (not shown in the figures). In this implementation, in Figure 3 Based on the provided method for running the MoE model, when the MoE layer includes one or more shared expert networks, the shared expert networks can adopt a parallel strategy TP or a hybrid parallel strategy DP+TP.

[0133] In this context, when the MoE layer includes one or more shared expert networks, and these shared expert networks employ a parallel strategy (TP), the parallelism of TP is denoted by z, where z is an integer greater than 1. Correspondingly, the model parameters of the one or more shared expert networks are divided into z sets of fifth model parameters, and multiple computing nodes are divided into z sets of fourth computing nodes. Each set of fourth computing nodes acquires one set of fifth model parameters from the z sets of fifth model parameters. In some embodiments, the first set of computing nodes and the fourth set of nodes may be the same or not entirely the same.

[0134] In this context, when the MoE layer includes one or more shared expert networks, and these shared expert networks employ a parallel strategy DP+TP, the parallelism of TP is denoted by z, and the parallelism of DP is denoted by k. k is an integer greater than 1. Correspondingly, the model parameters of the one or more shared expert networks are divided into z sets of fifth model parameters, and multiple computational nodes are divided into z sets of fourth computational nodes. Each set of fourth computational nodes acquires one set of fifth model parameters from the z sets. Furthermore, the attention network processing results are divided into k sets of second data, and each computational node in each set of fourth computational nodes acquires one set of second data from the k sets.

[0135] In this way, the computing nodes in multiple computing nodes process the acquired second data according to the acquired fifth model parameters to obtain the shared expert network processing result. Based on the fusion result of the shared expert network processing result and the routing expert network processing result, the expert network processing result can be obtained (in other words, the expert network processing result includes the shared expert network processing result).

[0136] The method for running the MoE model provided in the embodiments of this application (including the above) Figure 3 , Figure 4 , Figure 5 (Based on the operating methods of the MoE model provided, gating networks can be deployed on multiple computing nodes in various feasible ways so that the gating network can perform the required functions during the operation of MoE. For example, each computing node will acquire a gating network.)

[0137] In some implementations, the method for running the MoE model provided in the embodiments of this application (including the above) Figure 3 , Figure 4 , Figure 5The provided method for running the MoE model can determine the parallel strategy for running the MoE model (including the parallel strategy for the attention network and the parallel strategy for the expert network) based on at least one of the following: the model structure of the MoE model, the computing power of multiple computing nodes, the communication link information between multiple computing nodes, and the running requirements of the MoE model. In other words, it can determine at least one of the following information regarding the parallel strategy: the first model parameters of each first set of computing nodes, the first data of each computing node, the second model parameters of each computing node, and the second data of each computing node, based on at least one of the aforementioned factors. Furthermore, it can implement the determination of the parallel strategy for running the MoE model using any computing device.

[0138] As an example, the difference between the batch size of the input data for the MoE model and the parallelism j of the attention network's dynamic programming (DP) is less than a first threshold. For instance, for the prefill stage, the batch size is 4, and j can be set to 4.

[0139] As another example, when the communication time of the MoE model is greater than the model parameter transfer time of the MoE model, the parallelism j of the DP of the attention network is greater than the parallelism i of the TP of the attention network. When the communication time of the MoE model is less than the model parameter transfer time of the MoE model, the parallelism j of the DP of the attention network is less than the parallelism i of the TP of the attention network.

[0140] As another example, for the TP of an attention network, the communication link between the i first computing nodes is a communication link whose bandwidth meets a preset requirement among the communication links between multiple computing nodes. The preset requirement can be that the link bandwidth is greater than a preset threshold, or that the link bandwidth is one of the higher bandwidths among the communication links between multiple computing nodes.

[0141] In some embodiments, considering the high communication cost of the attention network's TP, the parallelism i of the attention network's TP can be limited, for example, by setting i to be less than a second threshold, which can be set according to requirements.

[0142] As another example, the parallelism n of the routing expert network's TP can be increased based on performance analysis data such as the computing power of multiple computing nodes, communication link information between multiple computing nodes, and the operational requirements of the MoE model.

[0143] As another example, the parallelism of the DP of a shared expert network can be determined based on the number of shared expert networks.

[0144] In the MoE model operation method provided in this application embodiment, multiple computing nodes can aggregate the first processing results through ensemble communication to obtain the attention network processing results. The first processing result refers to the processing result obtained by each computing node processing the acquired first data according to the acquired first model parameters.

[0145] Multiple computing nodes can also aggregate the third processing results through ensemble communication to obtain the expert network processing results. The third processing results refer to the results obtained by each computing node processing at least a portion of the data in the attention network processing results based on the acquired second model parameters.

[0146] Group communication is a global communication operation involving all processes in a process group. Its most basic operations include send, receive, copy, intra-group process barrier synchronization, and inter-node process synchronization (signal + wait). These basic operations are combined to form a set of communication templates, also called communication primitives. Examples include: one-to-many broadcast, many-to-one gather, all-gather, one-to-many scatter, many-to-one reduce, all-reduce, reduce-scatter, and many-to-all.

[0147] Figure 6 An exemplary schematic diagram of how the MoE model is run is shown. Figure 4 The following is a combination of... Figure 6 This application provides a detailed description of the communication primitives and corresponding algorithms used in the set communication involved in the operation method of the MoE model provided in the embodiments of this application.

[0148] In this embodiment, reduce-scatter communication and all-gather communication can be used to aggregate the first processing result to obtain the attention network processing result and aggregate the third processing result to obtain the expert network processing result.

[0149] In a specific embodiment, a computing node among multiple computing nodes processes the acquired first data based on the acquired first model parameters to obtain the attention network processing result of the input data, including:

[0150] Each of the multiple computing nodes processes the acquired first data based on the acquired first model parameters to obtain a first processing result; the multiple computing nodes aggregate the first processing results of the multiple computing nodes through reduce-scatter communication, so that each of the multiple computing nodes obtains a second processing result; the multiple computing nodes aggregate the second processing results of the multiple computing nodes through all-gather communication, so that each of the multiple computing nodes obtains the attention network processing result.

[0151] In a specific embodiment, at least some of the computing nodes among the multiple computing nodes process the attention network processing results according to the acquired second model parameters to obtain expert network processing results, including:

[0152] Each of the at least some computing nodes processes at least a portion of the data in the attention network processing result according to the acquired second model parameters to obtain a third processing result; multiple computing nodes aggregate the third processing results of at least some computing nodes through reduce-scatter communication, so that each of the multiple computing nodes obtains a fourth processing result; multiple computing nodes aggregate the fourth processing results of multiple computing nodes through all-gather communication, so that each first computing node in each first computing node set obtains a fifth processing result, and the fifth processing results of all computing nodes in each first computing node set constitute the expert network processing result.

[0153] exist Figure 6 The following example illustrates the set communication involved in the operation of the MoE model:

[0154] The MoE model runs on 8 computing nodes (including computing nodes 1 to 8); a hybrid parallel strategy DP+TP is used for the attention network, where the parallelism of TP is i=4 and the parallelism of DP is j=2; the MoE layer includes 64 routing expert networks, and a hybrid parallel strategy TP+EP is used for the 64 routing expert networks, where the parallelism of TP is n=2 and the parallelism of EP is m=4.

[0155] The model parameters A of the attention network are divided into four parts: the first model parameter attn TP-0, the first model parameter attn TP-1, the first model parameter attn TP-2, and the fourth model parameter attn TP-3.

[0156] The eight computing nodes are divided into four first computing node sets: first computing node set 1 (computing node 1, computing node 2), first computing node set 2 (computing node 3, computing node 4), first computing node set 3 (computing node 5, computing node 6), and first computing node set 4 (computing node 7, computing node 8).

[0157] The input data D of the attention network (including 128 data points from r0 to r127) is divided into two parts: the first data D1 and the first data D2. The first data D1 includes 64 data points from r0 to r63, and the first data D2 includes 64 data points from r64 to r127.

[0158] The 64 routing expert networks were divided into Routing Expert Network Set 1 (including Routing Expert Networks E0 to E15), Routing Expert Network Set 2 (including Routing Expert Networks E16 to E31), Routing Expert Network Set 3 (including Routing Expert Networks E32 to E47), and Routing Expert Network Set 4 (including Routing Expert Networks E48 to E63).

[0159] The model parameters of each routing expert network set are divided into two parts: third model parameters WE1 and third model parameters WE2.

[0160] The eight computing nodes are further divided into four second computing node sets: second computing node set 1 (computing node 1, computing node 3), second computing node set 2 (computing node 5, computing node 7), second computing node set 3 (computing node 2, computing node 4), and second computing node set 4 (computing node 6, computing node 8).

[0161] like Figure 6 As shown:

[0162] Compute node 1 obtains attn TP-0 and D1, and processes D1 based on attn TP-0 to obtain the first processing result R1;

[0163] Compute node 2 obtains attn TP-0 and D2, and processes D2 based on attn TP-0 to obtain the first processing result R2;

[0164] Compute node 3 obtains attn TP-1 and D1, and processes D1 based on attn TP-1 to obtain the first processing result R3;

[0165] Compute node 4 obtains attn TP-1 and D2, and processes D2 based on attn TP-1 to obtain the first processing result R4;

[0166] Compute node 5 obtains attn TP-2 and D1, and processes D1 based on attn TP-2 to obtain the first processing result R5;

[0167] Compute node 6 obtains attn TP-2 and D2, and processes D2 based on attn TP-2 to obtain the first processing result R6;

[0168] Compute node 7 obtains attn TP-3 and D1, and processes D1 based on attn TP-3 to obtain the first processing result R7;

[0169] Compute node 8 obtains attn TP-3 and D2, and processes D2 based on attn TP-3 to obtain the first processing result R8;

[0170] Then, computing nodes 1 to 8 aggregate the first processing results R1 to R8 through reduce-scatter communication, so that computing node 1 obtains the attention network processing results of data r0 to r15, computing node 3 obtains the attention network processing results of data r16 to r31, computing node 5 obtains the attention network processing results of data r32 to r47, computing node 7 obtains the attention network processing results of r48 to r63, computing node 2 obtains the attention network processing results of r64 to r79, computing node 4 obtains the attention network processing results of r80 to r95, computing node 6 obtains the attention network processing results of r96 to r111, and computing node 8 obtains the attention network processing results of r112 to r127.

[0171] Then, computing nodes 1 to 8 aggregate the attention network processing results of data r0 to r127 through all-gather communication, so that each computing node in computing nodes 1 to 8 obtains the attention network processing results of input data D (including the 128 data r0 to r127).

[0172] For example Figure 6 As shown:

[0173] Computation node 1 obtains WE1 from the gated network and routing expert network sets 1-E0 to E15;

[0174] Computation node 2 obtains WE1 from the gated network and routing expert network set 3-E32~E47;

[0175] Computation node 3 obtains WE2 of the gated network and routing expert network sets 1-E0~E15;

[0176] Compute node 4 obtains WE2 from the gated network and routing expert network set 3-E32~E47;

[0177] Computation node 5 obtains WE1 from the gated network and routing expert network set 2-E16~E31;

[0178] Compute node 6 obtains WE1 from the gated network and routing expert network sets 4-E48~E63;

[0179] Compute node 7 obtains WE2 from the gated network and routing expert network set 2-E16~E31;

[0180] Compute node 8 obtains WE2 from the gated network and routing expert network set 4-E48~E63;

[0181] The above-mentioned gating networks select the routing expert network in E0 to E63 to process the attention network processing results of each data in r0 to r127 based on the attention network processing results of the data r0 to r127, and each computing node processes the attention processing results of each data according to the third model parameters of the obtained routing expert network set to obtain the third processing result.

[0182] Then, compute nodes 1 through 8 aggregate the third processing results of each compute node through reduce-scatter communication, so that compute node 1 obtains the routing expert network processing results r0 to r15, compute node 3 obtains the routing expert network processing results r16 to r31, compute node 5 obtains the routing expert network processing results r32 to r47, compute node 7 obtains the routing expert network processing results r48 to r63, compute node 2 obtains the routing expert network processing results r64 to r79, compute node 4 obtains the routing expert network processing results r80 to r95, compute node 6 obtains the routing expert network processing results r96 to r111, and compute node 8 obtains the routing expert network processing results r112 to r127.

[0183] Then, compute nodes 1, 3, 5, and 7 aggregate the routing expert network processing results of data r0 to r63 through all-gather communication, so that each compute node among compute nodes 1, 3, 5, and 7 obtains the routing expert network processing results of the 64 data points r0 to r63; and compute nodes 2, 4, 6, and 8 aggregate the routing expert network processing results of data r64 to r127 through all-gather communication, so that each compute node among compute nodes 2, 4, 6, and 8 obtains the routing expert network processing results of the 64 data points r64 to r127.

[0184] In this embodiment, using Reduce-Scatter + All-gather hierarchical communication is equivalent to using All-reduce communication, which can achieve the desired aggregation effect and avoid redundant communication of the TP and DP domains of the attention network by All-reduce communication.

[0185] In some implementations, the graph positions of communication operators can be optimized for the MoE model's graph structure, reducing redundant vector calculations such as normalization computations (e.g., RMSnorm) and residual join computations. In specific embodiments, reduce-scatter communication and all-gather communication can be performed after normalization computation. Alternatively, reduce-scatter communication and all-gather communication can be performed after residual join computation.

[0186] In this embodiment, the shared expert network processing results can be obtained by aggregating them using a method similar to that used for routing expert network processing results, which will not be elaborated further here. Computing nodes 1 to 8 fuse the routing expert network processing results of each data with the shared expert network processing results of each data to obtain the expert network processing results for each data.

[0187] In some implementations, based on mathematical equivalence, before computing nodes 1 to 8 perform reduce-scatter communication and all-gather communication to aggregate the routing expert network processing results, the processing results of the attention network processing of data r0 to r127 processed by each computing node according to the partial model parameters of the shared expert network can be merged with the third processing results of each computing node. Then, reduce-scatter communication and all-gather communication are performed to aggregate the merged results of each computing node, so that computing nodes 1 to 8 can obtain the expert network processing results of each data.

[0188] It is understood that, in order to achieve the functions in the above embodiments, the computing device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and method steps described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application scenario and design constraints of the technical solution.

[0189] The above text combines Figures 3 to 6 The article describes in detail the operation method of the MoE model provided according to the embodiments of this application. The following will combine... Figure 7This application describes the computing nodes provided according to this application. These computing nodes can be used to implement the functions of any computing node in the above method embodiments, and thus can also achieve the beneficial effects of the above method embodiments.

[0190] Figure 7 The computing node 700 provided in this application embodiment includes a processing unit 741, an interface 742, and an interface 743, wherein the processing unit 741 is used to transmit data through the interface 742 and / or the interface 743.

[0191] It should be noted that the number of interfaces of the computing nodes involved in the embodiments of this application can be determined according to the actual communication needs and the communication capabilities that the interfaces can support. This application does not impose any restrictions on this.

[0192] Optionally, the compute node 700 also includes a storage unit 744 for storing data to be transmitted.

[0193] Computing node 700 can be implemented as any of the multiple computing nodes used to run the MoE model (e.g., computing node 1, computing node 2, computing node 3, computing node 4, computing node 5, computing node 6, computing node 7, computing node 8, etc. in system 200), and can be used to implement the functions performed by any of the multiple computing nodes used to run the MoE model.

[0194] For more details on the functionality performed by any of the multiple compute nodes used to run the MoE model, please refer to [link to relevant documentation]. Figures 3-6 And its related descriptions.

[0195] In one implementation, any one of the computing nodes used to run the MoE model can also be implemented in software.

[0196] A compute node may include code running on a compute instance. A compute instance can be at least one of a physical host (compute device), a virtual machine, a container, or other compute devices. Furthermore, the aforementioned compute devices may be one or more. For example, a compute node may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the application can be distributed within the same region or in different regions. The multiple hosts / virtual machines / containers used to run the code can be distributed within the same Availability Zone (AZ) or in different AZs, each AZ comprising one or more geographically proximate data centers. Typically, a region may include multiple AZs.

[0197] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same VPC or across multiple VPCs. Typically, a VPC is set up within a single region. Communication between two VPCs within the same region, and between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0198] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing node, it causes at least one computing node to execute this application. Figures 3-6 The steps or operations of the provided MoE model operation method, for example, are used to perform the aforementioned Figures 3-6 The provided steps or instructions for running the MoE model.

[0199] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct a computing device to execute this application. Figures 3-6 The steps or operations of the provided MoE model operation method, for example, are used to perform the aforementioned Figures 3-6 The provided steps or instructions for running the MoE model.

[0200] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.

[0201] The terms “first,” “second,” “third,” and “fourth,” etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to define a specific order.

[0202] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

Claims

1. A method for operating a hybrid expert MoE model, characterized in that, The MoE model includes an attention network and MoE layers, wherein the MoE layers include multiple expert networks, and the method includes: Each set of first computing nodes in a plurality of computing nodes obtains first model parameters. The plurality of computing nodes are divided into i sets of first computing nodes, and the model parameters of the attention network are divided into i sets of first model parameters, where i is an integer greater than 1. Each computing node in the first set of computing nodes obtains the first data, and the input data of the attention network is divided into j parts of the first data, where j is an integer greater than 1; Each of the plurality of computing nodes obtains a second model parameter, which is a partial parameter of the model parameters of the plurality of expert networks; The computing nodes among the plurality of computing nodes process the acquired first data according to the acquired first model parameters to obtain the attention network processing result of the input data; At least some of the computing nodes process the attention network processing results according to the acquired second model parameters to obtain the expert network processing results.

2. The method according to claim 1, characterized in that, The plurality of expert networks include a plurality of routing expert networks, and the plurality of computing nodes are divided into m second computing node sets, wherein the first computing node set is not completely identical to the second computing node set; Each of the plurality of computing nodes obtains the second model parameters, including: Each computing node in each of the second computing node sets obtains the third model parameters. The plurality of routing expert networks are divided into m routing expert network sets. The model parameters of each routing expert network set are divided into n parts of the third model parameters. The second model parameters include the third model parameters. Wherein, m is an integer greater than 1, and n is an integer greater than 1.

3. The method according to claim 1 or 2, characterized in that, The multiple expert networks include multiple shared expert networks, and the multiple computing nodes are divided into x third computing node sets, wherein the first computing node set is not completely identical to the third computing node set. Each of the plurality of computing nodes obtains the second model parameters, including: Each computing node in each of the third computing node sets obtains the fourth model parameters. The plurality of shared expert networks are divided into x shared expert network sets. The model parameters of each shared expert network set are divided into y parts of the fourth model parameters. The second model parameters include the fourth model parameters. Wherein, x is an integer greater than 1, and y is an integer greater than 1.

4. The method according to claim 1 or 2, characterized in that, The plurality of expert networks includes at least one shared expert network, and the plurality of computing nodes are divided into z sets of fourth computing nodes, wherein the first set of computing nodes is not completely identical to the set of fourth nodes. Each of the plurality of computing nodes obtains the second model parameters, including: Each computing node in the fourth computing node set obtains the fifth model parameters, and the model parameters of the at least one shared expert network are divided into z parts of the fifth model parameters, and the second model parameters include the fifth model parameters; Where z is an integer greater than 1.

5. The method according to claim 4, characterized in that, At least some of the plurality of computing nodes process the attention network processing results according to the acquired second model parameters, including: Each computing node in the fourth computing node set acquires the second data, and the attention network processing result is divided into k parts of the second data; The computing nodes among the plurality of computing nodes process the acquired second data according to the acquired fifth model parameters to obtain a shared expert network processing result, which includes the shared expert network processing result.

6. The method according to any one of claims 1-5, characterized in that, The method further includes: Based on at least one of the following: the model structure of the MoE model, the computing power of the plurality of computing nodes, the communication link information between the plurality of computing nodes, and the operating requirements of the MoE model, determine at least one of the following: the first model parameter of each first computing node set, the first data of each computing node, the second model parameter of each computing node, and the second data of each computing node.

7. The method according to any one of claims 1-6, characterized in that, The j satisfies at least one of the following: The difference between the batch size of the input data of the MoE model and j is less than a first threshold. If the communication time of the MoE model is greater than the time for transferring the model parameters of the MoE model, then j is greater than i.

8. The method according to claim 1 or 2, characterized in that, The computing nodes among the plurality of computing nodes process the acquired first data according to the acquired first model parameters to obtain the attention network processing result of the input data, including: Each of the plurality of computing nodes processes the acquired first data according to the acquired first model parameters to obtain a first processing result; The multiple computing nodes aggregate the first processing results of the multiple computing nodes through reduce-scatter communication, so that each of the multiple computing nodes obtains the second processing result; The multiple computing nodes aggregate the second processing results of the multiple computing nodes through all-gather communication, so that each of the multiple computing nodes obtains the attention network processing result.

9. The method according to claim 2, characterized in that, At least some of the plurality of computing nodes process the attention network processing results according to the acquired second model parameters to obtain expert network processing results, including: Each of the at least some computing nodes processes at least a portion of the data in the attention network processing result according to the acquired second model parameters to obtain a third processing result; The plurality of computing nodes aggregate the third processing results of at least some of the computing nodes through reduce-scatter communication, so that each of the plurality of computing nodes obtains a fourth processing result; The multiple computing nodes aggregate the fourth processing results of the multiple computing nodes through all-gather communication, so that each first computing node in each first computing node set obtains a fifth processing result, and the fifth processing results of all computing nodes in each first computing node set constitute the expert network processing result.

10. A system for running a hybrid expert MoE model, characterized in that, The MoE model includes an attention network and a MoE layer, the MoE layer includes multiple expert networks, and the system includes multiple computing nodes; Each first set of computing nodes in the plurality of computing nodes is used to obtain the first model parameters. The plurality of computing nodes are divided into i first sets of computing nodes, and the model parameters of the attention network are divided into i parts of the first model parameters, where i is an integer greater than 1. Each computing node in each of the first computing node sets is also used to acquire first data, wherein the input data of the attention network is divided into j parts of the first data, where j is an integer greater than 1; Each of the plurality of computing nodes is further configured to obtain second model parameters, which are a subset of the model parameters of the plurality of expert networks. The computing nodes among the plurality of computing nodes are further configured to process the acquired first data according to the acquired first model parameters to obtain the attention network processing result of the input data; At least some of the computing nodes are further configured to process the attention network processing results based on the acquired second model parameters to obtain expert network processing results.

11. The system according to claim 10, characterized in that, The plurality of expert networks include a plurality of routing expert networks, and the plurality of computing nodes are divided into m second computing node sets, wherein the first computing node set is not completely identical to the second computing node set; Each of the plurality of computing nodes is also used to obtain second model parameters, including: Each computing node in each of the second computing node sets is also used to obtain the third model parameters. The plurality of routing expert networks are divided into m routing expert network sets, and the model parameters of each routing expert network set are divided into n parts of the third model parameters. The second model parameters include the third model parameters. Wherein, m is an integer greater than 1, and n is an integer greater than 1.

12. The system according to claim 10 or 11, characterized in that, The computing nodes among the plurality of computing nodes are further configured to process the acquired first data according to the acquired first model parameters to obtain the attention network processing result of the input data, including: Each of the plurality of computing nodes is further configured to process the acquired first data according to the acquired first model parameters to obtain a first processing result; The plurality of computing nodes are further configured to aggregate the first processing results of the plurality of computing nodes through reduce-scatter communication, so that each of the plurality of computing nodes obtains the second processing result; The plurality of computing nodes are further configured to aggregate the second processing results of the plurality of computing nodes through all-gather communication, so that each of the plurality of computing nodes obtains the attention network processing result.

13. The system according to claim 11, characterized in that, At least some of the plurality of computing nodes are further configured to process the attention network processing results based on the acquired second model parameters to obtain expert network processing results, including: Each of the at least some computing nodes is further configured to process at least a portion of the data in the attention network processing result according to the acquired second model parameters to obtain a third processing result; The plurality of computing nodes are also configured to aggregate the third processing results of at least some of the computing nodes through reduce-scatter communication, so that each of the plurality of computing nodes obtains a fourth processing result; The multiple computing nodes aggregate the fourth processing results of the multiple computing nodes through all-gather communication, so that each first computing node in each first computing node set obtains a fifth processing result, and the fifth processing results of all computing nodes in each first computing node set constitute the expert network processing result.

14. A computer program product containing instructions, characterized in that, When the instruction is executed by multiple computing nodes, the multiple computing nodes perform the method as described in any one of claims 1-9.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes computer program instructions that, when executed by a plurality of computing nodes, perform the method as described in any one of claims 1-9.