A method, device, medium and program product for optimizing model environment parameters
The temperature-controlled parameter search process optimizes model deployment environments efficiently, addressing inefficiencies in existing methods by achieving global optimal parameters.
Patent Information
- Application Number
- CN202510331672.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2045-03-20
AI Technical Summary
In the prior art, the environmental configuration parameter tuning process after the model is deployed is time-consuming, inefficient, and occupies a large amount of computing power resources, making it difficult to obtain a global optimal solution.
Through the parameter optimization process, the model environment parameters are optimized using temperature coefficients and cooling factors, including obtaining current parameters, performance parameters and fitness, updating the model environment parameters until the termination conditions are met, and the global optimal solution is achieved.
The efficiency of model environment parameter optimization is improved, the global optimal solution is obtained, and the problem of manual debugging is long and low efficiency is solved.
Smart Images

Figure CN119849643B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and particularly to a method, device, medium and program product for optimizing model environment parameters. Background Art
[0002] In recent years, with the rapid development of artificial intelligence models in multiple fields such as image recognition, speech processing, and natural language processing, the scale and complexity of the models have been continuously increasing. How to improve the inference efficiency and performance of artificial intelligence models and effectively exert the inference ability of artificial intelligence models has become a key challenge. Inference is the core link for artificial intelligence models to perform tasks such as prediction, classification, or generation based on actual data. Since artificial intelligence models are deployed on specific hardware devices, their inference performance is restricted by the deployment environment. If the deployment environment is not configured reasonably, it is difficult to achieve good inference effects of the models. Therefore, after the model is deployed, it is necessary to optimize the parameters of its deployment environment to maximize the inference performance of the model. The debugging of the deployment environment usually depends on personal experience and is carried out in a manual optimization manner. This method is time-consuming, inefficient, and occupies a large amount of computing resources, and it is difficult to obtain globally optimal deployment environment parameters. Summary of the Invention
[0003] The present application provides a method, device, medium and program product for optimizing model environment parameters, which at least solves the problems of long optimization time, low efficiency, and large consumption of computing resources in the process of optimizing the configuration parameters of the environment after model deployment.
[0004] In a first aspect, the present application provides a method for optimizing model environment parameters, including:
[0005] Obtain a current temperature coefficient, current model environment parameters, current performance parameters corresponding to the current model environment parameters, and current fitness corresponding to the current performance parameters;
[0006] Execute a parameter optimization process until a termination condition is met, where the parameter optimization process includes:
[0007] According to the current model environment parameters, determine domain parameters corresponding to the current model environment parameters, new performance parameters corresponding to the domain parameters, and new fitness corresponding to the new performance parameters;
[0008] Determine a fitness difference according to the new fitness and the current fitness;
[0009] Update the current model environment parameters according to the fitness difference;
[0010] In response to the updated current model environment parameters meeting the termination condition, output the current model environment parameters;
[0011] In response to the updated current model environment parameters not meeting the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the decrease amplitude of the current temperature coefficient.
[0012] In a second aspect, the present application further provides a model environment parameter optimization device, including:
[0013] A parameter acquisition module, configured to acquire the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters;
[0014] A parameter optimization module, configured to execute the parameter optimization process until the termination condition is met, where the parameter optimization process includes:
[0015] A new solution calculation unit, configured to determine, according to the current model environment parameters, the neighborhood parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the neighborhood parameters, and the new fitness corresponding to the new performance parameters;
[0016] A difference calculation unit, configured to determine the fitness difference according to the new fitness and the current fitness;
[0017] A parameter update unit, configured to update the current model environment parameters according to the fitness difference;
[0018] A result output unit, configured to output the current model environment parameters in response to the updated current model environment parameters meeting the termination condition;
[0019] A coefficient update unit, configured to update the current temperature coefficient with the current temperature coefficient and the cooling factor and repeat the parameter optimization process in response to the updated current model environment parameters not meeting the termination condition, where the cooling factor represents the decrease amplitude of the current temperature coefficient.
[0020] In a third aspect, the present application further provides a computer device, including a memory, a processor, and a model environment parameter optimization program stored in the memory and executable on the processor. When the processor executes the model environment parameter optimization program, the model environment parameter optimization method described in the first aspect is implemented. Specifically, it includes:
[0021] Acquire the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters;
[0022] Execute the parameter optimization process until the termination condition is met, where the parameter optimization process includes:
[0023] Determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters according to the current model environment parameters;
[0024] Determine the fitness difference according to the new fitness and the current fitness;
[0025] Update the current model environment parameters according to the fitness difference;
[0026] In response to the updated current model environment parameters satisfying the termination condition, output the current model environment parameters;
[0027] In response to the updated current model environment parameters not satisfying the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the decreasing amplitude of the current temperature coefficient.
[0028] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a model environment parameter optimization program is stored. When the model environment parameter optimization program is executed by a processor, the model environment parameter optimization method described in the first aspect is implemented. Specifically, it includes:
[0029] Obtain the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters;
[0030] Execute the parameter optimization process until the termination condition is satisfied, where the parameter optimization process includes:
[0031] Determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters according to the current model environment parameters;
[0032] Determine the fitness difference according to the new fitness and the current fitness;
[0033] Update the current model environment parameters according to the fitness difference;
[0034] In response to the updated current model environment parameters satisfying the termination condition, output the current model environment parameters;
[0035] In response to the updated current model environment parameters not satisfying the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the decreasing amplitude of the current temperature coefficient.
[0036] In a fifth aspect, the present application further provides a computer program product, including a computer program. When the computer program is executed by a processor, the model environment parameter optimization method described in the first aspect is implemented. Specifically, it includes:
[0037] Obtain the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters;
[0038] Execute a parameter optimization process until a termination condition is satisfied, where the parameter optimization process includes:
[0039] According to the current model environment parameters, determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters;
[0040] Determine the fitness difference according to the new fitness and the current fitness;
[0041] Update the current model environment parameters according to the fitness difference;
[0042] In response to the updated current model environment parameters satisfying the termination condition, output the current model environment parameters;
[0043] In response to the updated current model environment parameters not satisfying the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the decrease amplitude of the current temperature coefficient.
[0044] The beneficial effects brought by the technical solutions provided in the embodiments of the present application are:
[0045] By implementing a method, device, medium and program product for optimizing model environment parameters provided in the embodiments of the present application, through executing a parameter optimization process, the efficiency of optimizing model environment parameters can be improved, and a global optimal solution can be obtained. It solves the problems of long time consumption and low efficiency in manually debugging environment parameters, and it is difficult to obtain a global optimal solution. Description of the Drawings
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0047] Figure 1 It is a schematic diagram of a method for optimizing model environment parameters provided in the embodiments of the present application;
[0048] Figure 2 It is a schematic diagram of a device for optimizing model environment parameters provided in the embodiments of the present application;
[0049] Figure 3It is a schematic diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0050] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are only a part rather than all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.
[0051] Unless otherwise defined, the technical terms or scientific terms used in this disclosure shall have the ordinary meanings understood by those of ordinary skill in the art to which this disclosure pertains. The "first", "second", and similar terms used in this disclosure do not denote any order, quantity, or importance, but are only used to distinguish different components. Similarly, the terms such as "a", "an", or "the" do not denote a quantity limitation, but mean that there is at least one. The numbers in the accompanying drawings of the specification only represent the distinction of each functional component or module, and do not represent the logical relationship between the components or modules. The terms such as "including" or "comprising" mean that the elements or objects appearing before this word cover the elements or objects listed after this word and their equivalents, without excluding other elements or objects. The terms such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The terms such as "upper", "lower", "left", and "right" are only used to represent relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship may also change accordingly.
[0052] Next, various embodiments according to the present disclosure will be described in detail with reference to the drawings. It should be noted that in the drawings, the same reference numerals are assigned to components having substantially the same or similar structures and functions, and repeated descriptions thereof will be omitted.
[0053] In view of the problems in the prior art that the environmental configuration parameters after model deployment have a long optimization time, low efficiency, and a large amount of computing power resources occupied during the debugging process, the present application provides the following implementation manners.
[0054] In some embodiments, as Figure 1 shown, a method for optimizing model environment parameters includes:
[0055] S100: Obtain the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters;
[0056] S200: Perform a parameter optimization process until a termination condition is met. The parameter optimization process includes:
[0057] S210: According to the current model environment parameters, determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters;
[0058] S220: Determine the fitness difference based on the new fitness and the current fitness;
[0059] S230: Update the current model environment parameters according to the fitness difference;
[0060] S240a: In response to the updated current model environment parameters meeting the termination condition, output the current model environment parameters;
[0061] S240b: In response to the updated current model environment parameters not meeting the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the decline rate of the current temperature coefficient.
[0062] When the model performs an inference task, it needs to configure its running environment. The model environment parameters include at least one of the following: batch size, number of copy streams, number of inference streams, whether to perform inference on the copy stream, and whether to use graph optimization.
[0063] Among them, the batch size (batchsize) determines the number of inferences each time, and its value range is from 256 to 2560; the number of copy streams (copy_streams) controls the number of concurrent streams during inference, and its value range is from 1 to 10; the number of inference streams (infer_streams) determines the number of inference threads running simultaneously, and its value range is from 1 to 10; whether to perform inference on the copy stream (run_infer_on_copy_streams) indicates whether to run inference on the copy stream. This parameter is a boolean parameter. Usually, its initial value is set to False (or 0); whether to use graph optimization (use_graph) indicates whether to enable graph optimization. This parameter is a boolean parameter. Usually, its initial value is set to False (or 0).
[0064] After performing the model inference task under the current model environment parameters, the corresponding current performance parameters are obtained. Through the current performance parameters, the current fitness can be calculated.
[0065] Before the model environment parameter optimization method, it also includes:
[0066] S010: Obtain the initial value of the model environment parameters as the current model environment parameters, where the model environment parameters at least include one of the following: batch size, number of copy streams, number of inference streams, whether to perform inference on the copy streams, and whether to use graph optimization;
[0067] S020: Configure the model running environment with the current model environment parameters and obtain the corresponding current performance parameters, where the current performance parameters at least include: model inference speed and hardware utilization rate;
[0068] S030: Determine the current fitness according to the current performance parameters.
[0069] The initial value of the model environment parameters is usually obtained by selecting random numbers within the value range of each model environment parameter. Schematically, an initial value of a set of model environment parameters is:
[0070] batchsize = 1024;
[0071] copy_streams = 5;
[0072] infer_streams = 5;
[0073] run_infer_on_copy_streams = 0;
[0074] use_graph = 0.
[0075] The current model environment parameters are the starting point of model inference. Starting from this point, through the parameter optimization process, a parameter combination more beneficial to model inference can be found.
[0076] Taking the current performance parameters including model inference speed and hardware utilization rate as an example, the current fitness is expressed as:
[0077] F p = P p · U p
[0078] Where F p represents the current fitness; P p represents the current model inference speed, representing the processing ability of the model under a specific configuration and reflecting the number of samples processed per second; U pIndicates the current hardware utilization rate, which is used to measure the utilization efficiency of the graphics card or other hardware resources. It is mainly represented by the video memory utilization rate to ensure the efficient use of hardware resources. To ensure that the fitness function is meaningful, the graphics card utilization rate U should be a positive indicator, that is, a higher utilization rate should indicate better resource utilization efficiency. If the graphics card utilization rate is too low, it means that the resources are not fully utilized; if the graphics card utilization rate is too high, it may lead to performance bottlenecks. Considering the fitness of hardware utilization is more in line with the actual hardware environment of the running model and achieves a compromise between model performance and hardware performance.
[0079] The fitness combines the model inference performance and the performance of the hardware when running the model inference task, and comprehensively evaluates the hardware resources and model performance. In some evaluation systems, especially the MLPerf evaluation system, the focus is on inference performance. Therefore, in the calculation of fitness, the performance indicators of model inference and hardware performance are directly used to evaluate the execution status.
[0080] Preferably, the current performance parameter also includes the hardware power consumption.
[0081] Determine the current fitness according to the current performance parameter, including:
[0082] According to: F p = P p · U p · W p , determine the current performance parameter, where, F p represents the current fitness, P p represents the current model inference speed, U p represents the current hardware utilization rate, W p represents the current hardware power consumption factor, which controls the impact of GPU power consumption, ensures that the power consumption is within the optimal operating range, and avoids performance loss or overload. Considering the fitness of hardware power consumption fully takes into account the actual hardware environment in which the model is deployed, and conducts a more comprehensive evaluation from the aspects of inference performance, hardware performance and energy consumption.
[0083] The current hardware power consumption factor is determined by the following formula:
[0084] ;
[0085] where,
[0086] ;
[0087] Pactual Indicates the current power consumption of the hardware (usually GPU). P max Indicates the maximum power consumption of the hardware (usually GPU).
[0088] Specifically, S210: Determine the domain parameters corresponding to the current model environment parameters according to the current model environment parameters, including:
[0089] S211: Obtain the parameter type of the current model environment parameters;
[0090] S212: In response to the parameter type of the current model environment parameters being continuous parameters, randomly increase or decrease the current model environment parameters by a preset step size to obtain the domain parameters;
[0091] S213: In response to the parameter type of the current model environment parameters being integer parameters, randomly increase or decrease the current model environment parameters by a preset value to obtain the domain parameters;
[0092] S214: In response to the parameter type of the current model environment parameters being boolean parameters, randomly invert or keep the current model environment parameters unchanged to obtain the domain parameters.
[0093] When performing parameter optimization using the model environment parameter optimization method described in the embodiments of the present application, domain parameters are generated based on the current model environment parameters in each iteration. For the batch size, which is a continuous parameter, the method for generating the corresponding domain parameters is to randomly increase or decrease the preset step size based on the current batch size value. Preferably, the preset compensation is set to 128.
[0094] For the number of copy streams and the number of inference streams, both of which are integer parameters, the method for generating the corresponding domain parameters is to randomly increase or decrease the preset value based on the current number of copy streams and the current number of inference streams. Preferably, the preset value is 1.
[0095] For the two parameters of whether to perform inference on the copy stream and whether to use graph optimization, both of which are boolean parameters, the method for generating the corresponding domain parameters is to randomly invert or keep the current value unchanged based on the current value.
[0096] Schematically, based on a set of model environment parameters batchsize = 1024; copy_streams = 5; infer_streams = 5; run_infer_on_copy_streams = 0; use_graph = 0, the generated domain parameters can be: batchsize = 1152 (increased by 128); copy_streams = 6 (increased by 1); infer_streams = 4 (decreased by 1); run_infer_on_copy_streams = 1 (negated); use_graph = 0 (remained unchanged).
[0097] Specifically, S210: Determine the new performance parameters corresponding to the domain parameters and the new fitness corresponding to the new performance parameters, including:
[0098] S215: Configure the model running environment with the domain parameters and complete the model inference task;
[0099] S216: Obtain the new performance parameters generated by the model when performing the inference task in the domain parameter running environment; where the new performance parameters at least include: the new model inference speed and the new hardware utilization rate;
[0100] S217: Use the product value of the new performance parameters as the new fitness.
[0101] Specifically, S220: Determine the fitness difference according to the new fitness and the current fitness, including:
[0102] According to: Δ f = F n – F p to determine the fitness difference, where Δ f represents the fitness difference, F n represents the new fitness, F p represents the current fitness.
[0103] Specifically, S230: Update the current model environment parameters according to the fitness difference, including:
[0104] S231: In response to the value of the fitness difference being greater than the preset difference degree, use the domain parameters as the current model environment parameters to update the current model environment parameters;
[0105] S231a: In response to the value of the fitness difference being less than or equal to the preset difference degree, decide whether to accept the domain parameters;
[0106] S232a: In response to accepting the domain parameter, use the domain parameter as the current model environment parameter to update the current model environment parameter;
[0107] S232b: In response to not accepting the domain parameter, keep the current model environment parameter unchanged.
[0108] Specifically, making a decision on whether to accept the domain parameter includes:
[0109] S2311a: Determine the acceptance probability value corresponding to the domain parameter according to the fitness difference;
[0110] S2312a: Generate a random number;
[0111] S2313a: Compare the numerical magnitudes of the random number and the acceptance probability value;
[0112] S2314a: In response to the random number being less than the acceptance probability value, accept the domain parameter as the current model environment parameter;
[0113] S2314b: In response to the random number being greater than or equal to the acceptance probability value, do not accept the domain parameter as the current model environment parameter.
[0114] Taking the following formula as an example:
[0115] ;
[0116] where, P accept represents the acceptance probability, and T represents the temperature coefficient. When the generated random number is less than P accept , then accept the domain parameter. Preferably, the random number is generated between 0 and 1.
[0117] When the new fitness is greater than the current fitness, unconditionally accept the domain parameter corresponding to the new fitness; when the new fitness is less than or equal to the current fitness, there is still a record of accepting the domain parameter corresponding to the new fitness. This can avoid prematurely falling into a local optimal solution during the parameter optimization process and being unable to obtain the global optimal solution.
[0118] Specifically, updating the current temperature coefficient with the current temperature coefficient and the cooling factor includes:
[0119] According to: T n = α · T c , determine the updated current temperature coefficient, where T n represents the updated current temperature coefficient, α represents the cooling factor, Tc Represents the current temperature coefficient before update.
[0120] The temperature coefficient gradually decreases from the set initial value under the action of the cooling factor.
[0121] The initial temperature coefficient T0 is usually set between 50 and 200. Preferably, in the embodiments of the present application, the initial temperature coefficient T0 is set to 100. Setting the initial temperature coefficient T0 to 100 can explore the optimal parameters in a relatively large solution space without causing excessive computational costs. A higher initial temperature can increase the exploratory nature of the search space, allowing the algorithm to search widely in the early stage to avoid getting trapped in a local optimum. The initial temperature is usually set relatively high so that in the initial stage, the algorithm can accept many different solutions. This helps to avoid getting trapped in a local optimum solution at the beginning and ensures global search. In practical applications, the selection of T0 usually needs to be combined with the characteristics of the specific problem. For example, if the search space of the problem is very large, a higher initial temperature can be set for more thorough exploration.
[0122] Preferably, determining the cooling factor includes:
[0123] S241b: Obtain the fitness difference and the current fitness;
[0124] S242b: Determine the difference degree ratio of the fitness difference to the current fitness according to the fitness difference and the current fitness;
[0125] S243b: Determine the value of the cooling factor according to the numerical interval where the difference degree ratio is located.
[0126] The cooling factor controls the rate of decrease of the temperature coefficient and determines the degree of temperature decrease in each iteration. A larger cooling factor will result in a slower temperature decrease, while a smaller cooling factor means a faster temperature decrease. It is usually set in the range of 0.8 to 0.99. If a higher α value (e.g., close to 1) is set, the parameter optimization process will maintain a relatively high temperature for a longer time, providing more opportunities to accept less excellent solutions and conduct a more extensive search. If α the value is set smaller, the parameter optimization process will converge faster, reducing the exploration range and entering the local optimum earlier. Generally, it is selected between 0.9 and 0.99. If a more conservative and earlier convergence of the search process is desired, a smaller α value (such as 0.95) is chosen. This setting will cause the temperature to gradually decrease while maintaining a relatively long exploration stage, preventing the algorithm from getting trapped in a local optimum prematurely, and is suitable for finding the global optimum in a relatively large search space.
[0127] Termination temperature coefficient T m, it is when the temperature coefficient drops below the termination temperature coefficient that the parameter optimization process terminates. A lower termination temperature means a higher degree of "refinement" in the parameter optimization process. That is, smaller changes are accepted, thereby exploring a more detailed solution space. T m controls the termination condition. When the temperature is too low, the parameter optimization process hardly accepts inferior solutions, and the search enters a convergence state. Setting this value too low will result in excessive calculations and difficulty in convergence, while setting it too high may cause the optimization to end prematurely. The common range of T m values is from 0.1 to 1, which depends on the scale and precision requirements of the specific problem. This value is small enough to ensure that the temperature drops to near the stable state, but it will not let the parameter optimization process waste too much time on minor changes, maintaining a high computational efficiency.
[0128] Specifically, S243b: Determine the value of the cooling factor according to the numerical interval where the difference ratio is located, including:
[0129] In response to the difference ratio being greater than the first preset value, set the cooling factor to the first cooling factor;
[0130] In response to the difference ratio being less than or equal to the first preset value and greater than the second preset value, set the cooling factor to the second cooling factor;
[0131] In response to the difference ratio being less than or equal to the second preset value and greater than the third preset value, set the cooling factor to the third cooling factor;
[0132] In response to the difference ratio being less than or equal to the third preset value and greater than the fourth preset value, set the cooling factor to the fourth cooling factor;
[0133] In response to the difference ratio being less than or equal to the fourth preset value, set the cooling factor to the fifth cooling factor.
[0134] The difference ratio is determined by: p f =Δ f / F p where, p f represents the difference ratio.
[0135] Schematically, the first preset value is 10%, the second preset value is 3%, the third preset value is 1%, and the fourth preset value is 0%.
[0136] Schematically, corresponding to p f >10%, the cooling factor α takes the value of 0.97; corresponding to 10%≥ p f> 3%, cooling factor α The value is 0.93; corresponding to 3% ≥ p f > 1%, cooling factor α The value is 0.90; corresponding to 1% ≥ p f > 0%, cooling factor α The value is 0.88. A large change in the difference ratio indicates a significant change in fitness. During the parameter optimization process, a larger cooling factor can be set to continue to fully explore the solution space; when the change in the difference ratio is very small, the cooling factor can be adjusted downwards to accelerate convergence and quickly obtain the optimal environmental parameters.
[0137] Specifically, the method for optimizing the model environmental parameters further includes:
[0138] In response to the temperature coefficient dropping below the preset minimum temperature, or
[0139] After the parameter optimization process has been iterated a preset number of times and the fitness difference does not exceed the preset threshold, or
[0140] The parameter optimization process iterates more than the preset maximum number of times, then terminate the parameter optimization process.
[0141] Illustratively, the preset maximum number of times is 50, the preset threshold is 10, and the preset maximum number of times is 100. By setting the termination conditions, it is possible to stop the parameter optimization process in a timely manner when the parameter optimization process meets the termination conditions, avoiding waste of computing power resources.
[0142] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation manner.
[0143] It should be understood that although Figure 1 the steps in the flowchart of Figure 1 are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover,
[0144] In other embodiments, such as Figure 2As shown in the figure, a device for optimizing model environment parameters includes:
[0145] A parameter acquisition module, configured to acquire a current temperature coefficient, current model environment parameters, a current performance parameter corresponding to the current model environment parameters, and a current fitness corresponding to the current performance parameter;
[0146] A parameter optimization module, configured to execute a parameter optimization process until a termination condition is satisfied, wherein the parameter optimization process includes:
[0147] A new solution calculation unit, configured to determine, according to the current model environment parameters, domain parameters corresponding to the current model environment parameters, new performance parameters corresponding to the domain parameters, and a new fitness corresponding to the new performance parameters;
[0148] A difference calculation unit, configured to determine a fitness difference according to the new fitness and the current fitness;
[0149] A parameter update unit, configured to update the current model environment parameters according to the fitness difference;
[0150] A result output unit, configured to output the current model environment parameters in response to the updated current model environment parameters satisfying the termination condition;
[0151] A coefficient update unit, configured to, in response to the updated current model environment parameters not satisfying the termination condition, update the current temperature coefficient with the current temperature coefficient and a cooling factor, and repeat the execution of the parameter optimization process, wherein the cooling factor represents the descending range of the current temperature coefficient.
[0152] For the specific limitations on the device for optimizing model environment parameters, reference may be made to the limitations on the method for optimizing model environment parameters in the foregoing text, which will not be elaborated herein. Each module in the foregoing device for optimizing model environment parameters may be implemented in whole or in part by software, hardware, and their combination. The foregoing modules may be embedded in or independent of a processor in a computer device in a hardware form, or may be stored in a memory in the computer device in a software form, so as to facilitate the processor to call and execute the operations corresponding to the foregoing modules.
[0153] In some other embodiments, as Figure 3 shown, a computer device includes a memory, a processor, and a model environment parameter optimization program stored on the memory and executable on the processor. When the processor executes the model environment parameter optimization program, the method for optimizing model environment parameters described in the first aspect is implemented. Specifically, it includes:
[0154] Acquire a current temperature coefficient, current model environment parameters, a current performance parameter corresponding to the current model environment parameters, and a current fitness corresponding to the current performance parameter;
[0155] Execute the parameter optimization process until the termination condition is met, where the parameter optimization process includes:
[0156] According to the current model environment parameters, determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters;
[0157] According to the new fitness and the current fitness, determine the fitness difference;
[0158] According to the fitness difference, update the current model environment parameters;
[0159] In response to the updated current model environment parameters meeting the termination condition, output the current model environment parameters;
[0160] In response to the updated current model environment parameters not meeting the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the decline rate of the current temperature coefficient.
[0161] In some other embodiments, the present application also provides a computer-readable storage medium, on which a model environment parameter optimization program is stored. When the model environment parameter optimization program is executed by a processor, the model environment parameter optimization method described in the first aspect is implemented. Specifically, it includes:
[0162] Obtain the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters;
[0163] Execute the parameter optimization process until the termination condition is met, where the parameter optimization process includes:
[0164] According to the current model environment parameters, determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters;
[0165] According to the new fitness and the current fitness, determine the fitness difference;
[0166] According to the fitness difference, update the current model environment parameters;
[0167] In response to the updated current model environment parameters meeting the termination condition, output the current model environment parameters;
[0168] In response to the updated current model environment parameters not meeting the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the decline rate of the current temperature coefficient.
[0169] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as USB flash drives, read-only memory (ROM for short), random access memory (RAM for short), external hard drives, magnetic disks, or optical discs that can store computer programs.
[0170] In some other embodiments, the present application further provides a computer program product, including a computer program, which when executed by a processor, implements the model environment parameter optimization method described in the first aspect. Specifically, it includes:
[0171] Obtain the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters;
[0172] Execute a parameter optimization process until a termination condition is met. Among them, the parameter optimization process includes:
[0173] According to the current model environment parameters, determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters;
[0174] According to the new fitness and the current fitness, determine the fitness difference;
[0175] According to the fitness difference, update the current model environment parameters;
[0176] In response to the updated current model environment parameters meeting the termination condition, output the current model environment parameters;
[0177] In response to the updated current model environment parameters not meeting the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the execution of the parameter optimization process, where the cooling factor represents the descending range of the current temperature coefficient.
[0178] By implementing a model environment parameter optimization method, device, medium, and program product provided by the embodiments of the present application, through executing the parameter optimization process, the efficiency of optimizing the model environment parameters can be improved, and the global optimal solution can be obtained. It solves the problems of long time consumption and low efficiency in manually debugging environment parameters, and it is difficult to obtain the global optimal solution.
[0179] Those skilled in the art may further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0180] In particular, according to the embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments of the present application include a computer program product, which includes a computer program loaded on a computer-readable medium, and the computer program contains program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a memory, or installed from a ROM. When the computer program is executed by an external processor, the above functions defined in the methods of the embodiments of the present application are executed.
[0181] It should be noted that the computer-readable medium of the embodiments of the present application may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present application, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of the present application, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0182] The above computer-readable medium may be included in the above server; or it may exist separately and not be assembled into the server. The above computer-readable medium carries one or more programs, and when the one or more programs are executed by the server, the server: obtains the frame rate of an application on the terminal in response to detecting that the peripheral mode of the terminal is not activated; determines whether the user is obtaining the screen information of the terminal when the frame rate meets the screen-off condition; and controls the screen to enter the immediate dimming mode in response to the determination result that the user is not obtaining the screen information of the terminal.
[0183] Computer program code for performing the operations of the embodiments of the present application can be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., connected through the Internet using an Internet service provider).
[0184] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for a system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, reference can be made to the partial description of the method embodiment. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative work.
[0185] The technical solutions provided in this application have been introduced in detail above. Specific examples are used in this article to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. At the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this application.
[0186] The above has introduced in detail a method, device, medium and program product for optimizing model environment parameters provided by this application. Specific examples are used in this article to elaborate on the principle and implementation manner of this application. The above embodiments are only preferred embodiments of this application, which are used to help understand the method and its core idea of this application, and are not intended to limit this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this application also fall within the protection scope of the claims of this application.
Claims
1. A method for optimizing model environment parameters, characterized in that, Including: Obtain the current temperature coefficient, the current model environment parameters, the current performance parameters corresponding to the current model environment parameters, and the current fitness corresponding to the current performance parameters; Execute a parameter optimization process until a termination condition is met, where the parameter optimization process includes: According to the current model environment parameters, determine the domain parameters corresponding to the current model environment parameters, the new performance parameters corresponding to the domain parameters, and the new fitness corresponding to the new performance parameters; Determine the fitness difference according to the new fitness and the current fitness; Update the current model environment parameters according to the fitness difference; In response to the updated current model environment parameters meeting the termination condition, output the current model environment parameters; In response to the updated current model environment parameters not meeting the termination condition, update the current temperature coefficient with the current temperature coefficient and the cooling factor, and repeat the parameter optimization process, where the cooling factor represents the descending range of the current temperature coefficient; The current fitness of the current performance parameters is obtained by the following method: According to: F p = P p · U p · W p , calculate the current fitness corresponding to the current performance parameter, where the F p represents the current fitness, the P p represents the current model inference speed, the U p represents the current hardware utilization rate, the W p represents the current hardware power consumption factor; The updating the current model environment parameters according to the fitness difference includes: In response to the value of the fitness difference being less than or equal to a preset difference degree, decide whether to accept the domain parameters.
2. The model environment parameter optimization method according to claim 1, wherein Before the method, it further includes: Obtain the initial value of the model environment parameters as the current model environment parameters, where the model environment parameters at least include one of the following: batch size, number of replication streams, number of inference streams, whether to perform inference on the replication stream, and whether to use graph optimization; Configure the model running environment with the current model environment parameters and obtain the corresponding current performance parameters, where the current performance parameters at least include: model inference speed and hardware utilization rate; Determine the current fitness according to the current performance parameters.
3. The model environment parameter optimization method according to claim 1, characterized in that The determining the domain parameters corresponding to the current model environment parameters according to the current model environment parameters includes: Obtain the parameter type of the current model environment parameters; In response to the parameter type of the current model environment parameters being a continuous parameter, randomly increase or decrease the current model environment parameters by a preset step size to obtain the domain parameters; In response to the parameter type of the current model environment parameters being an integer parameter, randomly increase or decrease the current model environment parameters by a preset value to obtain the domain parameters; In response to the parameter type of the current model environment parameters being a boolean parameter, randomly invert or keep the current model environment parameters unchanged to obtain the domain parameters.
4. The model environment parameter optimization method according to claim 1, characterized in that Determine the new performance parameters corresponding to the domain parameters and the new fitness corresponding to the new performance parameters, including: Configure the model running environment with the domain parameters and complete the model inference task; Obtain the new performance parameters generated by the model when performing the inference task in the domain parameter running environment; where the new performance parameters at least include: new model inference speed and new hardware utilization rate; Take the product of the new performance parameters as the new fitness.
5. The method for optimizing model environment parameters according to claim 1, wherein Determining a fitness difference according to the new fitness and the current fitness includes: According to: Δ f = F n – F p , determine the fitness difference, where the Δ f represents the fitness difference, the F n represents the new fitness, and the F p represents the current fitness.
6. The method for optimizing model environment parameters according to claim 1, characterized in that Updating the current model environment parameters according to the fitness difference further includes: In response to the value of the fitness difference being greater than a preset difference degree, using the domain parameters as the current model environment parameters to update the current model environment parameters; In response to accepting the domain parameters, using the domain parameters as the current model environment parameters to update the current model environment parameters; In response to not accepting the domain parameters, keeping the current model environment parameters unchanged.
7. The method for optimizing model environment parameters according to claim 6, characterized in that Determining whether to accept the domain parameters includes: Determining an acceptance probability value corresponding to the domain parameters according to the fitness difference; Generating a random number; Comparing the numerical size of the random number with the acceptance probability value; In response to the random number being less than the acceptance probability value, accepting the domain parameters as the current model environment parameters; In response to the random number being greater than or equal to the acceptance probability value, not accepting the domain parameters as the current model environment parameters.
8. The method for optimizing model environment parameters according to claim 1, wherein Updating the current temperature coefficient with the current temperature coefficient and a cooling factor includes: According to: T n = α · T c , determine the updated current temperature coefficient, where the T n represents the updated current temperature coefficient, and the α represents the cooling factor, and the T c represents the current temperature coefficient before update.
9. The method for optimizing model environment parameters according to claim 8, wherein Determining the cooling factor includes: Obtaining the fitness difference and the current fitness; Determining a difference degree ratio of the fitness difference to the current fitness according to the fitness difference and the current fitness; Determining the value of the cooling factor according to the numerical interval where the difference degree ratio is located.
10. The model environment parameter optimization method according to claim 9, characterized in that Determining the value of the cooling factor according to the numerical interval where the difference degree ratio is located includes: In response to the difference degree ratio being greater than a first preset value, setting the cooling factor to a first cooling factor; In response to the difference degree ratio being less than or equal to the first preset value and greater than a second preset value, setting the cooling factor to a second cooling factor; In response to the difference degree ratio being less than or equal to the second preset value and greater than a third preset value, setting the cooling factor to a third cooling factor; In response to the difference degree ratio being less than or equal to the third preset value and greater than a fourth preset value, setting the cooling factor to a fourth cooling factor; In response to the difference degree ratio being less than or equal to the fourth preset value, setting the cooling factor to a fifth cooling factor.
11. The model environment parameter optimization method according to claim 1, wherein The method further includes: In response to the temperature coefficient dropping to less than a preset minimum temperature, or After the parameter optimization process iterates a preset number of times, the fitness difference does not exceed a preset threshold, or The parameter optimization process iterates more than a preset maximum number of times, then terminating the parameter optimization process.
12. A computer device, characterized in that, Including a memory, a processor, and a model environment parameter optimization program stored on the memory and executable on the processor, when the processor executes the model environment parameter optimization program, implementing the model environment parameter optimization method according to any one of claims 1 to 11.
13. A computer-readable storage medium, characterized in that, Stored thereon is a model environment parameter optimization program, when the model environment parameter optimization program is executed by the processor, implementing the model environment parameter optimization method according to any one of claims 1 to 11.
14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the model environment parameter optimization method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Processor power consumption adjusting method and device and computer equipment
CN117193507A
Parameter optimization method and device, compiling method and device, electronic device and medium
CN118551820A