Method and device for optimizing reasoning resources and electronic equipment
By using the ILP solver in the neural network model for hardware resource optimization modeling and adaptive scheduling, the problem of low hardware resource utilization is solved and the effects of hardware cost minimization and performance balance are achieved.
Patent Information
- Application Number
- CN202410942759.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-07-15
AI Technical Summary
Neural network models have low hardware resource utilization in online service inference, resulting in excessive hardware and operating costs.
By obtaining the inference service response performance data and hardware cost data of the neural network model under different hardware resources, use an integer linear programming (ILP) solver for optimization modeling, generate a hardware resource deployment plan with the smallest hardware cost, and perform adaptive scheduling. Optimization to ensure performance requirements are met while reducing hardware costs.
It improves the utilization of hardware resources, reduces hardware deployment and operating costs, avoids over-configuration or waste of resources, and achieves hardware cost minimization and performance balance.
Smart Images

Figure CN118796471A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of large model reasoning, and more specifically, to a reasoning resource optimization method, device and electronic device. Background Art
[0002] At present, neural network models are often used for online service reasoning. For example, products such as search engines, chatbots, and virtual assistants often use large language model families or multimodal models as the underlying neural network models for reasoning. In actual practice, it is found that the utilization rate of hardware resources used by these neural network models is low. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a method, device and electronic device for optimizing inference resources, so as to improve the problem of low utilization rate of hardware resources used by the model.
[0004] The embodiment of the present application provides a method for optimizing inference resources, including: obtaining inference service response performance data of a neural network model under different hardware resources, and hardware cost data under different hardware resources; optimizing and modeling the inference service response performance data and hardware cost data to obtain a hardware resource deployment plan with the lowest hardware cost; generating a configuration file of the neural network model according to the hardware resource deployment plan with the lowest hardware cost; and adaptively scheduling and optimizing the neural network model and different hardware resources according to the configuration file. In the implementation process of the above scheme, by optimizing and modeling the inference service response performance data and hardware cost data, and according to the configuration file generated by the hardware resource deployment plan with the lowest hardware cost, the neural network model and different hardware resources are adaptively scheduled and optimized, thereby effectively improving the utilization rate of hardware resources.
[0005] Optionally, in an embodiment of the present application, different hardware resources include: multiple computing resources and multi-level storage resources; optimizing modeling of reasoning service response performance data and hardware cost data, including: constructing an integer linear programming ILP solver through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources and hardware cost data of multi-level storage resources; using the ILP solver to optimize modeling of reasoning service response performance data and hardware cost data. In the implementation process of the above scheme, by using the ILP solver to perform linear programming optimization modeling on the reasoning service response performance data and hardware cost data, the large model or large language model effectively converts its low hardware cost reasoning demand problem into an optimization modeling problem under different hardware resource constraints under specific reasoning service response performance requirements, and can accurately balance the relationship between reasoning performance and hardware cost, ensuring that while meeting specific service response time, throughput and other performance requirements, the hardware deployment and operation costs are minimized, and the most cost-effective hardware resource configuration scheme can be automatically selected to avoid excessive configuration or waste of resources.
[0006] Optionally, in an embodiment of the present application, the ILP solver includes: an objective function; constructing an integer linear programming ILP solver through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources, and hardware cost data of multi-level storage resources, including: determining the objective function through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources, and hardware cost data of multi-level storage resources Where n_acc represents the total number of types of computing resources, Acc i Indicates the number of computing power of the i-th computing power resource among multiple computing power resources, cost_acc i represents the hardware cost data of the i-th computing resource among multiple computing resources, n_mem represents the total number of types of the multi-level storage resources, mem j Indicates the storage size of the i-th level storage resource in the multi-level storage resource, cost_mem j Represents the hardware cost data of the i-th level storage resource in the multi-level storage resources. In the implementation process of the above solution, since computing power resources, storage resources and reasoning service request response performance data (such as parameters of different types of service requests) are closely related to the hardware cost of large model reasoning services, setting the above objective function of minimizing the hardware cost of the neural network model can effectively convert the low hardware cost reasoning demand problem into an optimization modeling problem under different hardware resource constraints. Specifically, the low hardware cost hardware resource deployment problem is converted into an integer linear programming problem, so that the most cost-effective hardware resource configuration solution can be automatically selected to avoid excessive configuration or waste of resources.
[0007] Optionally, in the embodiment of the present application, the ILP solver further includes: a constraint condition of computing power resources; constructing an integer linear programming ILP solver by using multiple computing power resources, hardware cost data of multiple computing power resources, multi-level storage resources and hardware cost data of multi-level storage resources, and further includes: Calculate various computing resources to obtain the constraints of computing resources; Acc_comp i Indicates the amount of computation required for the i-th computing resource among multiple computing resources, Acc_flops i represents the maximum computing power of the i-th computing resource among multiple computing resources, T communication Indicates the data communication duration between any two computing resources among multiple computing resources, and Latency_demand indicates the maximum latency of the inference server of the neural network model. In the implementation process of the above solution, by converting the constraints of multiple computing resources into mathematical models, the ILP solver can find the global optimal solution under given conditions, ensuring that the resource allocation solution minimizes the hardware cost while satisfying all constraints, and further directly incorporates the hardware cost of computing resources into the optimization target. This solution can automatically find the resource configuration solution with the lowest hardware cost while meeting performance (such as low latency requirements).
[0008] Optionally, in the embodiment of the present application, the ILP solver further includes: storage resource constraints; constructing an integer linear programming ILP solver by using multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources, and hardware cost data of multi-level storage resources, and further includes: acc +Act acc +KV acc <acc memory and w mem +Act mem +KV mem <mem memory Calculate the multi-level storage resources to obtain the constraints of storage resources; where w acc represents the data size of the weight parameters of the neural network model in the accelerator memory in the multi-level storage resource, w mem Indicates the data size of the weight parameters of the neural network model in the server memory in the multi-level storage resource, Act acc Act represents the data size of the activation value of the neural network model in the accelerator memory in the multi-level storage resource. mem Indicates the data size of the activation value of the neural network model in the server memory in the multi-level storage resource, KV acc Indicates the data size of the KV cache of the neural network model in the accelerator memory in the multi-level storage resource, KVmem Indicates the data size of the KV cache of the neural network model in the server memory in the multi-level storage resource, avv memory Indicates the total memory size of the accelerator memory in the multi-level storage resources, mem memory Represents the total memory size of the server memory in the multi-level storage resources. In the implementation of the above solution, through strict memory resource constraints, the solution ensures that the model weights, activation values, and KV cache can be properly distributed between the accelerator memory and the server memory, avoiding the overload of a single storage level and improving the overall memory resource utilization efficiency.
[0009] Optionally, in an embodiment of the present application, the neural network model and different hardware resources are adaptively scheduled and optimized according to the configuration file, including: determining whether the activity value of the model parameters of the neural network model is greater than the preset threshold in the configuration file; if so, the model parameters of the neural network model are moved to the accelerator memory in the multi-level storage resource, otherwise, the model parameters of the neural network model are moved to the server memory in the multi-level storage resource; wherein the model parameters include: weight parameters and / or KV cache. In the implementation process of the above scheme, the model parameters (weights and KV cache) with high activity are moved to the accelerator memory, which can reduce the access delay of the data, because the accelerator memory is usually closer to the computing unit than the server memory, thereby greatly improving the reading and writing speed of the data, so that frequently accessed data can be quickly processed, and the reasoning response speed and throughput are improved. Further, by distinguishing the activity level and reasonably allocating storage resources, the low-activity parameters are placed in the low-cost server memory, while the high-activity parameters occupy the high-cost accelerator memory, which can ensure the rapid access of key data and avoid the waste of expensive resources, and achieve a balance between storage cost and performance.
[0010] The embodiment of the present application also provides an inference resource optimization device, including: a resource data acquisition module, used to obtain the inference service response performance data of the neural network model under different hardware resources, and the hardware cost data under different hardware resources; a deployment plan acquisition module, used to optimize the modeling of the inference service response performance data and the hardware cost data, and obtain the hardware resource deployment plan with the minimum hardware cost; a configuration file generation module, used to generate a configuration file of the neural network model according to the hardware resource deployment plan with the minimum hardware cost; a resource scheduling optimization module, used to adaptively schedule and optimize the neural network model and different hardware resources according to the configuration file.
[0011] Optionally, in an embodiment of the present application, different hardware resources include: multiple computing power resources and multi-level storage resources; the deployment plan acquisition module includes: an ILP solver construction sub-module, used to construct an integer linear programming ILP solver through multiple computing power resources, hardware cost data of multiple computing power resources, multi-level storage resources and hardware cost data of multi-level storage resources; a data optimization modeling sub-module, used to use the ILP solver to optimize and model the inference service response performance data and hardware cost data.
[0012] Optionally, in an embodiment of the present application, the ILP solver includes: an objective function; an ILP solver construction submodule includes: an objective function determination unit for determining the objective function through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources, and hardware cost data of multi-level storage resources; Where n_acc represents the total number of types of computing resources, Acc i Indicates the number of computing power of the i-th computing power resource among multiple computing power resources, cost_acc i represents the hardware cost data of the i-th computing resource among multiple computing resources, n_mem represents the total number of types of the multi-level storage resources, mem j Indicates the storage size of the i-th level storage resource in the multi-level storage resource, cost_mem j Represents hardware cost data of the i-th level storage resource in the multi-level storage resources.
[0013] Optionally, in the embodiment of the present application, the ILP solver further includes: a constraint condition of computing power resources; an ILP solver construction submodule includes: a computing power constraint obtaining unit for obtaining the computing power constraint through the formula Calculate various computing resources to obtain the constraints of computing resources; Acc_comp i Indicates the amount of computation required for the i-th computing resource among multiple computing resources, Acc_flops i represents the maximum computing power of the i-th computing resource among multiple computing resources, T communication It indicates the data communication duration between any two computing resources among multiple computing resources. Latency_demand indicates the maximum latency of the inference server of the neural network model.
[0014] Optionally, in the embodiment of the present application, the ILP solver further includes: a storage resource constraint; an ILP solver construction submodule including: a storage constraint obtaining unit for obtaining the storage resource constraint through the formula w acc +Act acc +KV acc <acc memory and w mem +Actmem +KV mem <mem memory Calculate the multi-level storage resources to obtain the constraints of storage resources; where w acc represents the data size of the weight parameters of the neural network model in the accelerator memory in the multi-level storage resource, w mem Indicates the data size of the weight parameters of the neural network model in the server memory in the multi-level storage resource, Act acc Act represents the data size of the activation value of the neural network model in the accelerator memory in the multi-level storage resource. mem Indicates the data size of the activation value of the neural network model in the server memory in the multi-level storage resource, KV acc Indicates the data size of the KV cache of the neural network model in the accelerator memory in the multi-level storage resource, KV mem Indicates the data size of the KV cache of the neural network model in the server memory in the multi-level storage resource, acc memory Indicates the total memory size of the accelerator memory in the multi-level storage resources, mem memory Indicates the total memory size of the server memory in the multi-level storage resource.
[0015] Optionally, in an embodiment of the present application, the resource scheduling optimization module includes: an activity value judgment submodule, used to judge whether the activity value of the model parameters of the neural network model is greater than a preset threshold in the configuration file; a model parameter movement submodule, used to move the model parameters of the neural network model to the accelerator memory in the multi-level storage resources if the activity value of the model parameters of the neural network model is greater than the preset threshold in the configuration file; otherwise, the model parameters of the neural network model are moved to the server memory in the multi-level storage resources; wherein the model parameters include: weight parameters and / or KV cache.
[0016] An embodiment of the present application further provides an electronic device, including: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the machine-readable instructions execute the method described above when executed by the processor.
[0017] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described above is executed.
[0018] The embodiment of the present application also provides a computer program product, including: a computer program or a computer instruction, and the computer program or the computer instruction executes the method described above when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A flow chart of a method for optimizing inference resources provided by an embodiment of the present application is shown;
[0021] Figure 2 A schematic diagram of the search space of an integer linear programming ILP solver provided in an embodiment of the present application is shown;
[0022] Figure 3 A schematic diagram of a process of adaptive scheduling optimization provided by an embodiment of the present application is shown;
[0023] Figure 4 A schematic diagram of a flow chart of a device for optimizing inference resources provided in an embodiment of the present application is shown;
[0024] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0025] To make the purpose, technical scheme and advantages of the embodiment of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. It should be understood that the drawings in the embodiment of the present application only serve the purpose of explanation and description, and are not used to limit the protection scope of the embodiment of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in the embodiment of the present application shows the operation implemented according to some embodiments of the embodiment of the present application. It should be understood that the operation of the flowchart can be implemented out of order, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the embodiment of the present application, or remove one or more operations from the flowchart.
[0026] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all embodiments. The components of the embodiments of the present application described and shown in the drawings generally here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the embodiments of the present application claimed, but merely represents the selected embodiments of the embodiments of the present application.
[0027] It is understandable that the "first" and "second" in the embodiments of the present application are used to distinguish similar objects. Those skilled in the art will understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit the difference. In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that there may be three relationships, such as A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the related objects before and after are in an "or" relationship. The term "multiple" refers to more than two (including two), and similarly, "multiple groups" refers to more than two groups (including two groups).
[0028] Before introducing the reasoning resource optimization method provided in the embodiment of the present application, some concepts involved in the embodiment of the present application are first introduced:
[0029] Linear Programming (LP) is an important branch of operations research that has been studied early, developed rapidly, is widely used, and has relatively mature methods. It is a method to assist people in scientific management.
[0030] Integer Linear Programming (ILP) refers to integer linear programming in which decision variables must take integer values, that is, linear programming problems that require some or all decision variables to take integer values; among them, integer linear programming includes pure integer linear programming, mixed integer linear programming and 0-1 type integer linear programming.
[0031] It should be noted that the inference resource optimization method provided in the embodiment of the present application can be executed by an electronic device, where the electronic device refers to a device terminal or server with the function of executing a computer program, such as a smart phone, a personal computer, a tablet computer, a personal digital assistant, or a mobile Internet device. A server refers to a device that provides computing services through a network, such as an x86 server and a non-x86 server, and non-x86 servers include mainframes, minicomputers, and UNIX servers.
[0032] The following is an example of an application scenario to which the inference resource optimization method is applicable: In application scenarios such as search engines, chatbots, and virtual assistants, these application scenarios usually use large models, large language models, or multimodal models with transformer structures as base models to achieve interaction with user terminals. In these application scenarios, most of them face diverse user needs, such as the diversity of single requests and high concurrency requirements. These diverse needs usually require large-scale clustered deployment of base models with expensive computing power costs (such as hardware accelerators) and storage costs. These computing power costs and storage costs bring a heavy operational burden to enterprise operations. In this case, the inference resource optimization method can be used to optimize the different hardware resources used for the deployment of large models, large language models, or multimodal models to improve the utilization efficiency of these hardware resources, thereby reducing the use cost and operating cost of hardware resources.
[0033] See also Figure 1 The flowchart of the inference resource optimization method provided by the embodiment of the present application is shown; the embodiment of the present application provides a inference resource optimization method, including:
[0034] Step S110: Obtain the inference service response performance data of the neural network model under different hardware resources, and the hardware cost data under different hardware resources.
[0035] The above-mentioned neural network model can be a large model, a large language model or a multimodal model using a transformer structure, such as: a Llama model, an open pre-trained Transformer (Open Pre-trained Transformer, OPT) model or a general language model (Generative Language Model, GLM), etc. These large models, large language models or multimodal models can be network models whose model parameter quantity reaches a preset value or more, and the preset value here can be 2B or 6B, etc.
[0036] Step S120: Optimize and model the inference service response performance data and the hardware cost data to obtain a hardware resource deployment solution with the lowest hardware cost.
[0037] The above-mentioned inference service response performance data is the performance data of different neural network model inference service request response under different hardware resources. The inference service response performance data includes: inference delay and throughput performance indicator data under different computing power resources, different multi-level storage resources and different model inference service requirements. It can be understood that the inference service corresponding to the inference service response performance data may include different inference requirement parameters. Different inference requirement parameters may include: inference service request frequency, inference requirement service frequency, input text length and output text length of a single request, etc. In the specific practice process, these different inference requirement parameters can be represented by integers, thereby effectively reducing the search space of optimization modeling and improving the efficiency of obtaining the hardware resource deployment solution with the lowest hardware cost.
[0038] The above-mentioned hardware resource deployment scheme with the lowest hardware cost refers to the deployment scheme with the lowest hardware cost for reasoning calculations of neural network models under these different hardware resources. These deployment schemes can improve the problem of high reasoning cost of large models or large language models after deployment.
[0039] It is understandable that since linear programming, nonlinear programming, integer programming and combinatorial optimization are all optimization modeling methods in optimization theory, in the specific practice process, linear programming, nonlinear programming, integer programming or combinatorial optimization and other operations research modeling can be performed on the inference service response performance data and hardware cost data to obtain the hardware resource deployment plan with the lowest hardware cost. Considering that linear programming is a basic and important part of optimization theory, and integer linear programming is more suitable for the application scenario of inference resource optimization, the following focuses on the modeling method of integer linear programming.
[0040] Step S130: Generate a configuration file of the neural network model according to the hardware resource deployment solution with the lowest hardware cost.
[0041] It is understandable that the electronic device can count multiple hardware resource deployment schemes with total hardware costs consumed to meet the client's delay requirements, and filter out the hardware resource deployment scheme with the lowest hardware cost from the multiple hardware resource deployment schemes with total hardware costs, and then generate a configuration file for the neural network model based on the hardware resource deployment scheme with the lowest hardware cost.
[0042] Step S140: Adaptively schedule and optimize the neural network model and different hardware resources according to the configuration file.
[0043] In the implementation process of the above solution, by optimizing the modeling of the inference service response performance data and hardware cost data, and generating a configuration file based on the hardware resource deployment solution with the lowest hardware cost, the neural network model and different hardware resources are adaptively scheduled and optimized, thereby effectively improving the utilization of hardware resources.
[0044] As an optional implementation of the above step S120, the above different hardware resources may include: multiple computing resources and multi-level storage resources; the above implementation of optimizing modeling of the inference service response performance data and hardware cost data may include:
[0045] Step S121: construct an integer linear programming ILP solver through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources and hardware cost data of multi-level storage resources.
[0046] The above-mentioned multiple computing resources can be heterogeneous computing resources. Here, heterogeneous computing resources refer to a set of computing resources composed of computing units with different architectures, designs, and performance characteristics. For example, they can be different types of central processing units (CPU), field programmable gate arrays (FPGA), L4, A10G, and different types of graphics processing units (GPU). The different types of GPUs here include A100, H100, BI100, and MR100, etc. The GPU here can also be a domestic GPU.
[0047] The above-mentioned multi-level storage resources may include, for example, accelerator video memory, where the accelerator memory is, for example, high bandwidth memory (HBM), and the above-mentioned multi-level storage resources may also include server memory, where the server memory is, for example, dynamic random access memory (DRAM) or server hard disk, and the above-mentioned multi-level storage resources may also include server storage hard disk. In the specific practice, the storage resources may be calculated in units of 2GB, and storage resources less than 2GB may be calculated as 2GB, so that the multi-level storage resources are characterized in integer form.
[0048] Step S122: Use the ILP solver to perform linear programming optimization modeling on the inference service response performance data and the hardware cost data to obtain a hardware resource deployment solution with the minimum hardware cost.
[0049] It can be understood that the purpose of constructing the integer linear programming ILP solver above is to minimize the cost of large-model reasoning services while meeting the model reasoning performance requirements. Therefore, the ILP solver can be used to perform linear programming optimization modeling on the reasoning service response performance data and hardware cost data to obtain a hardware resource deployment plan with the lowest hardware cost.
[0050] In the implementation process of the above solution, by using the ILP solver to perform linear programming optimization modeling on the inference service response performance data and hardware cost data, the large model or large language model can effectively convert its low hardware cost inference demand problem into an optimization modeling problem under different hardware resource constraints under specific inference service response performance requirements. It can accurately balance the relationship between inference performance and hardware cost, ensure that while meeting specific service response time, throughput and other performance requirements, the hardware deployment and operation costs are minimized, and can automatically select the most cost-effective hardware resource configuration plan to avoid excessive configuration or waste of resources.
[0051] As an optional implementation of the above step S121, the above ILP solver may include: an objective function; the above implementation of constructing an integer linear programming ILP solver may include:
[0052] Step S121a: Determine the objective function through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources and hardware cost data of multi-level storage resources The purpose of this objective function is to set the minimum inference service cost of a neural network model (such as a large model, a large language model, or a multimodal model, etc.) under different hardware resources. The inference service cost here can be the sum of the hardware cost data of multiple computing resources and the hardware cost data of multiple levels of storage resources.
[0053] Where n_acc represents the total number of types of computing resources, Acc i Indicates the number of computing power of the i-th computing power resource among multiple computing power resources, cost_acc i represents the hardware cost data of the i-th computing resource among multiple computing resources, n_mem represents the total number of types of the multi-level storage resources, mem j Indicates the storage size of the i-th level storage resource in the multi-level storage resource, cost_mem j Indicates the hardware cost data of the i-th level storage resource in the multi-level storage resource. It can be understood that the above storage resource mem j It represents a continuous function. In the specific practice, it can be discretized (such as histogram) for sampling analysis to form the objective function of integer linear programming.
[0054] See also Figure 2 A schematic diagram of the search space of the integer linear programming ILP solver provided in an embodiment of the present application is shown; it can be understood that the above-mentioned setting of the objective function of minimizing the hardware cost of the neural network model can effectively convert the low hardware cost reasoning requirement problem into an optimization modeling problem under different hardware resource constraints, specifically, the low hardware cost hardware resource deployment problem is converted into an integer linear programming problem, so that the search space of the integer linear programming ILP solver includes different types of computing resource parameters and multi-level storage resource parameters for large model deployment, large model reasoning service request frequency, and large model request service parameters (such as the input text length and output text length of a single request).
[0055] In the implementation process of the above solution, since computing power resources, storage resources and inference service request response performance data (such as parameters of different types of service requests) are closely related to the hardware cost of large model inference services, setting the above objective function of minimizing the hardware cost of the neural network model can effectively convert the low hardware cost inference demand problem into an optimization modeling problem under different hardware resource constraints. Specifically, the low hardware cost hardware resource deployment problem is converted into an integer linear programming problem, so that the most cost-effective hardware resource configuration solution can be automatically selected to avoid excessive configuration or waste of resources.
[0056] As an optional implementation of the above step S121, the above ILP solver may further include: a constraint condition of computing power resources; constructing an integer linear programming ILP solver through multiple computing power resources, hardware cost data of multiple computing power resources, multi-level storage resources and hardware cost data of multi-level storage resources. The implementation method may also include:
[0057] Step S121b: Pass Calculate various computing resources to obtain the constraints of computing resources;
[0058] Among them, Acc_comp i Indicates the amount of computation required for the i-th computing resource among multiple computing resources, Acc_flops i represents the maximum computing power of the i-th computing resource among multiple computing resources, T communication It indicates the data communication duration between any two computing resources among multiple computing resources. Latency_demand indicates the maximum delay duration of the inference server of the neural network model. The maximum delay duration of the inference server here can be set according to the specific situation. For example, the maximum delay duration of the inference server is set to 50 milliseconds (ms).
[0059] It is understandable that the constraints of the above computing power resources can be obtained by offline analysis and calculation by an offline analysis module in an electronic device. The offline analysis here can include: weight parameter analysis of a neural network model (such as a large model, a large language model, or a multimodal model), and analysis and calculation of different hardware cost requirements and different reasoning service response performance requirements. In other words, the constraints of such computing power resources are the constraints of an integer linear programming problem formed by analyzing a neural network model (such as a large model, a large language model, or a multimodal model) under different hardware cost requirements and different reasoning service response performance requirements.
[0060] As an optional implementation of the above step S121, the above ILP solver may further include: storage resource constraints; constructing an integer linear programming ILP solver through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources, and hardware cost data of multi-level storage resources. The implementation of the ILP solver may also include:
[0061] Step S121c: By formula w acc +Act acc +KV acc <acc memory and w mem +Act mem +KV mem <mem memory Calculate multi-level storage resources to obtain storage resource constraints;
[0062] Among them, w acc represents the data size of the weight parameters of the neural network model in the accelerator memory in the multi-level storage resource, w mem Indicates the data size of the weight parameters of the neural network model in the server memory in the multi-level storage resource, Act acc Act represents the data size of the activation value of the neural network model in the accelerator memory in the multi-level storage resource. mem Indicates the data size of the activation value of the neural network model in the server memory in the multi-level storage resource, KV acc Indicates the data size of the KV cache of the neural network model in the accelerator memory in the multi-level storage resource, KV mem Indicates the data size of the KV cache of the neural network model in the server memory in the multi-level storage resource, acc memory Indicates the total memory size of the accelerator memory in the multi-level storage resources, mem memory Indicates the total memory size of the server memory in the multi-level storage resource.
[0063] Optionally, the above-mentioned ILP solver may include more constraints in addition to the constraints of computing resources and storage resources. For example, the storage resources at each level need to be greater than the peak storage demand and network throughput of the model inference, and the delay time of large model inference needs to be less than the minimum delay time required by the user service.
[0064] As an optional implementation of the above step S122, the above implementation of adaptively scheduling and optimizing the neural network model and different hardware resources according to the configuration file may include:
[0065] Step S122a: Determine whether the activity value of the model parameter of the neural network model is greater than a preset threshold in the configuration file.
[0066] It can be understood that the activity value of the model parameters of the above-mentioned neural network model can be obtained by statistical analysis of the model parameters of the neural network model. For example, if the model parameters (including weight parameters and / or KV cache) of a neural network model such as a large model, a large language model or a multimodal model are called once during an inference service request, the activity value of the model parameter is increased by 1, and the inference service request is completed, the activity value of the model parameter is statistically calculated.
[0067] The implementation method of the above step S122a is, for example: by using the activity calculation formula To calculate the activity value of the model parameters of the neural network model, and then, through the executable program to determine whether the activity value of the model parameters of the neural network model is greater than the preset threshold in the configuration file. Among them, the above-mentioned activity value can be calculated in the offline statistical analysis stage, tokens_total represents the total number of tokens in the reasoning process, and tokens_activated represents the number of tokens activated in the nodes of the neural network model during the reasoning process. Optionally, in the specific practice process, the above-mentioned neural network model can be a model using a transformer structure, which usually includes an attention block. In this case, since the cumulative attention scores of all tokens in the attention block follow a power law distribution, the KV cache value of the token with the highest attention score in the attention block (for example, the top 20% of the token) can be directly used as a high-activity KV cache, or the KV cache value of the token with the attention score of the token in the attention block greater than the preset score can be directly used as a high-activity KV cache.
[0068] Step S122b: If the activity value of the model parameter of the neural network model is greater than the preset threshold in the configuration file, the model parameter of the neural network model is moved to the accelerator memory in the multi-level storage resource.
[0069] The implementation method of the above-mentioned step S122b includes: if the activity value of the model parameter of the neural network model is greater than the preset threshold in the configuration file, it means that the activity value of the model parameter is relatively high, then the model parameters of the active part can be placed in the accelerator memory, or the model parameters of the neural network model can be moved to the accelerator memory in the multi-level storage resources, for example, this part of the high-activity parameters can be moved to the high-bandwidth memory (HBM) with fast reading speed.
[0070] Step S122c: If the activity value of the model parameter of the neural network model is less than or equal to the preset threshold in the configuration file, the model parameter of the neural network model is moved to the server memory in the multi-level storage resource.
[0071] The implementation method of the above step S122b is, for example: model parameters of different activities can be placed in different types of storage resources. If the activity value of the model parameter of the neural network model is less than or equal to the preset threshold in the configuration file, it means that the activity value of the model parameter is low, then the model parameters of the inactive part can be placed in the server memory, and the model parameters of the neural network model can be moved to the server memory in the multi-level storage resources, for example, the model parameters of the inactive part can be moved to the dynamic random access memory (DRAM) or the server hard disk with a slower reading speed. The above model parameters may include: weight parameters and / or KV cache.
[0072] In the implementation process of the above solution, the storage layout is dynamically adjusted according to the actual activity of the model during runtime, so that the system can automatically adjust under different workloads, improving the adaptability to different application scenarios, especially in the model reasoning stage, and can flexibly optimize resource allocation according to real-time needs.
[0073] As an optional implementation of the above step S130, for example: after obtaining the hardware resource deployment scheme with the lowest hardware cost, a configuration file of the neural network model can be generated according to the hardware resource deployment scheme with the lowest hardware cost. It can be understood that since the configuration file is generated according to the hardware resource deployment scheme with the lowest hardware cost, the content in the configuration file can be the information of the hardware resources to be deployed, for example: the configuration file can include model weight parameters and KV cache storage and proportion configuration information in multi-level storage resources, configuration information of various computing resources required for large model neuron calculations, etc.
[0074] See also Figure 3A schematic diagram of the process of adaptive scheduling optimization provided by an embodiment of the present application is shown; as an optional implementation of the above step S140, for example: based on reasoning demand parameters such as large model inference service request frequency, inference demand service frequency, single request input text length and output text length, the pending requests of each neural network model are dynamically allocated to different hardware resources selected in the configuration file in real time to complete the adaptive scheduling optimization of the neural network model and different hardware resources. For example, the electronic device can select suitable computing power resources from a variety of heterogeneous computing power resources according to the configuration file, and select suitable accelerator video memory and server memory from multi-level storage resources. The above-mentioned adaptive scheduling optimization process can be completed by the real-time scheduling deployment module of the electronic device, and the real-time scheduling deployment module can realize the adaptive scheduling optimization allocation function of the pending requests by executing the above reasoning resource optimization method.
[0075] Optionally, the above-mentioned electronic device can be a cluster control node for multiple computing resources and / or multi-level storage resources. That is to say, the above-mentioned multiple computing resources and / or multi-level storage resources can be operated in a high-availability distributed cluster manner, and the cluster control node can monitor and control the cluster node status of the multiple computing resources and / or multi-level storage resources in real time, so as to facilitate adaptive scheduling and optimization of the high-availability distributed cluster built with multiple computing resources and / or multi-level storage resources.
[0076] As an optional implementation of the above-mentioned reasoning resource optimization method, an exception handling mechanism module may also be provided in the above-mentioned electronic device. The exception handling mechanism module may identify the exception and perform exception handling when an abnormality occurs during the execution process of the above-mentioned reasoning optimization method. For example, in the event of a GPU failure or a degradation in storage device performance, the pending requests of each neural network model may be dynamically allocated to different hardware resources selected in the configuration file, or the hardware resources with abnormalities (including computing resources and storage resources) may be quickly identified, and the pending requests may be reallocated to healthy hardware resources.
[0077] See also Figure 4 The flowchart of the inference resource optimization device provided in the embodiment of the present application is shown; the embodiment of the present application provides an inference resource optimization device 200, including:
[0078] The resource data acquisition module 210 is used to obtain the inference service response performance data of the neural network model under different hardware resources, and the hardware cost data under different hardware resources.
[0079] The deployment plan acquisition module 220 is used to optimize the modeling of the inference service response performance data and the hardware cost data to obtain a hardware resource deployment plan with the minimum hardware cost.
[0080] The configuration file generation module 230 is used to generate a configuration file of the neural network model according to a hardware resource deployment solution with the lowest hardware cost.
[0081] The resource scheduling optimization module 240 is used to perform adaptive scheduling optimization on the neural network model and different hardware resources according to the configuration file.
[0082] As an optional implementation of the above device, different hardware resources include: multiple computing resources and multi-level storage resources; the deployment scheme acquisition module includes:
[0083] The ILP solver construction submodule is used to construct an integer linear programming ILP solver through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources and hardware cost data of multi-level storage resources.
[0084] The data optimization modeling submodule is used to optimize the modeling of the inference service response performance data and hardware cost data using the ILP solver.
[0085] As an optional implementation of the above-mentioned device, an ILP solver includes: an objective function; constructing an integer linear programming ILP solver through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources and hardware cost data of multi-level storage resources, including:
[0086] Determine the objective function through multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources and hardware cost data of multi-level storage resources
[0087] Where n_acc represents the total number of types of computing resources, Acc i Indicates the number of computing power of the i-th computing power resource among multiple computing power resources, cost_acc i represents the hardware cost data of the i-th computing resource among multiple computing resources, n_mem represents the total number of types of the multi-level storage resources, mem j Indicates the storage size of the i-th level storage resource in the multi-level storage resource, cost_mem j Represents hardware cost data of the i-th level storage resource in the multi-level storage resources.
[0088] As an optional implementation of the above device, the ILP solver further includes: a constraint condition of computing power resources; constructing an integer linear programming ILP solver by using multiple computing power resources, hardware cost data of multiple computing power resources, multi-level storage resources and hardware cost data of multi-level storage resources, and further includes:
[0089] By formula Calculate various computing resources to obtain the constraints of computing resources;
[0090] Among them, Acc_comp i Indicates the amount of computation required for the i-th computing resource among multiple computing resources, Acc_flops i represents the maximum computing power of the i-th computing resource among multiple computing resources, T communication It indicates the data communication duration between any two computing resources among multiple computing resources. Latency_demand indicates the maximum latency of the inference server of the neural network model.
[0091] As an optional implementation of the above device, the ILP solver further includes: a constraint condition of storage resources; constructing an integer linear programming ILP solver by using multiple computing resources, hardware cost data of multiple computing resources, multi-level storage resources and hardware cost data of multi-level storage resources, and further includes:
[0092] Through the formula w acc +Act acc +KV acc <acc memory and w mem +Act mem +KV mem <mem memory Calculate multi-level storage resources to obtain storage resource constraints;
[0093] Among them, w acc represents the data size of the weight parameters of the neural network model in the accelerator memory in the multi-level storage resource, w mem Indicates the data size of the weight parameters of the neural network model in the server memory in the multi-level storage resource, Act acc Act represents the data size of the activation value of the neural network model in the accelerator memory in the multi-level storage resource. mem Indicates the data size of the activation value of the neural network model in the server memory in the multi-level storage resource, KV acc Indicates the data size of the KV cache of the neural network model in the accelerator memory in the multi-level storage resource, KV mem Indicates the data size of the KV cache of the neural network model in the server memory in the multi-level storage resource, acc memory Indicates the total memory size of the accelerator memory in the multi-level storage resources, mem memory Indicates the total memory size of the server memory in the multi-level storage resource.
[0094] As an optional implementation of the above device, the resource scheduling optimization module includes:
[0095] The activity value judgment submodule is used to judge whether the activity value of the model parameter of the neural network model is greater than a preset threshold in the configuration file.
[0096] The model parameter moving submodule is used to move the model parameters of the neural network model to the accelerator memory in the multi-level storage resources if the activity value of the model parameters of the neural network model is greater than the preset threshold in the configuration file; otherwise, the model parameters of the neural network model are moved to the server memory in the multi-level storage resources; wherein the model parameters include: weight parameters and / or KV cache.
[0097] It should be understood that the device corresponds to the above-mentioned inference resource optimization method embodiment and can execute the various steps involved in the above-mentioned method embodiment. The specific functions of the device can be found in the above description, and the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the operating system (OS) of the device.
[0098] See also Figure 5 The electronic device 300 provided in the embodiment of the present application includes: a processor 310 and a memory 320, wherein the memory 320 stores machine-readable instructions executable by the processor 310, and when the machine-readable instructions are executed by the processor 310, the above method is executed.
[0099] The embodiment of the present application also provides a computer-readable storage medium 330, on which a computer program is stored, and the computer program is executed by the processor 310 to execute the above method. The computer-readable storage medium 330 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, disk or optical disk.
[0100] The embodiment of the present application also provides a computer program product, including: a computer program or a computer instruction, and the computer program or the computer instruction executes the method described above when executed by a processor.
[0101] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0102] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed device and method can also be implemented in other ways. The device embodiments described above are only schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible implementation architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a part of a module, a program segment or a code, and a part of a module, a program segment or a code includes one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also be different from the order of occurrence marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which is mainly determined by the functions involved.
[0103] In addition, each functional module of each embodiment in the embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. In addition, in the description of this specification, the description of reference terms "one embodiment", "some embodiments", "example", "specific example", "some examples", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present application. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples without contradiction.
[0104] The above description is only an optional implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be covered within the protection scope of the embodiments of the present application.
Claims
1. A method for optimizing inference resources, characterized in that: include: Obtaining inference service response performance data of the neural network model under different hardware resources, and hardware cost data under the different hardware resources; Optimizing and modeling the inference service response performance data and the hardware cost data to obtain a hardware resource deployment solution with the lowest hardware cost; Generate a configuration file of the neural network model according to the hardware resource deployment solution with the lowest hardware cost; The neural network model and the different hardware resources are adaptively scheduled and optimized according to the configuration file.
2. The method according to claim 1, characterized in that The different hardware resources include: multiple computing resources and multi-level storage resources; the optimization modeling of the reasoning service response performance data and the hardware cost data includes: Constructing an integer linear programming ILP solver by using the multiple computing resources, the hardware cost data of the multiple computing resources, the multi-level storage resources and the hardware cost data of the multi-level storage resources; The ILP solver is used to optimize and model the inference service response performance data and the hardware cost data.
3. The method according to claim 2, characterized in that The ILP solver comprises: an objective function; the integer linear programming ILP solver is constructed by using the multiple computing resources, the hardware cost data of the multiple computing resources, the multi-level storage resources and the hardware cost data of the multi-level storage resources, including: The objective function is determined by the multiple computing resources, the hardware cost data of the multiple computing resources, the multi-level storage resources and the hardware cost data of the multi-level storage resources. Where n_acc represents the total number of types of computing resources, Acc i represents the number of computing resources of the i-th computing resource among the multiple computing resources, cost_acc i represents the hardware cost data of the i-th computing resource among the multiple computing resources, n_mem represents the total number of types of the multi-level storage resources, mem j Indicates the storage size of the i-th level storage resource in the multi-level storage resource, cost_mem j Represents hardware cost data of an i-th level storage resource in the multi-level storage resources.
4. The method according to claim 3, characterized in that The ILP solver further includes: a constraint condition of computing power resources; the integer linear programming ILP solver is constructed by using the multiple computing power resources, the hardware cost data of the multiple computing power resources, the multi-level storage resources and the hardware cost data of the multi-level storage resources, and further includes: By formula Calculating the multiple computing resources to obtain constraints of the computing resources; Among them, Acc_comp i Indicates the amount of computation required by the i-th computing resource among the multiple computing resources, Acc_flops i represents the maximum computing power of the i-th computing power resource among the multiple computing power resources, T communication It represents the data communication duration between any two computing resources among the multiple computing resources, and Latency_demand represents the maximum delay duration of the inference server of the neural network model.
5. The method according to claim 3, characterized in that: The ILP solver further includes: a constraint condition of storage resources; the integer linear programming ILP solver is constructed by using the multiple computing resources, the hardware cost data of the multiple computing resources, the multi-level storage resources and the hardware cost data of the multi-level storage resources, and further includes: Through the formula w acc +Act acc +KV acc <acc memory and w mem +Act mem +KV mem <mem memory Calculating the multi-level storage resources to obtain constraints of the storage resources; Among them, w acc represents the data size of the weight parameters of the neural network model in the accelerator memory in the multi-level storage resource, w mem represents the data size of the weight parameters of the neural network model in the server memory in the multi-level storage resource, Act acc represents the data size of the activation value of the neural network model in the accelerator memory in the multi-level storage resource, Act mem represents the data size of the activation value of the neural network model in the server memory in the multi-level storage resource, KV acc represents the data size of the KV cache of the neural network model in the accelerator memory in the multi-level storage resource, KV mem represents the data size of the KV cache of the neural network model in the server memory in the multi-level storage resource, acc memory Indicates the total memory size of the accelerator memory in the multi-level storage resources, mem memory Indicates the total memory size of the server memory in the multi-level storage resource.
6. The method according to claim 2, characterized in that The adaptively scheduling and optimizing the neural network model and the different hardware resources according to the configuration file includes: Determining whether the activity value of the model parameter of the neural network model is greater than a preset threshold in the configuration file; If yes, the model parameters of the neural network model are moved to the accelerator memory in the multi-level storage resource; otherwise, the model parameters of the neural network model are moved to the server memory in the multi-level storage resource; The model parameters include: weight parameters and / or KV cache.
7. A reasoning resource optimization device, characterized in that: include: A resource data acquisition module, used to acquire the inference service response performance data of the neural network model under different hardware resources, and the hardware cost data under the different hardware resources; A deployment scheme acquisition module, used to optimize and model the inference service response performance data and the hardware cost data to obtain a hardware resource deployment scheme with the minimum hardware cost; A configuration file generation module, used to generate a configuration file of the neural network model according to the hardware resource deployment solution with the minimum hardware cost; A resource scheduling optimization module is used to perform adaptive scheduling optimization on the neural network model and the different hardware resources according to the configuration file.
8. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the machine-readable instructions are executed by the processor to perform any method according to claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is executed.
10. A computer program product, characterized in that include: A computer program or a computer instruction, wherein when the computer program or the computer instruction is executed by a processor, the method according to any one of claims 1 to 6 is executed.
Citation Information
Patent Citations
Inference task scheduling method and device and computer equipment
CN116841706A
Model structured pruning method and device based on edge computing architecture
CN118070868A
Storage method and device of neural network model, electronic equipment and storage medium
CN118170531A
Comprehensive energy system optimization scheduling method and system based on dynamic energy concentrator
CN118195065A
Parallel task scheduling method and device based on ILP model, equipment and medium
CN118210601A
Cited By
Resource allocation method, device and equipment for large model cluster, storage medium and program product
CN119597368A
LLM model resource allocation method and device under GPU cluster based on mixed integer programming
CN119988043A
FPGA chip configuration method and device, program product, medium and electronic equipment
CN120256381A
FPGA chip configuration method, device, program product, medium and electronic device
CN120256381B
Self-adaptive software stack optimization method and system based on GPU (Graphics Processing Unit) server configuration
CN120803541A
