Model inference method and apparatus, electronic device, storage medium, and program product

By determining the quantization accuracy and matching a suitable chip architecture based on the weight data distribution of each expert module in a large-scale neural network model, the problem of wasted hardware resources is solved, and more efficient model inference and cost reduction are achieved.

CN118469015BActive Publication Date: 2026-11-27SHANGHAI BIREN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410635870.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-21
Publication Date
2026-11-27
Estimated Expiration
2044-05-21

AI Technical Summary

Technical Problem

In large-scale neural network models, the use of the same chip architecture type leads to a waste of hardware resources and makes it impossible to effectively utilize the differences in the sensitivity of weight data quantization of different expert modules.

Method used

Based on the weight data distribution of each expert module, the quantization accuracy is determined, and a suitable chip architecture type is matched for model inference to reduce the waste of hardware resources.

Benefits of technology

By optimizing the heterogeneous chip architecture, more efficient model inference can be achieved, reducing costs and improving hardware utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118469015B_ABST
    Figure CN118469015B_ABST
Patent Text Reader

Abstract

The present application provides a model reasoning method, device, electronic equipment, storage medium and program product, the method comprises: determining the quantization precision of the weight data of each expert module based on the weight data distribution of each expert module in the model; determining the chip architecture type corresponding to each expert module based on the quantization precision of each weight data; determining the chip architecture corresponding to each expert module based on the chip architecture type corresponding to each expert module, so as to perform model reasoning on the chip architecture corresponding to each expert module. The present application can adapt the appropriate chip architecture to different expert modules according to task requirements and complexity, reduce the waste of hardware resources and reduce costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a model reasoning method, apparatus, electronic device, storage medium, and program product. Background Technology

[0002] Large model inference typically refers to the process of using large-scale neural network models for data analysis and decision-making. In the field of deep learning, large models usually refer to models with millions or even billions of parameters. For example, the Mixture of Experts (MoE) is a special type of large model architecture that aims to improve efficiency and flexibility by decomposing a large model into multiple smaller sub-models (i.e., "experts"), each of which focuses on handling a specific type of input or task.

[0003] In MoE, all experts use the same chip architecture, meaning all experts use the same type of chip architecture for computation. However, after quantization, the scale and computational load of the weight data differ among different experts, and using the same type of chip architecture for computation would result in a waste of hardware resources. Summary of the Invention

[0004] This invention provides a model reasoning method, apparatus, electronic device, storage medium, and program product to address the deficiencies in the prior art.

[0005] This invention provides a model reasoning method, comprising:

[0006] Based on the weight data distribution of each expert module in the model, the quantization accuracy of the weight data of each expert module is determined.

[0007] Based on the quantization accuracy of each weight data, the chip architecture type corresponding to each expert module is determined.

[0008] Based on the chip architecture type corresponding to each expert module, the chip architecture corresponding to each expert module is determined so that model inference can be performed on the chip architecture corresponding to each expert module.

[0009] According to a model reasoning method provided by the present invention, the weight data distribution of each expert module is determined based on the range of variation between the maximum and minimum element values ​​in the weight data of each expert module, and the differences between the element values ​​in the weight data of each expert module.

[0010] According to a model inference method provided by the present invention, determining the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module in the model includes:

[0011] If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module exceeds a preset range, and the difference between the element values ​​in the weight data of any expert module is greater than a preset value, the first quantization precision shall be used as the quantization precision of the weight data of any expert module.

[0012] If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module is within the preset range, and the difference between each element value in the weight data of any expert module is less than or equal to the preset value, then the second quantization precision shall be used as the quantization precision of the weight data of any expert module.

[0013] The first quantization precision is higher than the second quantization precision.

[0014] According to a model inference method provided by the present invention, the step of determining the chip architecture corresponding to each expert module based on the chip architecture type of each expert module further includes:

[0015] Each weight data is assigned to the chip architecture of the corresponding expert module to perform model inference calculations on the corresponding chip architecture.

[0016] According to a model inference method provided by the present invention, the step of determining the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module in the model further includes:

[0017] Based on the quantization precision of each weight data, each weight data is quantized.

[0018] According to the present invention, a model reasoning method is provided, wherein the model is a text generation model.

[0019] The present invention also provides a model reasoning device, comprising:

[0020] The accuracy determination unit is used to determine the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module in the model.

[0021] An architecture determination unit is used to determine the chip architecture type corresponding to each expert module based on the quantization accuracy of each weight data.

[0022] The model inference unit is used to determine the chip architecture corresponding to each expert module based on the chip architecture type corresponding to each expert module, so as to perform model inference on the chip architecture corresponding to each expert module.

[0023] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the model inference method as described above.

[0024] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the model inference method as described above.

[0025] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the model inference method as described above.

[0026] The model inference method, apparatus, electronic device, storage medium, and program product provided by this invention determine the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module. This allows for matching different chip architecture types to each expert module based on the quantization accuracy of the weight data, and determining the corresponding chip architecture for each expert module according to the chip architecture type. This enables the allocation of weight data from different expert modules to different chip architectures for model inference. In other words, this invention can adapt suitable chip architectures to different expert modules according to task requirements and complexity, reducing the waste of hardware resources and lowering costs. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0028] Figure 1 This is a flowchart illustrating the model reasoning method provided by the present invention;

[0029] Figure 2 This is a schematic diagram of the chip architecture allocation of each expert module provided by the present invention;

[0030] Figure 3 This is a schematic diagram of the structure of the model reasoning device provided by the present invention;

[0031] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0032] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0033] MoE employs multiple FFNs in its Feedforward Neural Network (FFN) layers, each representing an expert with varying sensitivities to different tasks. Inference is performed through these multiple experts. Low-precision quantization accelerates the inference process by reducing the number of bits in the weights and activations of the neural network model, while maintaining performance as much as possible. Low-precision quantization significantly reduces the model's memory footprint and computational requirements.

[0034] Currently, all FFN experts in MoE use the same data precision. Even when quantization is used, it is performed on all FFN experts. The above quantization method has the following problems:

[0035] First, the quantization sensitivity of weight data varies among different FFN experts. That is, the precision of weight data from some FFN experts is not lost after quantization, and it can even be quantized to a lower number of bits. However, the precision of weight data from some FFN experts is greatly lost after quantization and cannot be quantized at all.

[0036] Secondly, all experts use the same type of chip architecture for calculation. However, after quantization, the scale and computational load of the weight data differ among different experts. Using the same type of chip architecture for calculation will result in a waste of hardware resources.

[0037] In response, this invention provides a model reasoning method. Figure 1 This is a flowchart illustrating the model reasoning method provided by the present invention, as shown below. Figure 1 As shown, the method includes the following steps:

[0038] Step 110: Based on the weight data distribution of each expert module in the model, determine the quantization accuracy of the weight data of each expert module.

[0039] Specifically, each expert module in the model can be understood as an expert in MoE, which can be constructed based on FFN. The weight data distribution of each expert module is used to characterize the range of data variation of the weight data in each expert module (such as the range of variation between the maximum and minimum element values) and the distribution of each element value in the weight data (such as whether the data of each element value is stationary). Among them, the weight data distribution of each expert module can be statistically analyzed offline in advance.

[0040] Optionally, if the range of variation of the weight data in any expert module is large, and the distribution of the element values ​​of the weight data is not stable, then there will be a significant loss of precision during the quantization of the corresponding weight data. In other words, the corresponding weight data has high quantization sensitivity and is difficult to quantize. Conversely, if the range of variation of the weight data in any expert module is small, and the distribution of the element values ​​of the weight data is relatively stable, then the corresponding weight data can be quantized to a lower bit level. In other words, the corresponding weight data has low quantization sensitivity and can be quantized with lower precision.

[0041] Therefore, based on the weight data distribution of each expert module, the quantization sensitivity of the weight data of each expert module can be determined, and thus the quantization accuracy of the weight data of each expert module can be determined based on the quantization sensitivity of the weight data.

[0042] Step 120: Based on the quantization accuracy of each weight data, determine the chip architecture type corresponding to each expert module.

[0043] Step 130: Based on the chip architecture type corresponding to each expert module, determine the chip architecture corresponding to each expert module so as to perform model inference on the chip architecture corresponding to each expert module.

[0044] Specifically, after determining the quantization precision of the weight data for each expert module, the weight data can be quantized based on this precision. Since the quantization precision varies for the weight data of different expert modules, the scale and computational complexity of the quantized weight data for each module will also differ. If all expert modules use the same type of chip architecture to calculate the weight data, there may be a waste of hardware resources.

[0045] For example, the model includes expert module 1 and expert module 2. Both expert module 1 and expert module 2 use chip architecture 'a'. The size of the weight data in expert module 1 after quantization is larger than that in expert module 2, and the computational cost of the weight data in expert module 1 after quantization is also greater than that in expert module 2. In other words, expert module 2 can use a lower-performance chip architecture for model inference compared to expert module 1. Using a higher-performance chip architecture 'a' for expert module 2 might result in wasted hardware resources.

[0046] To address this, this invention matches different chip architecture types to each expert module based on the quantization accuracy of each weight data, and determines the corresponding chip architecture for each expert module according to the chip architecture type. This allows the weight data of different expert modules to be allocated to different chip architectures for model inference. In other words, this invention can adapt suitable chip architectures for different expert modules according to task requirements and complexity, reducing hardware resource waste and lowering costs. Furthermore, this invention, through heterogeneous implementation at the same resource cost, can support larger-scale MoE models and achieve better model inference performance.

[0047] The model inference method provided in this invention determines the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module. This allows for matching different chip architecture types to each expert module based on the quantization accuracy of the weight data, and determining the corresponding chip architecture for each expert module according to the chip architecture type. This enables the allocation of weight data from different expert modules to different chip architectures for model inference. In other words, this invention can adapt suitable chip architectures to different expert modules according to task requirements and complexity, reducing the waste of hardware resources and lowering costs.

[0048] As an optional embodiment, the model here can be a text generation model. The weight data of each expert module can be selected based on the input text. The model reasoning method described above is used to perform model reasoning to obtain the output text corresponding to the input text, which can reduce the waste of hardware resources and reduce costs.

[0049] Based on the above embodiments, the quantization accuracy of the weight data of each expert module is determined based on the weight data distribution of each expert module in the model, and then the process further includes:

[0050] Based on the quantization accuracy of each weight data, the weight data is quantized.

[0051] Specifically, after determining the quantization accuracy of the weight data for each expert module, the weight data is quantized based on the quantization accuracy of each weight data, thereby reducing storage resources and computational load.

[0052] Furthermore, since the quantization accuracy of each weight data in the embodiments of the present invention is determined based on the weight data distribution of each expert module, that is, the quantization sensitivity of each weight data is considered when determining the quantization accuracy of each weight data, thereby realizing adaptive quantization of each weight data, ensuring accuracy while reducing storage resources and computational load.

[0053] For example, assuming the MoE includes eight expert modules (i.e., expert modules 1 to 8), based on the weight data distribution of each expert module, it is determined that the weight data of expert modules 1 and 7 are not suitable for quantization. That is, the weight data of expert modules 1 and 7 retain their original precision. The quantization precision of the weight data of expert modules 2, 3, and 5 is 8 bits (e.g., int8, FP8), and the quantization precision of the weight data of expert modules 4, 6, and 8 is 4 bits (e.g., int4, FP4). The above quantization precision is an example; other quantization precisions can be used according to actual needs.

[0054] Based on any of the above embodiments, the chip architecture corresponding to each expert module is determined based on the chip architecture type corresponding to each expert module, and then the process further includes:

[0055] Each weight data is assigned to the chip architecture of the corresponding expert module so that model inference calculations can be performed on the corresponding chip architecture.

[0056] Specifically, after determining the chip architecture corresponding to each expert module, the weight data is allocated to the chip architecture of the corresponding expert module so that model inference calculation can be performed on the corresponding chip architecture.

[0057] For example, if the weight data of expert modules 1 and 7 maintain their original precision, the quantization precision of the weight data of expert modules 2, 3 and 5 is 8 bits, and the quantization precision of the weight data of expert modules 4, 6 and 8 is 4 bits, then expert modules 1 and 7 correspond to the same chip architecture type, expert modules 2, 3 and 5 correspond to the same chip architecture type, and expert modules 4, 6 and 8 correspond to the same chip architecture type.

[0058] Figure 2 This is a schematic diagram of the chip architecture allocation of each expert module provided by the present invention, such as... Figure 2As shown, FFN1 represents expert module 1, FFN2 represents expert module 2, FFN3 represents expert module 3, FFN4 represents expert module 4, FFN5 represents expert module 5, FFN6 represents expert module 6, FFN7 represents expert module 7, and FFN8 represents expert module 8. FFN1 and FFN7 correspond to chip architecture A, FFN2, FFN3, and FFN7 correspond to chip architecture B, and FFN4, FFN6, and FFN8 correspond to chip architecture C. Following the example above, the weight data of FFN1 and FFN7 maintains its original precision, the quantization precision of the weight data of FFN2, FFN3, and FFN7 is 8 bits, and the quantization precision of the weight data of FFN4, FFN6, and FFN8 is 4 bits. Correspondingly, the computing power of chip architecture B can be half that of chip architecture A, thus requiring less storage and significantly reducing chip costs. Similarly, the computing power of chip architecture C can be 1 / 4 that of chip architecture A, allowing chip architecture C to use lower-performance chips, further reducing chip costs.

[0059] Based on any of the above embodiments, the weight data distribution of each expert module is determined based on the range of variation between the maximum and minimum element values ​​in the weight data of each expert module, and the differences between the element values ​​in the weight data of each expert module.

[0060] Specifically, the range between the maximum and minimum element values ​​is used to characterize the range of variation in the weighted data. For example, a large range between the maximum and minimum element values ​​indicates a large range of variation in the corresponding data. Furthermore, the differences between the element values ​​in the weighted data are used to characterize whether the data distribution is stable. Differences between element values ​​indicate that the data distribution is not stable.

[0061] Based on this, by combining the range of variation between the maximum and minimum element values ​​in the weight data of each expert module, as well as the differences between the element values ​​in the weight data of each expert module, the weight data distribution of each expert module can be accurately determined. Thus, the quantization accuracy of each weight data can be determined based on the weight data distribution of each expert module, so as to match different chip architecture types for each expert module.

[0062] Based on any of the above embodiments, the quantization accuracy of the weight data of each expert module is determined based on the weight data distribution of each expert module in the model, including:

[0063] If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module exceeds the preset range, and the difference between the element values ​​in the weight data of any expert module is greater than the preset value, the first quantization precision shall be used as the quantization precision of the weight data of any expert module.

[0064] If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module is within a preset range, and the difference between each element value in the weight data of any expert module is less than or equal to a preset value, then the second quantization precision shall be used as the quantization precision of the weight data of any expert module.

[0065] The first quantization precision is higher than the second quantization precision.

[0066] Specifically, if the range of variation between the maximum and minimum element values ​​in the weight data of any expert module exceeds the preset range, it indicates that the range of variation of the weight data in any expert module is large; and if the difference between the element values ​​in the weight data of any expert module is greater than the preset value, it indicates that the data distribution of the element values ​​in the weight data of any expert module is not stable, which will result in a large loss of precision when quantizing the corresponding weight data, that is, the corresponding weight data quantization sensitivity is high. In this case, the first quantization precision with higher precision is used as the quantization precision of the weight data of any expert module.

[0067] If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module is within a preset range, it indicates that the range of variation of the weight data in any expert module is small. Furthermore, if the difference between the element values ​​in the weight data of any expert module is less than or equal to a preset value, it indicates that the data distribution of the element values ​​in the weight data of any expert module is relatively stable. Consequently, the corresponding weight data can be quantized to a lower bit, which means that the quantization sensitivity of the corresponding weight data is low. Therefore, a second quantization precision with lower precision can be used as the quantization precision of the weight data of any expert module.

[0068] Based on any of the above embodiments, the model here can be a text generation model. The weight data of each expert module can be selected based on the input text. The model reasoning method described above is used to perform model reasoning to obtain the output text corresponding to the input text, which can reduce the waste of hardware resources and reduce costs.

[0069] The model reasoning apparatus provided by the present invention is described below. The model reasoning apparatus described below and the model reasoning method described above can be referred to in correspondence.

[0070] Based on any of the above embodiments Figure 3 This is a schematic diagram of the structure of the model inference device provided by the present invention, as shown below. Figure 3 As shown, the device includes:

[0071] The accuracy determination unit 310 is used to determine the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module in the model.

[0072] Architecture determination unit 320 is used to determine the chip architecture type corresponding to each expert module based on the quantization accuracy of each weight data;

[0073] The model inference unit 330 is used to determine the chip architecture corresponding to each expert module based on the chip architecture type corresponding to each expert module, so as to perform model inference on the chip architecture corresponding to each expert module.

[0074] Based on any of the above embodiments, the quantization accuracy of the weight data of each expert module is determined based on the weight data distribution of each expert module in the model, and then the method further includes:

[0075] Based on the quantization accuracy of each weight data, the weight data is quantized.

[0076] Based on any of the above embodiments, the chip architecture corresponding to each expert module is determined based on the chip architecture type corresponding to each expert module, and then the process further includes:

[0077] Each weight data is assigned to the chip architecture of the corresponding expert module so that model inference calculations can be performed on the corresponding chip architecture.

[0078] Based on any of the above embodiments, the weight data distribution of each expert module is determined based on the range of variation between the maximum and minimum element values ​​in the weight data of each expert module, and the differences between the element values ​​in the weight data of each expert module.

[0079] Based on any of the above embodiments, the quantization accuracy of the weight data of each expert module is determined based on the weight data distribution of each expert module in the model, including:

[0080] If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module exceeds the preset range, and the difference between the element values ​​in the weight data of any expert module is greater than the preset value, the first quantization precision shall be used as the quantization precision of the weight data of any expert module.

[0081] If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module is within a preset range, and the difference between each element value in the weight data of any expert module is less than or equal to a preset value, then the second quantization precision shall be used as the quantization precision of the weight data of any expert module.

[0082] The first quantization precision is higher than the second quantization precision.

[0083] Based on any of the above embodiments, the model is a text generation model.

[0084] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 4As shown, the electronic device may include a processor 410, a memory 420, a communication interface 430, and a communication bus 440. The processor 410, memory 420, and communication interface 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 420 to execute a model inference method. This method includes: determining the quantization precision of the weight data of each expert module based on the weight data distribution of each expert module in the model; determining the chip architecture type corresponding to each expert module based on the quantization precision of each weight data; and determining the chip architecture corresponding to each expert module based on the chip architecture type, so as to perform model inference on the chip architecture corresponding to each expert module.

[0085] Furthermore, the logical instructions in the aforementioned memory 420 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0086] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the model inference method provided by the above methods, the method comprising: determining the quantization precision of the weight data of each expert module based on the weight data distribution of each expert module in the model; determining the chip architecture type corresponding to each expert module based on the quantization precision of each weight data; and determining the chip architecture corresponding to each expert module based on the chip architecture type corresponding to each expert module, so as to perform model inference on the chip architecture corresponding to each expert module.

[0087] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform the aforementioned model inference methods. The method includes: determining the quantization precision of the weight data of each expert module based on the weight data distribution of each expert module in the model; determining the chip architecture type corresponding to each expert module based on the quantization precision of each weight data; and determining the chip architecture corresponding to each expert module based on the chip architecture type corresponding to each expert module, so as to perform model inference on the chip architecture corresponding to each expert module.

[0088] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0089] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A model reasoning method, characterized in that, include: Based on the weight data distribution of each expert module in the model, the quantization accuracy of the weight data of each expert module is determined. Based on the quantization accuracy of each weight data, the chip architecture type corresponding to each expert module is determined. Based on the chip architecture type corresponding to each expert module, the chip architecture corresponding to each expert module is determined so that model inference can be performed on the chip architecture corresponding to each expert module.

2. The model reasoning method according to claim 1, characterized in that, The weight data distribution of each expert module is determined based on the range of variation between the maximum and minimum element values ​​in the weight data of each expert module, as well as the differences between the element values ​​in the weight data of each expert module.

3. The model reasoning method according to claim 2, characterized in that, The determination of the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module in the model includes: If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module exceeds a preset range, and the difference between the element values ​​in the weight data of any expert module is greater than a preset value, then the first quantization precision shall be used as the quantization precision of the weight data of any expert module. If the range of variation between the maximum and minimum element values ​​in the weight data of any expert module is within the preset range, and the difference between each element value in the weight data of any expert module is less than or equal to the preset value, then the second quantization precision shall be used as the quantization precision of the weight data of any expert module. The first quantization precision is higher than the second quantization precision.

4. The model reasoning method according to any one of claims 1 to 3, characterized in that, The process of determining the quantization accuracy of the weight data for each expert module based on the weight data distribution of each expert module in the model further includes: Based on the quantization precision of each weight data, each weight data is quantized.

5. The model reasoning method according to any one of claims 1 to 3, characterized in that, The process of determining the chip architecture corresponding to each expert module based on the chip architecture type of each expert module further includes: Each weight data is assigned to the chip architecture of the corresponding expert module to perform model inference calculations on the corresponding chip architecture.

6. The model reasoning method according to any one of claims 1 to 3, characterized in that, The model described is a text generation model.

7. A model reasoning device, characterized in that, include: The accuracy determination unit is used to determine the quantization accuracy of the weight data of each expert module based on the weight data distribution of each expert module in the model. An architecture determination unit is used to determine the chip architecture type corresponding to each expert module based on the quantization accuracy of each weight data. The model inference unit is used to determine the chip architecture corresponding to each expert module based on the chip architecture type corresponding to each expert module, so as to perform model inference on the chip architecture corresponding to each expert module.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the model reasoning method as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the model reasoning method as described in any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the model reasoning method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Model quantification method and device, electronic equipment and storage medium

    CN114970883A

  • Hybrid expert network optimization method based on partial quantification

    CN115730646A