An expert load balancing method and computer device

By differentiating the number of expert replicas and adjusting the expert arrangement, the problem of unbalanced load in the hybrid expert model was solved, and the model's performance and inference speed were improved.

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

Patent Information

Application Number
CN202511151646.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2025-05-20
Filing Date
2025-08-14
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In hybrid expert models, the load imbalance caused by the allocation decisions of the gating network affects the model's performance and inference speed.

Method used

By allocating the number of expert replicas differently based on the load balance of multiple expert layers using computer equipment, adjusting the initial expert arrangement, and rationally controlling computing cluster resources, the load imbalance can be reduced, and model performance and inference speed can be improved.

Benefits of technology

It enables the rational control of computing cluster resources, avoids resource waste, and improves the performance and inference speed of hybrid expert models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123145256A_ABST
    Figure CN123145256A_ABST
Patent Text Reader

Abstract

The application discloses an expert load balancing method and a computer device, and relates to the technical field of computers, which can realize reasonable regulation and control of computing cluster resources, avoid resource waste, reduce the load balancing degree of a hybrid expert model, improve the performance and reasoning speed of the hybrid expert model. The method provided by the application can receive a reasoning request; run a hybrid expert model, execute the reasoning request by using the hybrid expert model, and obtain a reasoning result; the hybrid expert model comprises a first expert layer and a second expert layer; the current load balancing degree of the first expert layer is greater than the current load balancing degree of the second expert layer, and the number of expert copies of the first expert layer is greater than the number of expert copies of the second expert layer. Based on the application, the computer device can differentially allocate the number of expert copies to multiple expert layers according to the load balancing degrees of the multiple expert layers, that is, the number of expert copies of an expert layer with a high load balancing degree is greater than the number of expert copies of an expert layer with a low load balancing degree.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority to Chinese patent application filed on May 20, 2025, with application number 202510654489.2 and entitled “Expert Balancing Greedy Algorithm, Apparatus and System Based on Min-Heap”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of computer technology, and in particular to an expert load balancing method and computer equipment. Background Technology

[0003] A mixture of experts (MoE) model is a machine learning model architecture designed to improve computational efficiency and model performance by distributing tasks among multiple specialized sub-models (called "experts"). A MoE model consists of multiple expert layers, each containing multiple experts, a gating network (GN), input layers, and output layers. Each expert is an independent multilayer perceptron (MLP), and each expert is dedicated to processing a specific type of data or task. The gating network dynamically selects one or more logical experts to perform computation based on the characteristics of the input data and performs a weighted combination of the outputs of one or more logical experts to generate the final output.

[0004] However, the allocation decisions of the gating network may lead to an unbalanced load on the MoE model, which in turn affects the performance and inference speed of the MoE model. Summary of the Invention

[0005] This application provides an expert load balancing method and computer equipment, which can not only realize the rational control of computing cluster resources and avoid resource waste, but also reduce the load balancing degree of hybrid expert models and improve the performance and inference speed of hybrid expert models.

[0006] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:

[0007] In a first aspect, an expert load balancing method is provided, which is applied to any computer device in a computing cluster. The method includes: receiving an inference request; running a hybrid expert model, executing the inference request using the hybrid expert model, and obtaining an inference result; wherein the hybrid expert model includes multiple expert layers, including a first expert layer and a second expert layer; the current load balancing degree of the first expert layer is greater than the current load balancing degree of the second expert layer, and the number of expert replicas of the first expert layer is greater than the number of expert replicas of the second expert layer.

[0008] The solution provided in the first aspect above allows computer equipment to allocate the number of expert replicas to multiple expert layers differentially based on their load balancing. Specifically, the number of expert replicas for expert layers with high load balancing is greater than the number of expert replicas for expert layers with low load balancing. This not only enables reasonable control of computing cluster resources and avoids resource waste, but also reduces the load balancing of the hybrid expert model, thereby improving its performance and inference speed.

[0009] As one possible implementation, each expert layer includes multiple physical experts, each of whom is a logical expert or an expert replica; the computing cluster includes multiple computing cards, and the multiple physical experts of each expert layer are distributed across multiple computing cards. Before receiving inference requests, the method further includes: obtaining the historical load balancing of each of the multiple expert layers under the initial expert arrangement; obtaining the redundancy budget of each of the multiple expert layers based on the total redundancy budget of the computing cluster and the historical load balancing of each of the multiple expert layers; wherein, the total redundancy budget represents the maximum number of redundancy positions in a computing card for multiple expert layers; the redundancy budget represents the number of redundancy positions that a computing card can support in the corresponding expert layer, and one redundancy position is used to place one physical expert; adjusting the initial expert arrangement based on the redundancy budget of each of the multiple expert layers to obtain the target expert arrangement; the target arrangement characterizes the distribution positions of the multiple physical experts of each of the multiple expert layers on the computing cluster during the operation of the hybrid expert model. In this way, the computer equipment can adjust the initial expert arrangement based on the total redundancy budget of the computing cluster and the historical load balancing of each of the multiple expert layers to obtain the target expert arrangement, thereby achieving reasonable control of computing cluster resources, avoiding resource waste, and also reducing the load balancing of the hybrid expert model, improving the performance and inference speed of the hybrid expert model.

[0010] As one possible approach, the above-mentioned method of obtaining the redundancy budget for each expert layer based on the total redundancy budget of the computing cluster and the historical load balancing of each expert layer includes: obtaining the theoretical redundancy budget for each expert layer based on the total redundancy budget and the historical load balancing of each expert layer; wherein the historical load balancing of each expert layer is positively correlated with the theoretical redundancy budget; allocating the total remaining redundancy budget to obtain the remaining redundancy budget for each expert layer; wherein the total remaining redundancy budget is the redundancy budget in the total redundancy budget excluding the initial redundancy budget for each expert layer; the initial redundancy budget is determined based on the theoretical redundancy budget; and obtaining the redundancy budget for each expert layer based on the initial redundancy budget and the remaining redundancy budget. In this way, under the constraint of the total redundancy budget, the computer equipment can first allocate a reasonable initial redundancy budget to each expert layer based on the historical load balancing of each expert layer, and then redistribute the total remaining redundancy budget, which can further improve the rationality of redundancy budget allocation, enabling reasonable control of computing cluster resources and avoiding resource waste.

[0011] As an example, multiple expert layers include a third expert layer, which is any one of the multiple expert layers. If the integer redundancy budget of the third expert layer is greater than or equal to the maximum single-layer redundancy budget of the third expert layer, then the initial redundancy budget of the third expert layer is the maximum single-layer redundancy budget. If the integer redundancy budget of the third expert layer is less than the maximum single-layer redundancy budget of the third expert layer, then the initial redundancy budget of the third expert layer is the integer redundancy budget of the third expert layer. Here, the maximum single-layer redundancy budget of the third expert layer represents the maximum number of redundant positions of the third expert layer on a computing card, and the integer redundancy budget refers to the integer part of the theoretical redundancy budget. Thus, by limiting the maximum single-layer redundancy budget of each expert layer, computer equipment can more rationally allocate the resources of the computing cluster, improving the inference speed and performance of the hybrid expert model. This is because the hybrid expert model is obtained by stacking multiple network modules, and a network module in the hybrid expert model includes not only one expert layer but also other network layers (such as attention mechanism layers). Other network layers also require computing resources (such as storage and computational resources). Without limiting the maximum redundancy budget for a single layer, resource usage in other network layers within some network modules may be restricted, affecting the inference speed of those layers and consequently reducing the inference speed and performance of the hybrid expert model. Furthermore, when the hybrid expert model experiences operational failures during the trial phase, some expert layers may not have started inference, resulting in a historical activation count of 0 and a historical load balancing degree of 1 for those layers. Without limiting the maximum redundancy budget for each expert layer, expert layers that haven't started inference will lack redundancy budgets, while some expert layers will receive excessive redundancy budgets, wasting resources and reducing the inference speed and performance of the hybrid expert model.

[0012] As another example, multiple expert layers include a third expert layer, which is any one of the multiple expert layers; the initial redundancy budget for the third expert layer is the integer part of the theoretical redundancy budget. In this way, the computer device can quickly allocate the initial redundancy budget to each expert layer.

[0013] As one possible implementation, the total remaining redundancy budget includes at least one remaining redundancy location. The above-described allocation of the total remaining redundancy budget to obtain the remaining redundancy budgets for multiple expert layers includes: obtaining a first target expert layer; and allocating the total remaining redundancy budget to at least one target expert layer according to the difference in redundancy budgets between the first target expert layers. Here, the first target expert layer is the expert layer whose initial redundancy budget is less than the maximum redundancy budget for a single layer, and the difference is the difference between the theoretical redundancy budget and the initial redundancy budget. In this way, the computer equipment can allocate the total remaining redundancy budget to expert layers whose initial redundancy budget is less than the maximum redundancy budget for a single layer based on the difference in redundancy budgets among the expert layers, achieving a rational allocation of computer resources.

[0014] As an example, the difference could be the difference between the theoretical redundancy budget and the initial redundancy budget.

[0015] As another example, the difference can be the level of difference between the theoretical redundancy budget and the initial redundancy budget. The larger the level of difference, the greater the difference between the theoretical redundancy budget and the initial redundancy budget.

[0016] As one possible implementation, multiple expert layers include a third expert layer, which is any one of the multiple expert layers. The above-mentioned adjustment of the initial expert arrangement based on the redundancy budgets of each of the multiple expert layers to obtain the target expert arrangement includes: obtaining multiple redundancy levels of the third expert layer, each redundancy level representing the number of configurable redundant positions for a computing card in the third expert layer under its redundancy budget; obtaining multiple arrangement methods corresponding to the multiple redundancy levels; wherein, the arrangement method represents the distribution location of multiple physical experts in the third expert layer on the computing cluster; one arrangement method corresponds to one expert replica allocation method; the expert replica allocation method represents the number of expert replicas for each of the multiple logical experts in the third expert layer under the corresponding redundancy level; selecting the target arrangement method corresponding to the third expert layer from the multiple arrangement methods corresponding to the third expert layer; wherein, the simulated load balancing degree corresponding to the target arrangement method is less than or equal to the minimum simulated load balancing degree corresponding to the non-target arrangement method; and adjusting the initial expert arrangement based on the target arrangement method corresponding to the third expert layer to obtain the target expert arrangement. In this way, the computer equipment obtains multiple redundancy levels corresponding to the redundancy budget of the third expert layer, which helps to increase the diversity of the third expert layer's arrangement methods. Furthermore, selecting the target arrangement method with the minimum simulated load balancing degree from the arrangement methods of multiple redundancy levels is beneficial to achieving load balancing of the hybrid expert model.

[0017] As an example, the allocation of expert replicas for any non-minimum redundancy level is based on a greedy algorithm using a min-heap. In this min-heap data structure, each node is a tuple containing the expert ID of a logical expert at the third expert level and the expert's current sub-priority. The initial value of the current sub-priority is a negative of the corresponding logical expert's historical activation count, and the non-initial value is the ratio of the corresponding logical expert's historical activation count to the number of physical experts the logical expert was previously allocated. This allows the computer device to allocate a more reasonable number of expert replicas to each logical expert. For example, if the number of physical experts previously allocated to a logical expert remains constant, a higher historical activation count and a lower current sub-priority value increase the likelihood of the corresponding logical expert being placed at the root node, making it easier for the computer device to allocate expert replicas. Conversely, if the historical activation count remains constant, a higher number of physical experts previously allocated to a logical expert increases the likelihood of the corresponding logical expert being placed at the root node, thus preventing the computer device from allocating too many expert replicas to logical experts that already have a large number of replicas.

[0018] As another example, the initial value of the current sub-priority is the negative of the predicted activation count for the corresponding logical expert, and the non-initial value of the current sub-priority is the ratio of the predicted activation count for the corresponding logical expert to the number of physical experts previously allocated to the logical expert; the predicted activation count is obtained based on historical activation counts. In this way, the computer device can allocate a more reasonable number of expert replicas to each logical expert. For example, by using the predicted activation count to determine the current sub-priority, the value of the current sub-priority better reflects the subsequent operation of the hybrid expert model, thus facilitating an expert replica allocation method that better reflects the load change trend of the computing cluster and improving the accuracy of the number of expert replicas allocated to each logical expert by the computer device. For another example, if the number of physical experts previously allocated to a logical expert remains constant, a larger predicted activation count and a smaller current sub-priority value increase the likelihood that the corresponding logical expert will be placed in the root node, making it easier for the computer device to allocate expert replicas. For yet another example, if the predicted activation count remains constant, a larger number of physical experts previously allocated to a logical expert and a larger current sub-priority value decrease the likelihood that the corresponding logical expert will be placed in the root node, preventing the computer device from allocating too many expert replicas to logical experts that already have a large number of expert replicas configured.

[0019] As an example, the arrangement is used to divide multiple physical experts in the third expert layer into multiple expert groups, where the types of multiple physical experts in each expert group are different, and the number of expert groups in the third expert layer is the same as the number of computing cards.

[0020] In a computer cluster, communication time within the same computing card is less than communication time within the same computing device, which is less than communication time between different computing devices. Furthermore, multiple computing cards can each store data for model inference. When a physics expert's computing card lacks the data required for inference, data must be retrieved across computing cards or computer devices before inference can proceed, reducing model inference efficiency. Therefore, this application addresses this by grouping physics experts of the same type into different expert groups, thereby assigning them to different computing cards. This reduces the probability of cross-computing card or cross-computer device communication operations and improves model inference efficiency.

[0021] As an example, the third expert layer includes multiple physical experts, including a first physical expert and a second physical expert. The historical average load of the first physical expert is higher than that of the second physical expert. The first physical expert is assigned to an expert group before the second physical expert. The expert group to which the first physical expert belongs is the expert group with the lowest total load at the time of assignment and whose type does not overlap with the first physical expert. In this way, the computer device will prioritize assigning the expert group to the physical expert with the higher historical average load, and when assigning expert groups, it will prioritize the expert group with the lowest total load and no overlap in type, resulting in a more balanced load among the computing cards and improved storage efficiency of the computing cards.

[0022] As an example, a computing cluster comprises multiple computer devices, each including at least one computing card. These devices are arranged to assign multiple expert groups to a single computing card within each device. The expert groups include a first expert group and a second expert group, where the type similarity between the first and second expert groups is greater than or equal to a similarity threshold. The first and second expert groups are located on different computer devices. By assigning expert groups with high type similarity to different computer devices, the probability of cross-device communication operations is reduced, cross-device communication overhead is decreased, the data throughput of the computing cluster is increased, and model inference efficiency is improved.

[0023] As one possible implementation, during the operation of the hybrid expert model, the above method further includes: obtaining a simulated arrangement of the target expert layer based on the redundancy budget of the second target expert layer; wherein the second target expert layer is the expert layer whose current load balancing degree is greater than a preset threshold; when the difference between the current load balancing degree and the load balancing degree of the simulated arrangement is greater than or equal to a preset difference, the arrangement of the target expert layer is adjusted to the simulated arrangement. In this way, the computer device can dynamically adjust the arrangement of the second target expert layer of the hybrid expert model according to the operation of the hybrid expert model, so as to optimize the load balancing degree of the hybrid expert model in real time. Furthermore, the introduction of a dual gating mechanism of preset threshold and preset difference ensures that dynamic adjustments only occur when necessary and can bring significant benefits, effectively avoiding jitter caused by frequent or ineffective adjustments to the hybrid expert model, and ensuring the stability of the hybrid expert model's operation.

[0024] Secondly, this application provides an expert load balancing device that runs on any computer device in a computing cluster. The expert load balancing device is used to execute any of the expert load balancing methods provided in the first aspect above.

[0025] In one possible implementation, this application can divide the expert load balancing device into functional modules according to the method provided in the first aspect above. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into a single processing module. For instance, this application can divide the expert load balancing device into a receiving module and an inference module, etc., according to their functions. The descriptions of the possible technical solutions and beneficial effects of the various functional modules described above can be found in the technical solutions provided in the first aspect above or its corresponding possible implementations, and will not be repeated here.

[0026] Thirdly, a computer device is provided, deployed in a computing cluster, the computer device comprising: a memory for storing computer program instructions; and a processor for executing the computer program instructions to support the computer device in implementing the methods as described in any possible implementation of the first aspect.

[0027] Fourthly, a computer-readable storage medium is provided that stores computer program instructions that, when executed by a processor, implement the method as described in any possible implementation of the first aspect.

[0028] Fifthly, a computer program product containing instructions is provided, which, when run on a computer, causes the computer to implement the method as described in any possible implementation of the first aspect.

[0029] Sixthly, a chip system is provided, comprising processing circuitry and a storage medium storing computer program instructions; when executed by a processor, the computer program instructions implement the method as described in any possible implementation of the first aspect. The chip system may be composed of chips or may include chips and other discrete devices.

[0030] The technical effects of the solutions provided in the second to sixth aspects mentioned above can be compared with the technical effects of the corresponding expert load balancing method in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0031] Figure 1 A flowchart of an expert load balancing method provided in an embodiment of this application;

[0032] Figure 2 A schematic diagram illustrating an initial expert arrangement method provided in an embodiment of this application;

[0033] Figure 3 A schematic diagram illustrating the load balancing of each expert layer under different redundancy strategies, provided for embodiments of this application;

[0034] Figure 4A schematic diagram illustrating the load distribution of each expert layer under different redundancy strategies, provided for embodiments of this application;

[0035] Figure 5 A flowchart of another expert load balancing method provided in the embodiments of this application;

[0036] Figure 6 A schematic diagram of a code engineering structure provided in an embodiment of this application;

[0037] Figure 7 This is a schematic diagram of the structure of an expert load balancing device provided in an embodiment of this application;

[0038] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0039] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of 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. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.

[0040] In the following text, the terms "first," "second," and "third" are used only to distinguish different descriptive objects and do not limit the position, order, priority, or quantity of the described objects. For example, if the described object is "position," then the ordinal numbers preceding "expert level" in "first expert level," "second expert level," and "third expert level" do not limit the position or order of the "expert levels," and "first," "second," and "third" do not limit the order in which they modify the "expert levels." Similarly, if the described object is "expert level," then the ordinal numbers preceding "expert level" in "first expert level," "second expert level," and "third expert level" do not limit the priority among the "expert levels." Furthermore, the quantity of described objects is not limited by ordinal numbers and can be one or more; for example, in "first target expert level," the quantity of "first target expert level" can be one or more. In addition, the objects modified by different prefixes can be the same or different; for example, if the described object is "expert level," then "first expert level" and "third expert level" can be the same expert level or different expert levels. In summary, the use of ordinal numbers and other prefixes used to distinguish the described objects in the embodiments of this application does not constitute a limitation on the described objects. The description of the described objects is given in the claims or the context of the embodiments, and the use of such prefixes should not constitute an unnecessary limitation.

[0041] Furthermore, in the embodiments of this application, "connection" can be a direct connection or an indirect connection; in addition, it can refer to an electrical connection or a communication connection; for example, the connection of two electrical components A and B can refer to A and B being directly connected, or it can refer to A and B being indirectly connected through other electrical components or connection media, or it can refer to A and B being indirectly connected through other communication devices or communication media, as long as it enables communication between A and B.

[0042] To better understand the methods provided in this application, the technical terms involved in the embodiments of this application will be explained below.

[0043] Logical expert: refers to the original expert in the hybrid expert model.

[0044] Expert replicas (replications / replica): refers to replicas of logical experts.

[0045] A physical expert is an expert deployed on a computer device. A physical expert is either a logical expert or an expert replica. In a hybrid expert model, the number of physical experts equals the sum of the number of logical experts and the number of expert replicas.

[0046] Load balancing: In hybrid expert model applications, this refers to the distribution of different physics experts called by the gating network during model training or inference. The lower the load balancing, the more balanced the load; the more balanced the load, the better the model's performance and the faster the inference speed.

[0047] Computing card: refers to a chip with model training or inference capabilities, such as graphics processing unit (GPU) and neural processing unit (NPU).

[0048] Min-heap: refers to a data structure based on a complete binary tree structure. In a min-heap, the value of any non-leaf node is no greater than its left or right child nodes, and the root node is always the smallest element in the heap.

[0049] Greedy algorithm: refers to an algorithmic strategy that adopts the current optimal solution in each step, aiming to obtain the global optimal solution by combining local optimal solutions.

[0050] Round-robin strategy: This refers to a commonly used task scheduling or resource allocation algorithm. The core idea of ​​the round-robin strategy is to allocate resources in a fixed order to ensure that all requests or tasks are processed fairly and evenly.

[0051] Compared to traditional large-scale single neural networks, hybrid expert models (HEMs) significantly reduce computational costs while maintaining the model's expressive power and generalization performance through sparse activation (i.e., activating only some experts). This allows HEMs to be widely used in fields such as natural language processing, image processing, and recommender systems. However, HEMs face the challenge of load balancing in practical deployments. This is because the allocation decisions of gating networks may lead to some experts being over-utilized while others are underutilized, resulting in an unbalanced model load and consequently affecting the model's performance and response speed.

[0052] Among related approaches, the Expert Parallelism Load Balancer (EPLB) algorithm can be used to optimize the load balancing of hybrid expert models. The EPLB algorithm is based on a redundant expert strategy, replicating high-load logical experts and distributing them appropriately across different GPUs to achieve load balancing.

[0053] The redundant expert strategy refers to the fact that in expert parallelism, the load on different experts may vary depending on the input data and model structure. By introducing expert replicas (copying high-load logical experts), the load can be balanced. The redundant expert strategy supports the multiple replication of high-load logical experts, distributing them across multiple GPUs to avoid overloading a single GPU.

[0054] In addition, to achieve load balancing, the EPLB algorithm is also configured with the following two modes: hierarchical load balancing mode and global load balancing mode, which are suitable for different scenarios.

[0055] When the number of expert groups is divisible by the number of computer devices, a hierarchical load balancing model can be used to achieve load balancing. Each expert tier can have multiple expert groups, and each expert group can include multiple physical experts. The implementation method of the hierarchical load balancing model is as follows: Expert groups are evenly distributed across different computer devices, ensuring that the load on each computer device is approximately equal. Within each computer device, logical experts are further replicated, and these replicated logical experts (i.e., expert copies) are distributed across the GPUs within the computer device to ensure load balancing within the computer device. Physical experts from the same group are placed on the same computer device whenever possible to reduce cross-node communication overhead.

[0056] When the number of expert groups is not divisible by the number of computer devices, a global load balancing mode can be used to achieve load balancing. The global load balancing mode ignores the expert group limitation and replicates and distributes physics experts across all available GPUs.

[0057] However, the EPLB algorithm's load balancing performance needs improvement because it lacks inter-layer redundancy decision-making: EPLB deploys the same number of expert replicas in all expert layers without considering the distribution differences between different expert layers, which may lead to resource waste or insufficient number of expert replicas.

[0058] To address the issues of unreasonable resource allocation in computing clusters and reduced model performance and inference speed due to unbalanced load in hybrid expert models, this application provides an expert load balancing method. Based on this method, the computer device can allocate a different number of expert replicas to multiple expert layers based on their load balancing levels; that is, the number of expert replicas for expert layers with high load balancing is greater than the number of expert replicas for expert layers with low load balancing. This not only enables reasonable control of computing cluster resources and avoids resource waste, but also reduces the load balancing of hybrid expert models, thereby improving their performance and inference speed.

[0059] The following will describe in detail, with reference to the accompanying drawings, an expert load balancing method provided in this application. The expert load balancing method provided in this application is applied to any computer device (hereinafter referred to as "computer device") in a computing cluster that possesses expert load balancing capabilities. The computing cluster includes multiple computer devices, each computer device including at least one computing card, and each computer device also includes a processor for determining the target expert deployment method, such as a central processing unit (CPU). The multiple computer devices can communicate with each other.

[0060] Please refer to Figure 1 , Figure 1 A flowchart of an expert load balancing method provided in an embodiment of this application is shown. Figure 1 As shown, the expert load balancing method may include S101 to S105:

[0061] S101. The computer device obtains the historical load balancing degree of each of the multiple expert layers in the hybrid expert model under the initial expert arrangement.

[0062] The system comprises multiple expert layers, including a first expert layer, a second expert layer, and a third expert layer. The first expert layer differs from the second expert layer, while the third expert layer is any one of the multiple expert layers. Each expert layer includes multiple physical experts, each of whom is either a logic expert or a copy of an expert. The multiple physical experts in each expert layer are distributed across multiple computing cards.

[0063] In this embodiment, the operation of the hybrid expert model on the computer cluster can be divided into two stages: the first stage can be called the trial operation stage, and the second stage can be called the formal operation stage. During the trial operation stage, the hybrid expert model has an initial expert arrangement. After the trial operation stage, the computer device can obtain the load balancing degree of each of the multiple expert layers during the trial operation stage, and adjust the initial expert arrangement according to the historical load balancing degree of each of the multiple expert layers to obtain the target expert arrangement (steps S101-S103). After the target expert arrangement adjustment is completed, when the computer device receives an inference request, the hybrid expert model enters the formal operation stage (steps S104 and S105). That is, the initial expert arrangement refers to the distribution position of the multiple physical experts of each of the multiple expert layers on the computing cluster before receiving the inference request. The historical load balancing degree refers to the load balancing degree of the corresponding expert layer before receiving the inference request.

[0064] To determine the distribution location of each physical expert within the computing cluster, each computer device has a device number, each computing card has a card number, each expert layer has a layer number, and each physical expert has an expert number. The expert number of a logical expert differs from the expert number of its copy, and the expert numbers of logical experts within the same expert layer are also different. For example, device 0 can represent the computer device with device number 0, card 0 can represent the computing card with card number 0, layer 0 can represent the expert layer with layer number 0, E0 can represent the logical expert with expert number 0, and E... r00 It can represent the expert copy with expert number 0 corresponding to E0.

[0065] The distribution of each physics expert can be represented by a three-dimensional tensor. For example, P[card number r][layer number l][expert number e] = 0 can indicate that the physics expert with expert number e is not deployed in layer l of card r, and P[card number r][layer number l][expert number e] = 1 can indicate that the physics expert with expert number e is deployed in layer l of card r.

[0066] For example, suppose the computing cluster has two computer devices, each including two computing cards, the hybrid expert model has L expert layers, each expert layer has 4S logical experts, and each card includes S logical experts, where L and S are both positive integers. Then the initial expert arrangement can be as follows: Figure 2 As shown, device 0 includes card 0 and card 1, and device 1 includes card 2 and card 3. Each expert layer of each card contains S logical experts. For example, for any level of expert layer number, card 0 includes E0 to E1. S-1 Card 1 includes E S ~E 2S-1 Card 2 includes E 2S ~E 3S-1 Card 3 includes E 3S ~E 4S-1 .

[0067] It should be noted that, Figure 2 This is just one example of an initial layout. Other initial layouts are also possible. For example, each expert layer may include logical experts and expert copies; the number of physical experts may differ between different expert layers; and the number of computing cards may differ between different computing devices.

[0068] As one possible approach, the computer device can obtain the original historical activation counts of multiple physical experts in each expert layer, and then obtain the historical load balancing degree of each expert layer based on the original historical activation counts of multiple physical experts in each expert layer.

[0069] The original historical activation count refers to the number of times the corresponding physics expert was selected by the gating network before receiving inference requests (i.e., during the trial phase).

[0070] Optionally, each computer device in the computer cluster can count the original historical activation counts of the physical experts it deploys, and then each computer device can send the original historical activation counts it counts to the same computer device, so that a computer device can obtain the original historical activation counts of multiple physical experts in each expert layer.

[0071] Optionally, after obtaining the original historical activation counts of multiple physical experts in each expert layer, since the reference value of the original historical activation counts that are more recent is higher, in order to obtain a more accurate historical load balancing degree, the computer device can perform data preprocessing on the original historical activation counts of each physical expert obtained in different time periods to obtain the historical activation counts, so as to obtain the historical load balancing degree of each expert layer based on the historical activation counts of multiple physical experts in each expert layer.

[0072] Optionally, after obtaining the original historical activation counts of multiple physical experts in each expert layer, the computer device can directly add up the original historical activation counts obtained in different time periods for each physical expert to obtain the historical activation count.

[0073] For example, with Figure 2 Taking the initial expert arrangement as an example, assume the two-dimensional tensor: D[layer number l][expert number s] = y i Let represent the historical activation count of the logical expert with expert number s (hereinafter referred to as "Expert Es of Layer l") in expert layer l, which is located between time i-1 and time i. The values ​​of i range from [1, T-1], l range from [0, L-1], and s range from [0, 4S-1]. For expert Es in layer l, the corresponding activation counts between time 0 and time T-1 are y0, y1, ..., y... T Then the historical activation count (i.e., Y) of expert Es in layer l is:

[0074] Y = a0y0 + a1y1 + ... + a T y T

[0075] Among them, a i It can represent y i The corresponding weight, a i Greater than or equal to a i+1 a0, a1, ..., a T The sum of these is 1, a0, a1, ..., a T These are non-negative real numbers determined based on experience.

[0076] After obtaining the initial expert arrangement and the historical activation counts of each logical expert in layer l, the computer device can determine the historical load balancing of layer l based on the total historical computational load of each computing card in layer l. The total historical computational load of card r in layer l is the sum of the historical activation counts of all physical experts in card r, and the total historical computational load of card r in layer l can be expressed as R. r (l, P, D). For example, assuming... Figure 2 In the middle layer 0 card 0, E0~E S-1 The corresponding historical activation counts are Y0 to Y10 respectively. S-1 Then R0(0, P, D) = Y0 + Y1 + ... + Y S-1 .

[0077] Furthermore, the historical load balancing degree of layer l (i.e., B(l, P, D)) can be obtained by the following formula:

[0078]

[0079] Where R represents the total number of computing cards in layer l, maxR r (l, P, D) represents the maximum total historical computation load in layer l. This represents the sum of the total computational load of the R computing cards in layer l. The historical load balancing degree of each expert layer is a real number greater than or equal to 1. When the historical load balancing degree is 1, it indicates that the corresponding expert layer has achieved historical load balancing.

[0080] S102. The computer equipment obtains the redundancy budget for each of the multiple expert layers based on the total redundancy budget of the computing cluster and the historical load balancing of each expert layer.

[0081] The total redundancy budget represents the maximum number of redundant positions across multiple expert layers on a single compute card. The redundancy budget for an expert layer represents the number of redundant positions a compute card can support at its corresponding expert layer; each redundant position is used to house a physical expert. For example, assuming a compute cluster has R compute cards, L expert layers, a total redundancy budget of M×R, and a redundancy budget for layer 1 of C×R, then the total redundancy budget represents the maximum number of redundant positions (M) across the L expert layers on a single compute card, and the redundancy budget for layer 1 represents the number of redundant positions a compute card can support at layer 1 of C.

[0082] One possible approach is for the computer equipment to obtain the theoretical redundancy budget for each of the multiple expert layers based on the total redundancy budget and their respective historical load balancing levels. The historical load balancing level of each expert layer is positively correlated with its theoretical redundancy budget. The total remaining redundancy budget is then allocated to each of the multiple expert layers to obtain their respective remaining redundancy budgets. This remaining redundancy budget is the redundancy budget beyond the initial redundancy budgets of each expert layer within the total redundancy budget. The initial redundancy budget is determined based on the theoretical redundancy budget. Based on the initial and remaining redundancy budgets of each expert layer, the redundancy budget for each expert layer is obtained. In this way, under the constraint of the total redundancy budget, the computer equipment can first allocate a reasonable initial redundancy budget to each expert layer based on their respective historical load balancing levels, and then redistribute the total remaining redundancy budget. This can further improve the rationality of redundancy budget allocation, enabling reasonable control of computing cluster resources and avoiding resource waste.

[0083] Here, the theoretical redundancy budget represents the number of theoretically redundant positions of a computing card in the corresponding expert layer. The theoretical redundancy budget is a floating-point number. For example, assuming the computing cluster has R computing cards, and the theoretical redundancy budget of layer l is s_l_raw × R, then the theoretical redundancy budget of layer l represents the theoretical redundancy budget of a computing card in layer l as s_l_raw.

[0084] Optionally, taking layer l on a computing card as an example, the formula for calculating the theoretical redundancy budget of layer l can be:

[0085]

[0086] In some embodiments, where the constraints for determining the initial redundancy budget include the total redundancy budget, the initial redundancy budget is an integer part of the theoretical redundancy budget. This allows the computer device to quickly allocate the initial redundancy budget to each expert level.

[0087] In other embodiments, the constraints for determining the initial redundancy budget include the total redundancy budget and the maximum single-layer redundancy budget for each of the multiple expert layers. The maximum single-layer redundancy budget represents the maximum number of redundant positions for the corresponding expert layer on a computing card. Taking the third expert layer as an example, the maximum single-layer redundancy budget for the third expert layer represents the maximum number of redundant positions for the third expert layer on a computing card. If the integer redundancy budget for the third expert layer is greater than or equal to the maximum single-layer redundancy budget for the third expert layer, then the initial redundancy budget for the third expert layer is the maximum single-layer redundancy budget; if the integer redundancy budget for the third expert layer is less than the maximum single-layer redundancy budget for the third expert layer, then the initial redundancy budget for the third expert layer is the integer redundancy budget for the third expert layer. Here, the maximum single-layer redundancy budget for the third expert layer represents the maximum number of redundant positions for the third expert layer on a computing card, and the integer redundancy budget refers to the integer part of the theoretical redundancy budget. Thus, by limiting the maximum single-layer redundancy budget for each expert layer, the computer equipment can more rationally allocate the resources of the computing cluster, improving the inference speed and performance of the hybrid expert model. The reason is that hybrid expert models are composed of multiple stacked network modules. A single network module in a hybrid expert model includes not only an expert layer but also other network layers (such as attention mechanism layers). These other network layers also require computing resources (such as storage and computational resources). If the maximum redundancy budget for a single layer is not limited, the resource usage of other network layers in some network modules may be restricted, thus affecting the inference speed of those layers and consequently reducing the inference speed and performance of the hybrid expert model. Furthermore, when a hybrid expert model experiences operational failures during the trial phase, some expert layers may not have started inference, resulting in a historical activation count of 0 and a historical load balancing degree of 1 for those expert layers. If the maximum redundancy budget for each expert layer is not limited, expert layers that have not started inference will have no redundancy budget, while some expert layers will receive excessive redundancy budget, thus wasting resources and reducing the inference speed and performance of the hybrid expert model.

[0088] Optionally, the maximum redundancy budget for each of the multiple expert layers can be exactly the same, or the maximum redundancy budgets for each of the multiple expert layers can be different; this is not limited here. For example, when computing cluster resources are limited, the maximum redundancy budget for some expert layers can be set to 0, so that limited resources are allocated as much as possible to expert layers with higher historical load balancing. In this way, computer equipment can flexibly allocate resources according to actual conditions.

[0089] Optionally, the total redundancy budget and the maximum redundancy budget for each of the multiple expert layers are set by the developers based on experience.

[0090] After determining the initial redundancy budget for each expert layer, in order to allocate the total remaining redundancy budget, the computer equipment can acquire a first target expert layer. Based on the difference in redundancy budgets among at least one first target expert layer, the total remaining redundancy budget is allocated to at least one target expert layer. Here, the first target expert layer is the expert layer whose initial redundancy budget is less than the maximum redundancy budget for a single layer; the difference is the difference between the theoretical redundancy budget and the initial redundancy budget. In this way, the computer equipment can allocate the total remaining redundancy budget to expert layers whose initial redundancy budget is less than the maximum redundancy budget for a single layer based on the difference in their redundancy budgets, thus achieving a rational allocation of computer resources.

[0091] As an example, the difference could be the difference between the theoretical redundancy budget and the initial redundancy budget.

[0092] As one possible implementation, the computer device can arrange at least one first target expert layer in descending order of difference, and then allocate the total remaining redundant budget to at least one first target expert layer one by one in the above order.

[0093] For example, suppose the computing cluster has a total of 5 expert layers, where layers 0 to 3 are the first target expert layers, and the total remaining redundant budget is 3. The difference between layers 0 and 3 is 0.7, the difference between layers 1 and 2 is 0.5, the difference between layers 2 and 3 is 0.2. Then, layers 0 to 3 arranged in the above order are: layer 0, layer 2, layer 1, layer 3. The computer equipment can allocate one remaining redundant budget to layers 0, 2, and 1 in sequence, while layer 3 has no remaining redundant budget.

[0094] As one possible approach, the computer device can allocate the total remaining redundant budget multiple times based on the difference, allocating one portion of the total remaining redundant budget to a first target expert layer each time. In one allocation process, one remaining redundant budget is allocated to a third target expert layer; the third target expert layer is the first target expert layer whose comparison redundant budget is less than the maximum single-layer redundant budget, and whose theoretical redundant budget has the largest difference from the comparison redundant budget. The comparison redundant budget of the third target expert layer is incremented by 1, and the next allocation process continues until the total remaining redundant budget is allocated, resulting in the remaining redundant budgets for each of the multiple first target expert layers.

[0095] For example, assume the computing cluster has a total of 5 expert layers, where layers 0 to 3 are the first target expert layers. The maximum redundancy budget for each layer from 0 to 3 is 10, and the total remaining redundancy budget is 3. In the first allocation process, the theoretical redundancy budget for layer 0 is 8.7, the comparison redundancy budget is 8, and the difference is 0.7; the theoretical redundancy budget for layer 1 is 6.5, the comparison redundancy budget is 6, and the difference is 0.5; the theoretical redundancy budget for layer 2 is 6.6, the comparison redundancy budget is 6, and the difference is 0.6; and the theoretical redundancy budget for layer 3 is 4.2, the comparison redundancy budget is 4, and the difference is 0.2. The computer determines that the third target expert layer corresponding to the first allocation process is layer 0, allocates one remaining redundancy budget to layer 0, and updates the comparison redundancy budget of layer 0 to 9 (8+1).

[0096] During the second allocation process, the theoretical redundancy budget for layer 0 is 8.7, the alignment redundancy budget is 9, and the difference is -0.3. The difference and alignment redundancy budgets for other layers remain unchanged. The computer equipment determines that the third target expert layer corresponding to the second allocation process is layer 2, allocates a remaining redundancy budget to layer 2, and updates the alignment redundancy budget of layer 2 to 7.

[0097] In the third allocation process, the theoretical redundant budget of layer 0 is 8.7, the comparison redundant budget is 9, and the difference is -0.3. The theoretical redundant budget of layer 2 is 6.6, the comparison redundant budget is 7, and the difference is -0.4. The difference and comparison redundant budget of other layers remain unchanged. The computer equipment determines that the third target expert layer corresponding to the third allocation process is layer 1. The computer equipment allocates a remaining redundant budget to layer 1, thus completing the allocation of the total remaining redundant budget.

[0098] Continuing with the example of multiple allocations mentioned above, assuming that the maximum redundancy budget for each layer from layer 0 to layer 3 is 9, since the comparison redundancy budget for layer 0 is 9 after the first allocation process, in subsequent (second and third) allocation processes, the computer equipment can abandon determining the difference for layer 0, that is, no longer allocate the remaining redundancy budget for layer 0.

[0099] Furthermore, when there is no single-layer maximum redundancy budget in any of the five expert layers, the allocation process can be the same as the previous example of multiple allocations (the single-layer maximum redundancy budget corresponding to layers 0 to 3 is 10).

[0100] As another example, the difference can be the level of difference between the theoretical redundancy budget and the initial redundancy budget. The larger the level of difference, the greater the difference between the theoretical redundancy budget and the initial redundancy budget.

[0101] The difference level is determined based on the difference between the theoretical redundancy budget and the initial redundancy budget. For example, when the difference is in the range [0, 0.2), the corresponding difference level is 0; when the difference is in the range [0.2, 0.4), the corresponding difference level is 1; when the difference is in the range [0.4, 0.6), the corresponding difference level is 2; when the difference is in the range [0.6, 0.8), the corresponding difference level is 3; and when the difference is in the range [0.8, 1), the corresponding difference level is 4.

[0102] There is a mapping relationship between the difference levels. This mapping relationship represents the budget quota corresponding to each difference level. The larger the difference level, the larger the budget quota. The budget quota represents the maximum amount of remaining redundant budget that can be allocated to the corresponding expert level. That is, the actual allocated remaining redundant budget is less than or equal to the budget quota.

[0103] This mapping can be determined based on the developers' experience. For example, the budget allocation for difference level 4 is 4, for difference level 3 it is 3, for difference level 2 it is 2, for difference level 1 it is 1, and for difference level 0 it is 0. As another example, the budget allocation for difference level 4 is 4, for difference level 3 it is 2, and for difference levels 2, 1, and 0 it is all 0.

[0104] As one possible approach, the computer device can allocate the total remaining redundant budget to at least one first target expert layer based on the difference level of at least one first target expert layer and the corresponding budget quota.

[0105] For example, without considering single-layer redundancy budgets, assume the computing cluster has a total of 5 expert layers, where layers 0 to 3 are the first target expert layers, and the total remaining redundancy budget is 3. The difference in value for layer 0 is 0.7, for layer 1 it is 0.5, for layer 2 it is 0.6, and for layer 3 it is 0.2. Therefore, the difference levels for layers 0 to 3 are 3, 2, 3, and 1, respectively. Since layers 0 and 2 have the same difference level, and the budget allocation for difference level 3 is equal to the total remaining redundancy budget, the computer equipment can choose from several allocation methods to distribute the total remaining redundancy budget to layers 0 and 2. These methods include: allocating all remaining redundancy budget to layer 0; allocating all remaining redundancy budget to layer 2; allocating 1 remaining redundancy budget to layer 0 and 2 remaining redundancy budget to layer 2; or allocating 2 remaining redundancy budget to layer 0 and 1 remaining redundancy budget to layer 2.

[0106] For example, considering single-layer redundancy budgets, assume the computing cluster has a total of 5 expert layers, where layers 0 to 3 are the first target expert layers. The maximum single-layer redundancy budget for each layer is 9, and the total remaining redundancy budget is 3. Layer 0 has a theoretical redundancy budget of 8.7, a comparison redundancy budget of 8, and a difference of 0.7; Layer 1 has a theoretical redundancy budget of 6.5, a comparison redundancy budget of 6, and a difference of 0.5; Layer 2 has a theoretical redundancy budget of 6.6, a comparison redundancy budget of 6, and a difference of 0.6; and Layer 3 has a theoretical redundancy budget of 4.2, a comparison redundancy budget of 4, and a difference of 0.2. The difference levels for layers 0 to 3 are 3, 2, 3, and 1, respectively. Since layers 0 and 2 have the same difference level, and the budget allocation for difference level 3 is equal to the total remaining redundancy budget, the computer equipment can choose from various allocation methods to distribute the total remaining redundancy budget to layers 0 and 2. Multiple allocation methods include: either allocating all remaining redundant budget to layer 2; or allocating 1 remaining redundant budget to layer 0 and 2 remaining redundant budget to layer 2. That is, considering the redundant budget of a single layer, the following allocation methods are eliminated: allocating all remaining redundant budget to layer 0, allocating 2 remaining redundant budget to layer 0, and allocating 1 remaining redundant budget to layer 2.

[0107] Besides the two methods of representing differences mentioned above, the differences in this application can also be represented in other ways. For example, the difference corresponding to an expert layer can be the ratio of the difference of that expert layer to the sum of the differences of all expert layers, etc., and this is not limited here. In practical applications, one or more of the above methods can be selected to represent differences according to the actual application scenario.

[0108] S103. The computer equipment adjusts the initial expert arrangement according to the redundancy budget of each of the multiple expert layers to obtain the target expert arrangement. The target arrangement represents the distribution position of multiple physical experts of each of the multiple expert layers on the computing cluster during the operation of the hybrid expert model.

[0109] As one possible approach, the computer equipment can determine the target arrangement of each of the multiple expert layers based on their respective redundancy budgets, and then adjust the initial expert arrangement according to the target arrangement of each expert layer to obtain the target expert arrangement. The target arrangement represents the distribution position of multiple physical experts of the corresponding expert layer on the computing cluster during the operation of the hybrid expert model.

[0110] Taking the third expert layer as an example, obtaining the target deployment method for the third expert layer can include the following steps: Step 1: The computer equipment obtains multiple redundancy levels for the third expert layer. Each redundancy level represents the number of redundant positions that a computing card can be configured in the third expert layer under the redundancy budget. Step 2: Obtain multiple deployment methods corresponding to multiple redundancy levels. The deployment method represents the distribution location of multiple physical experts in the third expert layer on the computing cluster. One deployment method corresponds to one expert replica allocation method. The expert replica allocation method represents the number of expert replicas for each logical expert in the third expert layer under the corresponding redundancy level. Step 3: From the multiple deployment methods corresponding to the third expert layer, select the target deployment method for the third expert layer. The simulated load balancing degree corresponding to the target deployment method is less than or equal to the minimum simulated load balancing degree corresponding to the non-target deployment method. The simulated load balancing degree can refer to the load balancing degree obtained based on the historical average load of each physical expert under the corresponding deployment method. The historical average load of each physical expert is obtained based on the historical activation count and the number of expert replicas of the corresponding physical expert. Thus, compared to the EPLB algorithm which directly allocates all redundant budget, the computer equipment obtains multiple redundancy levels corresponding to the redundant budget of the third expert layer, resulting in arrangements for each redundancy level. This increases the diversity of arrangements at the third expert layer. Furthermore, selecting the target arrangement with the lowest simulated load balancing degree from the arrangements of multiple redundancy levels facilitates load balancing in the hybrid expert model. A more detailed description of the above steps is as follows:

[0111] 1. Regarding the description of "Step 1, Computer equipment obtains multiple redundancy levels of the third expert layer":

[0112] For example, assuming a computing cluster has 4 compute cards, and the redundancy budget for the third expert layer is 4×2, where the redundancy budget indicates that a compute card can support 2 redundant positions in the third expert layer, then the redundancy levels for the third expert layer are 0 (minimum redundancy level), 1, and 2. Redundancy level 0 means that a compute card has 0 redundant positions in the third expert layer, i.e., no expert replicas in the third expert layer. Redundancy level 1 means that a compute card has 1 redundant position in the third expert layer, i.e., the number of expert replicas in the third expert layer is 4 (i.e., 4×1). Redundancy level 2 means that a compute card has 2 redundant positions in the third expert layer, i.e., the number of expert replicas in the third expert layer is 8 (i.e., 4×2).

[0113] 2. Regarding the description of "Step 2, obtaining multiple arrangement methods corresponding to multiple redundancy levels":

[0114] As one possible approach, the computer device can first obtain the expert copy allocation methods corresponding to multiple redundancy levels, and then determine multiple arrangement methods corresponding to multiple redundancy levels under the expert copy allocation methods corresponding to multiple redundancy levels.

[0115] (1) Determining the method for allocating expert copies:

[0116] After determining the number of expert replicas corresponding to each redundancy level in the third expert layer, the computer equipment can further confirm the expert replica allocation method for each redundancy level. The expert replica allocation method for any non-minimum redundancy level can be obtained based on a greedy algorithm using a min-heap; where the nodes in the min-heap data structure are tuples, and the tuple includes the expert number of a logical expert in the third expert layer and the current sub-priority of the logical expert.

[0117] As an example, the initial value of the current sub-priority is a negative of the historical activation count of the corresponding logical expert, and the non-initial value of the current sub-priority is the ratio of the historical activation count of the corresponding logical expert to the number of physical experts the logical expert was previously allocated. In this way, the computer device can allocate a more reasonable number of expert replicas to each logical expert. For example, if the number of physical experts previously allocated to a logical expert remains constant, a higher historical activation count and a lower current sub-priority value increase the likelihood that the corresponding logical expert will be placed in the root node and is more likely to be allocated expert replicas by the computer device. Conversely, if the historical activation count remains constant, a higher number of physical experts previously allocated to a logical expert increases the likelihood that the corresponding logical expert will be placed in the root node, thus preventing the computer device from allocating too many expert replicas to logical experts that already have a large number of expert replicas configured.

[0118] For example, assuming E0 has been activated 50 times in the past, the initial value of E0's current sub-priority is -50, i.e., -50 / (1+0) = -50; after an allocation is completed, E0 is allocated 1 expert copy, and the value of E0's current sub-priority becomes -25, i.e., -50 / (1+1) = -25.

[0119] As another example, the initial value of the current sub-priority is a negative of the predicted activation count of the corresponding logical expert, and the non-initial value of the current sub-priority is the ratio of the predicted activation count of the corresponding logical expert to the number of physical experts previously allocated to the logical expert; the predicted activation count is obtained based on the historical activation count. In this way, the computer device can allocate a more reasonable number of expert replicas to each logical expert. For example, by using the predicted activation count to determine the current sub-priority, the value of the current sub-priority better reflects the subsequent operation of the hybrid expert model, thus facilitating an expert replica allocation method that better reflects the load change trend of the computing cluster and improving the accuracy of the number of expert replicas allocated to each logical expert by the computer device. Furthermore, if the number of physical experts previously allocated to a logical expert remains constant, a larger predicted activation count and a smaller current sub-priority value increase the likelihood that the corresponding logical expert will be placed in the root node and is more easily allocated expert replicas by the computer device. For example, if the number of predicted activations remains unchanged, the more physical experts a logic expert was previously assigned, the higher the current priority value, and the lower the probability that the corresponding logic expert will be placed in the root node. This can prevent the computer device from assigning too many expert replicas to logic experts that have already been configured with a large number of expert replicas.

[0120] Optionally, the computer device can predict the historical activation counts of multiple logic experts by employing a time series analysis model, thereby obtaining the predicted activation counts for each logic expert. The time series analysis model can be any of the following: an autoregressive integrated moving average model (ARIMA), an exponential smoothing model, etc.

[0121] The min-heap greedy algorithm can be used to assign one or more expert replicas to the logical expert with the smallest value at the current second priority (i.e., the root node in the min-heap data structure) during each expert replica allocation process.

[0122] Optionally, for any non-minimum redundancy level, during the current allocation process, the computer device can construct a min-heap data structure corresponding to the current allocation process based on the current sub-priority of each of the multiple logical experts in the third expert layer; allocate one or more expert replicas to the target logical expert, where the target logical expert is the logical expert corresponding to the root node in the min-heap data structure; update the current sub-priority of the target logical expert, and use the updated current sub-priority as the current sub-priority for the next allocation process. The next allocation process continues until the expert replica allocation is complete.

[0123] Compared to the linear scanning of multiple logical experts in the third expert layer during each allocation process (hereinafter referred to as "Method 1"), the computer device's use of a min-heap greedy algorithm can reduce time complexity and improve the generation efficiency of the target expert arrangement method. This is because, assuming there are E logical experts in the third expert layer, Method 1 has a time complexity of O(E), while the time complexity of the "extracting the minimum" and "insertion" operations in the min-heap greedy algorithm is only O(log E). This significantly reduces the total time complexity of allocating k×R redundant replicas from O(k×R×E) to O(k×R×logE), while maintaining the space complexity at O(E). Furthermore, by using the min-heap greedy algorithm, the computer device can maximize the improvement of the load bottleneck in the third expert layer with each redundant budget, achieving optimal load balancing for the third expert layer.

[0124] (2) Determining the layout:

[0125] In this embodiment, the arrangement method is used to divide the multiple physical experts of the third expert layer into multiple expert groups. The types of multiple physical experts in each expert group are different, and the number of expert groups in the third expert layer is the same as the number of computing cards.

[0126] In this system, for each logic expert in the third expert layer, there is one corresponding type; for each expert replica in the third expert layer, the type of each expert replica is the same as the type of the logic expert corresponding to that expert replica. For example, suppose the third expert layer has logic experts with expert numbers E0 and E1, and E1 has logic experts with expert numbers Er... 10 Er 11 For expert copies, E0 and E1 are of different types, E1 and Er 10 Er 11 They are of the same type.

[0127] Among them, the third expert layer includes a first physics expert and a second physics expert. The historical average load of the first physics expert is greater than that of the second physics expert. The first physics expert is assigned to an expert group before the second physics expert. The expert group to which the first physics expert belongs is the expert group with the lowest total load when the group to which the first physics expert belongs and whose type does not overlap with that of the first physics expert.

[0128] Among them, the historical average load of physical experts of the same type (similar to the current second priority in a min-heap greedy algorithm) is the same. The historical average load of each type of physical expert is the ratio of the historical activation count of the corresponding type of logical experts to the total number of physical experts of the corresponding type. For example, assume that multiple physical experts of type A include logical expert E1 and expert replicas corresponding to E1: Er 10 Er11 If E1 has 36 historical activations, then the historical average load of each type A physics expert is 12 (36 / 3).

[0129] For example, suppose the computing cluster includes 4 computing cards (i.e., there are 3 expert groups: group 0, group 1, group 2, and group 3), and the third expert layer includes multiple physical experts of the first type: E1, Er 10 Er 11 Er 12 Second type of multiple physics experts: E2, Er 20 If the historical average load of each type 1 physics expert is 30 and the historical average load of each type 2 physics expert is 20, then the computer equipment can determine that E1 belongs to group 0, Er... 10 Belongs to group 1, Er 11 Belongs to group 2, Er 12 E2 belongs to group 3, E2 belongs to group 0, Er 20 Belonging to Group 1. In addition, the third expert layer may also include multiple physics experts of other types, and these multiple physics experts of other types may also be divided into the four expert groups respectively.

[0130] In the prior art, after obtaining the expert allocation method of the third expert layer, the computer device can use the EPLB algorithm to arrange multiple physical experts of the third expert layer. However, the EPLB algorithm may allocate multiple expert copies of the same logical expert to the same GPU, which will lead to the following problems: (1) Uneven GPU load: The aggregation of multiple expert copies of high-load logical experts on the same GPU may lead to excessive load on that GPU, while the resources of other GPUs are not fully utilized. (2) Wasted video memory: Duplicate expert copies occupy video memory, reducing GPU storage efficiency.

[0131] Furthermore, in a computer cluster, communication time within the same computing card is less than communication time within the same computing device, which is less than communication time between different computing devices. Also, multiple computing cards can each store data for model inference. When a physics expert's computing card lacks the data required for inference, data must be retrieved across computing cards or computer devices before inference can proceed, reducing model inference efficiency.

[0132] Therefore, compared to the EPLB algorithm, this application divides physics experts of the same type into different expert groups, thereby dividing them into different computing cards. This reduces the probability of communication operations across computing cards or computer devices and improves model inference efficiency.

[0133] Furthermore, when dividing expert groups, the computer equipment will prioritize the expert groups to which physical experts with high historical average load belong, and will give priority to expert groups with the lowest total load and no overlap in types, so as to make the load among computing cards more balanced and improve the storage efficiency of computing cards.

[0134] As an example, this arrangement also involves assigning multiple expert groups from the third expert layer to a single computing card within a single computer device. These expert groups include a first expert group and a second expert group, where the type similarity between the first and second expert groups is greater than or equal to a similarity threshold, and the computer devices corresponding to the first and second expert groups are different. In this way, by assigning expert groups with high type similarity to different computer devices, the computer device can reduce the probability of cross-device communication operations, reduce cross-device communication overhead, increase the data throughput of the computer cluster, and improve model inference efficiency.

[0135] As one possible approach, after obtaining multiple expert groups from the third expert layer, the computer device can use a polling strategy to assign each expert group to a computing card within the computer device.

[0136] Based on the aforementioned example of expert group division, it can be seen that the closer the expert group numbers are, the higher the type similarity between expert groups. For example, compared with group 1, both group 0 and group 1 have physics experts of type 1 and type 2; compared with group 3, group 3 lacks physics experts of type 2.

[0137] For example, suppose a computing cluster includes two computer devices, each with two computing cards. Device 0 includes card 0 and card 1, and device 1 includes card 2 and card 3. However, when the computer devices use the EPLB algorithm to allocate computer devices and computing cards for multiple expert groups, the computer devices will assign group 0 to card 0 of device 0, group 1 to card 1 of device 0, group 2 to card 2 of device 1, and group 3 to card 3 of device 1, placing group 0 and group 1 on the same computer device. However, in this application, the computer devices can allocate group 0 to card 0 of device 0, group 1 to card 2 of device 1, group 2 to card 1 of device 0, and group 3 to card 3 of device 1 according to a round-robin strategy, thereby placing group 0 and group 1 on different computer devices. This helps reduce the probability of cross-computer device data acquisition operations and improves model inference efficiency.

[0138] Optionally, the computer device can count the number of identical types in any two expert groups, and count the total number of unique types included in any two expert groups (hereinafter referred to as "total number of types"), and use the ratio of the number of identical types to the total number of types as the type similarity between any two expert groups. The similarity threshold can be determined by the developers based on experience.

[0139] As another example, the arrangement method is also used to assign multiple expert groups in the third expert layer to a single computing card in a computer device; wherein, the multiple expert groups include a first expert group and a second expert group, the type similarity between the first expert group and the second expert group is greater than or equal to a similarity threshold, and the computer devices corresponding to the first expert group and the second expert group are the same. That is to say, the use of a polling strategy for placing expert groups in the computer device in this application is an optional strategy, and the computer device can also use the method corresponding to the EPLB algorithm to place expert groups, which is not limited here.

[0140] 3. Regarding the description of "Step 3: Select the target layout method corresponding to the third expert layer from the various layout methods corresponding to the third expert layer":

[0141] As one possible approach, for any given layout, the computer device can determine the simulated load balancing degree of that layout based on the total simulated computing load of each computing card. Then, the computer device can select the target layout corresponding to the third expert layer based on the simulated load balancing degrees of the various layout options available for the third expert layer.

[0142] In the third expert layer, the total simulated computing load of a computing card is the sum of the historical average loads of all physics experts in that computing card. The method for obtaining the simulated load balance based on the total simulated computing load of each computing card is similar to the method for "obtaining the historical load balance based on the total historical computing load of each computing card" in the aforementioned step S101, and will not be repeated here.

[0143] As one possible approach, once determined, the computer device can determine the target layout of each of the multiple expert layers based on their respective redundancy budgets. Then, it can compare the differences between the target layout of each expert layer and the layout in the initial expert layout, generate relevant instructions (such as one or more instructions for migrating physical experts or copying logical experts), adjust the initial expert layout, and obtain the target expert layout.

[0144] S104. The computer device receives an inference request.

[0145] Among them, the inference request refers to the need for a hybrid expert model to perform calculations and return inference results.

[0146] As one possible approach, the computer device could receive inference requests from a terminal device initiated by the user. For example, a user could input a voice message into the terminal device: "What's the weather like in City A tomorrow?" The terminal device could then convert this voice message into an inference request to obtain the weather forecast for City A tomorrow and send the request to the computer device.

[0147] S105. The computer device runs a hybrid expert model, uses the hybrid expert model to execute inference requests, and obtains inference results.

[0148] In the formal operation phase of the hybrid expert model, the current load balancing degree of the first expert layer is greater than that of the second expert layer, and the number of expert replicas in the first expert layer is greater than that in the second expert layer.

[0149] As one possible approach, a computer device can respond to a received inference request by running a hybrid expert model, inputting data related to the inference request into the hybrid expert model, and obtaining the inference result.

[0150] The data related to the inference request can be used to assist the hybrid expert model in obtaining the inference result. For example, when the inference request is "Please describe the contents of Figure A", the data related to the inference request may include Figure A. As another example, when the inference request is "What will the weather be like in City A tomorrow?", the data related to the inference request may include historical weather information for City A.

[0151] In this embodiment, the computer device can allocate the number of expert replicas to multiple expert layers differentially based on their load balancing. Specifically, the number of expert replicas for expert layers with high load balancing is greater than the number of expert replicas for expert layers with low load balancing. This not only enables reasonable control of computing cluster resources and avoids resource waste, but also reduces the load balancing of the hybrid expert model, thereby improving its performance and inference speed.

[0152] For example, when a computer cluster includes 32 computing cards, a hybrid expert model includes 58 expert layers, and the hybrid expert model performs inference based on the same dataset, the load balancing degree of each expert layer under different redundancy strategies and the optimal load balancing degree of each expert layer are as follows: Figure 3 As shown. Figure 3Different redundancy strategies include: baseline method (i.e., no expert layers have expert copies), redundancy of 10 layers (i.e., 10 expert layers have expert copies), redundancy of 20 layers (i.e., 20 expert layers have expert copies), redundancy of 30 layers (i.e., 30 expert layers have expert copies), redundancy of 40 layers (i.e., 40 expert layers have expert copies), and redundancy of 58 layers (i.e., 58 expert layers have expert copies). Figure 3 It can be seen that the load on each expert layer can be reduced by introducing expert copies.

[0153] For example, Figure 4 It shows in Figure 3 The theoretical heatmap shows the load distribution of each expert layer across different computing cards under each redundancy strategy. Figure 4 It can be seen that setting up expert replicas can make the load distribution more even.

[0154] In the expert load balancing method of the foregoing embodiments, the computer device can adjust the expert arrangement of the hybrid expert model before it runs. This application also provides another expert load balancing method. Based on this method, during the operation of the hybrid expert model, the computer device can dynamically adjust the arrangement of some expert layers. The following will describe in detail the other expert load balancing method provided by this application embodiment with reference to the accompanying drawings.

[0155] like Figure 5 As shown, container cluster detection methods can include S501-S504:

[0156] S501, The computer device receives an inference request.

[0157] For information on computer devices receiving inference requests, please refer to the above text. Figure 1 The introduction of S104 will not be repeated.

[0158] S502. The computer device runs a hybrid expert model, uses the hybrid expert model to execute inference requests, and obtains inference results.

[0159] For information on how computer devices produce inference results, please refer to the section above. Figure 1 The introduction of S105 will not be repeated here.

[0160] S503. During the operation of the hybrid expert model, the computer equipment obtains the simulated arrangement of the second target expert layer based on the redundancy budget of the second target expert layer; wherein, the second target expert layer is the expert layer whose current load balancing degree is greater than a preset threshold.

[0161] As one possible approach, during the operation of the hybrid expert model, the computer device can obtain the number of times each physical expert in each expert layer has been activated, and then obtain the current load balancing degree of each expert layer based on the number of times each physical expert in each expert layer has been activated. After obtaining the current load balancing degree of each expert layer, the computer device can compare the current load balancing degree of each expert layer with a preset threshold to obtain the expert layer whose current load balancing degree is greater than the preset threshold (i.e., the second target expert layer).

[0162] The activation count refers to the number of times a physical expert is selected by the gating network during the operation of the hybrid expert model.

[0163] In this embodiment of the application, the process by which the computer device determines the current load balancing degree is similar to... Figure 1 The process of determining the historical load balancing degree in step S101 is similar and will not be repeated here. The redundancy budget of the second target expert layer during the operation of the hybrid expert model can be the same as or different from the redundancy budget before the operation of the hybrid expert model; this application does not impose any limitations on this. When there are different redundancy budgets for the second target expert layer before and after the operation of the hybrid expert model, the redundancy budget of the second target expert layer during the operation of the hybrid expert model can be determined by the developers based on experience.

[0164] As one possible implementation method, the computer device obtains the implementation process of the simulated arrangement method of the second objective expert layer based on the redundancy budget of the second objective expert layer. Figure 1 The process of obtaining the target arrangement method of the third expert layer in step S103 is similar and will not be repeated here.

[0165] As another possible implementation method, the computer device obtains the simulation arrangement method of the second target expert layer based on the redundancy budget of the second target expert layer. The implementation process is similar to that of existing technologies (such as the EPLB algorithm), and will not be described in detail here.

[0166] S504. When the difference between the current load balancing degree and the load balancing degree of the simulated arrangement is greater than or equal to the preset difference, the computer equipment will adjust the arrangement of the target expert layer to the simulated arrangement.

[0167] As one possible approach, when the difference between the current load balancing degree and the load balancing degree of the simulated arrangement is greater than or equal to a preset difference, the computer device will adjust the arrangement of the target expert layer to the simulated arrangement; when the difference between the current load balancing degree and the load balancing degree of the simulated arrangement is less than the preset difference, the computer device will abandon adjusting the arrangement of the target expert layer to the simulated arrangement.

[0168] As an example, the difference between the current load balancing and the load balancing of the simulated load balancing can be the difference between the current load balancing and the load balancing of the simulated load balancing. In this case, the preset difference can refer to a preset data difference.

[0169] As another example, the difference between the current load balancing and the simulated load balancing can be described as the difference level between the two load balancing methods. In this case, the preset difference can refer to a preset level difference.

[0170] It should be noted that the computer device can execute steps S502, S503, and S504 during the operation of the hybrid expert model, but there is no obvious order between S502 and step S503, or between S502 and step S504.

[0171] In some possible scenarios, the computer device may not execute steps S503 and S504, for example, in scenarios where there is no second target expert layer.

[0172] In this embodiment, the computer device can dynamically adjust the arrangement of the second target expert layer of the hybrid expert model based on its operation, thereby optimizing the load balancing of the hybrid expert model in real time. Furthermore, the computer device introduces a dual gating mechanism of preset thresholds and preset differences, ensuring that dynamic adjustments only occur when necessary and yield significant benefits. This effectively prevents the hybrid expert model from fluctuating due to frequent or ineffective adjustments, thus guaranteeing the stability of the hybrid expert model's operation.

[0173] It should be noted that the algorithm used in this application to obtain the arrangement of the target experts and / or the algorithm used to dynamically adjust the arrangement of the second target expert layer can be referred to as the OmniPlacement algorithm. The OmniPlacement algorithm can be deployed on the Ascend platform, and its code structure can be as follows: Figure 6 As shown. (Through) Figure 6As can be seen, the code project structure of the OmniPlacement algorithm includes the omni_planner folder, which contains the following: the optim folder, the _init_.py file, the cluster_status.py file, the config.py file, and the omni_planner.py file. The optim folder contains the following: the _init_.py file, the ada_router_optimizer.py file, the optimizers.py file, the optimizers_loader.py file, the redundant_experts_optimizer.py file, and the token_balance_optimizer.py file.

[0174] The OmniPlacement algorithm was validated on the Ascend platform using computer equipment, and the performance validation results are as follows:

[0175] (1) Inference latency optimization: Compared with the hybrid expert model without load balancing optimization, the inference latency of the OmniPlacement algorithm is reduced by about 10%. The inference latency optimization is due to the dynamic adjustment of the arrangement of the second objective expert layer and the saving of communication overhead (such as not having the same type of physical experts in the same expert group, or avoiding the group of experts with high type similarity in the same computer device as much as possible), which improves the user experience.

[0176] (2) Increased throughput: Compared to the hybrid expert model without load balancing optimization, the OmniPlacement algorithm increases the throughput of the hybrid expert model by about 10%. The increase in throughput is due to the optimization of resource utilization. For example, in high-concurrency scenarios, the redundant deployment of inter-layer differences and the arrangement of dynamic second target expert layers alleviate the load bottleneck and improve resource utilization.

[0177] (3) Increased stability of the hybrid expert model: Under dynamic input and high load scenarios, the system maintains stable operation without performance fluctuations or service interruptions. The dynamic monitoring mechanism supports the system's response to sudden loads.

[0178] The above verification also shows that the OmniPlacement algorithm is applicable to a variety of hybrid expert models and input data distributions, and supports the deployment of large-scale hybrid expert models.

[0179] It should be understood that the various solutions in the embodiments of this application can be used in a reasonable combination, and the explanations or descriptions of the various terms appearing in the embodiments can be referenced or explained to each other in the various embodiments, without limitation.

[0180] It should also be understood that, in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0181] The methods provided in the embodiments of this application above are described from the perspective of a computer device as the executing entity. To implement the functions of the methods provided in the embodiments of this application above, the computer device may include hardware structures and / or software modules, implementing the above functions in the form of hardware structures, software modules, or a combination of hardware structures and software modules. Whether a particular function is executed in the form of hardware structures, software modules, or a combination of hardware structures and software modules depends on the specific application and design constraints of the technical solution.

[0182] This application embodiment can divide a computer device into functional modules. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware or as software functional modules. It should be noted that the module division in this application embodiment is illustrative and represents only one logical functional division; in actual implementation, other division methods may be used.

[0183] As an example, Figure 7 This is a schematic diagram of the structure of an expert load balancing device provided in an embodiment of this application. Figure 7 The expert load balancer 700 shown can be applied to computer equipment, or the expert load balancer 700 can be a computer device. The expert load balancer 700 includes:

[0184] The receiving module 710 is used to receive inference requests.

[0185] The inference module 720 is used to run a hybrid expert model, execute inference requests using the hybrid expert model, and obtain inference results. The hybrid expert model includes multiple expert layers, including a first expert layer and a second expert layer. Under the target expert arrangement, the current load balancing degree of the first expert layer is greater than that of the second expert layer, and the number of expert replicas in the first expert layer is greater than that in the second expert layer.

[0186] As one possible implementation, the expert load balancer 700 also includes a layout module 730.

[0187] The arrangement module 730 is used to obtain the historical load balancing degree of each of the multiple expert layers under the initial expert arrangement method before the hybrid expert model is run; to obtain the redundancy budget of each of the multiple expert layers based on the total redundancy budget of the computing cluster and the historical load balancing degree of each of the multiple expert layers; and to adjust the initial expert arrangement method based on the redundancy budget of each of the multiple expert layers to obtain the target expert arrangement method.

[0188] The layout module 730 is also used to obtain the simulated layout method of the target expert layer based on the redundancy budget of the second target expert layer during the operation of the hybrid expert model; wherein, the second target expert layer is the expert layer whose current load balancing degree is greater than a preset threshold; when the difference between the current load balancing degree and the load balancing degree of the simulated layout method is greater than or equal to a preset difference, the layout method of the target expert layer is adjusted to the simulated layout method.

[0189] For example, combining Figure 1 The receiving module 710 is used to perform Figure 1 S104 in the inference module 720 is used to execute Figure 1 S105, the layout module 730 is used to execute Figure 1 S101 to S103 in the example.

[0190] For example, combining Figure 5 The receiving module 710 is used to perform Figure 5 S501; Inference module 720 is used to execute Figure 5 In S502, the layout module 730 is used to execute... Figure 5 S503 and S504 in the example.

[0191] It should be understood that the various modules in a computer device can be implemented in software and / or hardware, without specific limitations. In other words, a computer device is presented in the form of functional modules. Here, "module" can refer to application-specific integrated circuits (ASICs), circuits, processors and memory that execute one or more software or firmware programs, integrated logic circuits, and / or other devices that can provide the aforementioned functions.

[0192] The foregoing Figure 7 Some or all of the modules in the expert load balancing device 700 can operate in Figure 8 On the computer device shown, Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 8 The computer device 800 shown includes at least: a memory 810, a processor 820, a communication interface 830, and a bus 840.

[0193] The communication interface 830 uses a transceiver module, such as, but not limited to, a transceiver, to enable communication between the computer device 800 and other devices or communication networks. The communication interface 830 can be used to receive inference requests.

[0194] The processor 820 can be used to run a hybrid expert model, execute inference requests using the hybrid expert model, obtain inference results, and / or other processes related to the implementation of this application. The memory 810 can be used to store the logic code corresponding to the container cluster detection method provided in the embodiments of this application.

[0195] Optionally, the computer device 800 can be various types of server devices such as rack servers and full rack servers. The computer device 800 can also be terminal computer devices such as computers, mobile terminals, tablet computers, laptops, desktop computers, all-in-one computers, personal digital assistants (PDAs), and ultra-mobile personal computers (UMPCs).

[0196] Optionally, the memory 810 may include random access memory (RAM), read-only memory (ROM), etc., wherein the memory 810 can run the necessary operating system and receiving module (corresponding) in its RAM. Figure 7 The receiving module 710) and the inference module (corresponding to) Figure 7 The reasoning module 720 and the layout module (corresponding to) Figure 7 The module 730 in the middle is used to execute the expert load balancing method provided in this application.

[0197] Optionally, the memory 810 can also run the necessary operating system and receiving module (corresponding) in its RAM. Figure 7 The receiving module 710) and the inference module (corresponding to) Figure 7 The reasoning module 720 and the layout module (corresponding to) Figure 7 The module 730 in the middle is used to execute the expert load balancing method provided in this application.

[0198] Optionally, the processor 820 can be a central processing unit (CPU) or other general-purpose processor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), digital signal processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0199] Optionally, bus 840 can be a peripheral component interconnect (PCI) bus, etc., and this application does not limit the type of bus. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 8 The bus 840 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 840 may include a path for transmitting information between various components of the computer device 800 (e.g., memory 810, processor 820, and communication interface 830).

[0200] In the above embodiments, depending on the context, the terms "when / at..." or "after..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrases "when determining...", "if (the stated condition or event)" or "if..." can be interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event)" or "in response to detecting (the stated condition or event)". Furthermore, in the above embodiments, relational terms such as "first" and "second" are used to distinguish one entity from another, without limiting any actual relationship or order between these entities.

[0201] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0202] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this embodiment are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The computer-readable storage 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., a solid-state disk (SSD)). Where there is no conflict, the solutions in the above embodiments can be used in combination.

[0203] The steps of the methods or algorithms described in the embodiments of this application can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in RAM, flash memory, ROM, EPROM, EEPROM, registers, hard disk, portable hard disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Alternatively, the ASIC can reside in a computer device. Of course, the processor and storage medium can also exist as discrete components in the computer device.

[0204] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

Claims

1. An expert load balancing method, characterized in that, The method, applied to any computer device in a computing cluster, includes: Receive inference request; Run a hybrid expert model, execute the inference request using the hybrid expert model, and obtain the inference result; wherein, the hybrid expert model includes multiple expert layers, the multiple expert layers include a first expert layer and a second expert layer; the current load balancing degree of the first expert layer is greater than the current load balancing degree of the second expert layer, and the number of expert replicas of the first expert layer is greater than the number of expert replicas of the second expert layer.

2. The method according to claim 1, characterized in that, Each expert layer includes multiple physical experts, and each physical expert is a logical expert or an expert copy; the computing cluster includes multiple computing cards, and the multiple physical experts of each expert layer are distributed on the multiple computing cards; Prior to receiving the inference request, the method further includes: Obtain the historical load balancing degree of each of the multiple expert layers under the initial expert arrangement; Based on the total redundancy budget of the computing cluster and the historical load balancing of each of the multiple expert layers, the redundancy budget of each of the multiple expert layers is obtained; wherein, the total redundancy budget represents the maximum number of redundancy positions in the multiple expert layers in a computing card; the redundancy budget represents the number of redundancy positions that a computing card can support in the corresponding expert layer, and one redundancy position is used to place one physical expert. Based on the redundancy budgets of each of the multiple expert layers, the initial expert arrangement is adjusted to obtain the target expert arrangement; the target arrangement represents the distribution position of multiple physical experts of each of the multiple expert layers on the computing cluster during the operation of the hybrid expert model.

3. The method according to claim 2, characterized in that, The step of obtaining the redundancy budget for each of the multiple expert layers based on the total redundancy budget of the computing cluster and the historical load balancing of each of the multiple expert layers includes: Based on the total redundancy budget and the historical load balancing degree of each of the multiple expert layers, the theoretical redundancy budget of each of the multiple expert layers is obtained; wherein, the historical load balancing degree of each expert layer is positively correlated with the theoretical redundancy budget; The total remaining redundant budget is allocated to obtain the remaining redundant budget for each of the multiple expert layers; wherein, the total remaining redundant budget is the redundant budget in the total redundant budget excluding the initial redundant budget for each of the multiple expert layers; the initial redundant budget is determined based on the theoretical redundant budget; The redundancy budgets for each of the multiple expert layers are obtained based on their initial redundancy budgets and remaining redundancy budgets.

4. The method according to claim 3, characterized in that, The plurality of expert layers includes a third expert layer, which is any one of the plurality of expert layers; If the integer redundancy budget of the third expert layer is greater than or equal to the single-layer maximum redundancy budget of the third expert layer, then the initial redundancy budget of the third expert layer is the single-layer maximum redundancy budget. If the integer redundancy budget of the third expert layer is less than the maximum single-layer redundancy budget of the third expert layer, then the initial redundancy budget of the third expert layer is the integer redundancy budget of the third expert layer. The maximum redundancy budget of the third expert layer represents the maximum number of redundant positions of the third expert layer in a computing card.

5. The method according to claim 3 or 4, characterized in that, The total remaining redundancy budget includes at least one remaining redundancy location. The allocation of the total remaining redundancy budget to obtain the remaining redundancy budgets for each of the multiple expert layers includes: Obtain the first target expert layer; The total remaining redundant budget is allocated to the at least one target expert layer according to the difference in redundant budget of at least one first target expert layer; wherein the first target expert layer is the expert layer whose initial redundant budget is less than the maximum redundant budget of a single layer, and the difference is the difference between the theoretical redundant budget and the initial redundant budget.

6. The method according to any one of claims 2-5, characterized in that, The plurality of expert layers includes a third expert layer, which is any one of the plurality of expert layers; the step of adjusting the initial expert arrangement according to the redundancy budget of each of the plurality of expert layers to obtain the target expert arrangement includes: Multiple redundancy levels are obtained for the third expert layer, where each redundancy level represents the number of redundant locations that a computing card can be configured in the third expert layer under the redundancy budget of the third expert layer. Obtain multiple arrangement methods corresponding to the multiple redundancy levels; wherein, the arrangement method represents the distribution position of multiple physical experts in the third expert layer on the computing cluster; one arrangement method corresponds to one expert replica allocation method; the expert replica allocation method represents the number of expert replicas of each of the multiple logical experts in the third expert layer under the corresponding redundancy level; From the multiple arrangement methods corresponding to the third expert layer, select the target arrangement method corresponding to the third expert layer; wherein the simulated load balancing degree corresponding to the target arrangement method is less than or equal to the minimum simulated load balancing degree corresponding to the non-target arrangement method. Based on the target arrangement method corresponding to the third expert layer, the initial expert arrangement method is adjusted to obtain the target expert arrangement method.

7. The method according to claim 6, characterized in that, The allocation method for expert replicas at any non-minimum redundancy level is obtained based on a greedy algorithm of min-heap; wherein, the nodes in the min-heap data structure are tuples, and the tuples include the expert number of a logical expert in the third expert layer and the current sub-priority of the logical expert. The initial value of the current sub-priority is a negative number of the historical activation count of the corresponding logic expert, and the non-initial value of the current sub-priority is the ratio of the historical activation count of the corresponding logic expert to the number of physical experts previously allocated to the logic expert. Alternatively, the initial value of the current sub-priority is a negative number of the predicted activation count of the corresponding logic expert, and the non-initial value of the current sub-priority is the ratio of the predicted activation count of the corresponding logic expert to the number of physical experts previously allocated to the logic expert; the predicted activation count is obtained by prediction based on the historical activation count.

8. The method according to claim 6, characterized in that, The arrangement method is used to divide the multiple physical experts in the third expert layer into multiple expert groups. The types of multiple physical experts in each expert group are different. The number of expert groups in the third expert layer is the same as the number of computing cards.

9. The method according to claim 8, characterized in that, The third expert layer includes a first physical expert and a second physical expert. The historical average load of the first physical expert is greater than that of the second physical expert. The first physical expert is assigned to an expert group before the second physical expert. The expert group to which the first physical expert belongs is the expert group with the lowest total load when the group to which the first physical expert belongs and whose type does not overlap with that of the first physical expert.

10. The method according to claim 8 or 9, characterized in that, The computing cluster includes multiple computer devices, each of which includes at least one computing card. The arrangement is used to assign the multiple expert groups to one computing card in one of the computer devices. The multiple expert groups include a first expert group and a second expert group. The type similarity between the first expert group and the second expert group is greater than or equal to a similarity threshold. The computer devices corresponding to the first expert group and the second expert group are different.

11. The method according to any one of claims 1-10, characterized in that, During the operation of the hybrid expert model, the method further includes: Based on the redundancy budget of the second target expert layer, the simulated arrangement of the target expert layer is obtained; wherein, the second target expert layer is the expert layer whose current load balancing degree is greater than a preset threshold; When the difference between the current load balancing degree and the load balancing degree of the simulated arrangement is greater than or equal to a preset difference, the arrangement of the target expert layer is adjusted to the simulated arrangement.

12. An expert load balancing device, characterized in that, The expert load balancer, running on any computer device in the computing cluster, includes: The receiving module is used to receive inference requests; The inference module is used to run the hybrid expert model, execute the inference request using the hybrid expert model, and obtain the inference result; wherein, the hybrid expert model includes multiple expert layers, the multiple expert layers include a first expert layer and a second expert layer; under the target expert arrangement method, the current load balancing degree of the first expert layer is greater than the current load balancing degree of the second expert layer, and the number of expert replicas of the first expert layer is greater than the number of expert replicas of the second expert layer.

13. A computer device, characterized in that, The computer equipment is deployed in a computing cluster, and the computer equipment includes: Memory is used to store computer program instructions; A processor for executing the computer program instructions to support the computer device in implementing the method as described in any one of claims 1-11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processing circuit, implement the method as described in any one of claims 1-11.

15. A computer program product containing instructions, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1-11.