Module-aware mixed-precision inference method and apparatus for machine-learned interatomic potential models

CN122965683APending Publication Date: 2026-10-23INST OF COMPUTING TECH CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611117992.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-27
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

缺少该闭环流程时,难以同时保证低精度推理的精度、稳定性和实际部署收益

Benefits of technology

[0044](1)本发明将混合精度策略由全模型统一设置转变为候选模块级选择,能够根据不同候选模块的计算形态和误差敏感程度配置执行路径,降低统一低精度化造成的能量、力和应力误差放大风险。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122965683A_ABST
    Figure CN122965683A_ABST
Patent Text Reader

Abstract

The application provides a module-aware mixed-precision inference method and device for a machine learning interatomic potential model, a storage medium and an electronic device, comprising: performing full-precision inference on the machine learning interatomic potential model to obtain a physical quantity baseline and running features of a candidate module; generating a mixed-precision strategy for the candidate module according to the influence of the running features and a candidate execution path on a prediction error; selecting an actual execution path from the candidate execution path according to the mixed-precision strategy and a running condition of a current module in the candidate module to obtain a mixed-precision inference result; verifying the mixed-precision inference result according to the physical quantity baseline, and updating the mixed-precision strategy according to accuracy and performance verification results. Therefore, the application can improve end-to-end inference efficiency while ensuring the quality of energy, force and stress prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of high-performance computing and artificial intelligence, and in particular to a module-aware hybrid precision inference method, apparatus, storage medium and electronic device for machine learning interatomic potential energy models. Background Technology

[0002] First-principles calculations, starting from the fundamental laws of quantum mechanics, can accurately solve for physical quantities such as energy, atomic forces, and stresses in materials, molecules, or crystal systems. Common methods include DFT (Density Functional Theory). However, first-principles calculations typically require solving complex electronic structure problems, resulting in high computational costs and making it difficult to directly support large-scale structure searches, long-term molecular dynamics studies, and high-throughput material screening.

[0003] MLIP (Machine Learning Interatomic Potential) is a class of models that approximate first-principles potential energy surfaces using machine learning methods. These models typically take atom types, atomic coordinates, unit cell information, and atomic adjacency relationships as inputs to predict the system's energy, and further derive the forces and stresses by differentiating the energy with respect to atomic coordinates or unit cell variables. Compared to directly performing first-principles calculations, MLIP can achieve higher prediction accuracy at a lower computational cost, and has therefore become an important technological direction in computational materials science.

[0004] In recent years, pre-trained MLIPs have been increasingly used in various material systems. Some models employ equivariant structures to enhance the physical consistency of the model with spatial transformations such as rotation and translation. However, equivariant models typically involve tensor products and high-order feature representations, resulting in high training and inference costs. MatRIS is a pre-trained machine learning interatomic potential energy model, and its overall structure is as follows: Figure 1As shown, the model first receives input structural information, including atom types, atomic coordinates, and unit cell information. Then, it enters the graph construction stage, where the model performs periodic expansion based on periodic boundary conditions and constructs atomic and line graphs based on the truncation radius. The atomic graph uses atoms as nodes and inter-atomic interactions as edges to describe two-body adjacency relationships; the line graph uses edges in the atomic graph as nodes and bond angles or three-body relationships formed by adjacent edges as edges to describe three-body interactions. After graph construction, the model enters the feature embedding stage, expanding features based on atom type, inter-atomic distance, and three-body angles to obtain atomic features, edge features, and three-body angle features. Subsequently, the features are input into the multi-layer interaction modules. Each interaction module includes a line graph attention module, an atomic graph attention module, and a feature refinement module: the line graph attention module updates edge and three-body features and passes the updated edge features to the atomic graph attention module; the atomic graph attention module updates atomic and edge features; and the feature refinement module further smooths and updates node, edge, and three-body related features using a gated multilayer perceptron, a regular multilayer perceptron, and a learnable envelope function. The aforementioned interaction modules can be repeatedly stacked in multiple layers to progressively model many-body interactions within the local structure of the material. Finally, the model reads out and sums the atomic energies using the energy readout module to obtain the total system energy E, and then automatically differentiates the force F and stress σ based on the total energy E. Therefore, MatRIS structurally includes stages such as input structure, graph construction, feature embedding, multi-layer interactions, energy readout, and physical quantity output, explicitly modeling many-body interactions while avoiding the high computational cost of high-order tensor products in isovariant models, thus achieving a balance between expressive power and computational efficiency.

[0005] Unlike ordinary deep learning models, MLIPs typically perform not only forward computation during the inference phase but also calculate input gradients for forces and stresses. Therefore, their inference chain includes forward computations such as atomic feature embedding, multilayer perceptrons, gated multilayer perceptrons, attention computation, edge feature updates, node feature updates, and readout modules, as well as backward input gradient calculations related to forces and stresses. While existing techniques such as mixed precision, quantization, compiler optimization, and inference engines can improve the inference efficiency of some neural networks, they primarily target ordinary forward inference or rule-based model structures and cannot directly address the dynamic graph structures, input gradient paths, and sensitivity to physical quantity errors inherent in MatRIS-like MLIPs.

[0006] Current limitations in accelerating deep learning model inference stem from their primary focus on general forward inference models, neglecting the unique inference process of machine learning inter-atomic potential energy models that rely on first-principles calculations. These models require predicting not only energy but also force and stress during the inference phase; force and stress are typically derived from the derivative of energy with respect to atomic coordinates or unit cell variables. Therefore, the inference process for these models can be viewed as a combination of forward computation and input gradient calculation, rather than the purely forward computation process found in general models.

[0007] For MatRIS-like models, the optimization targets are not limited to a single linear layer or a single matrix multiplication. In terms of model structure, different modules need to be considered, such as multilayer perceptrons, gated multilayer perceptrons, attention modules, readout modules, edge feature aggregation modules, and backward tail computation. Regarding numerical accuracy, the sensitivity of different modules to energy, force, and stress errors needs to be considered. In terms of input data, the changes in the number of atoms, edges, local geometric relationships, and intermediate tensor shapes introduced by different material structures also need to be taken into account. Therefore, directly using layer-by-layer quantization or low-precision replacement of the entire model makes it difficult to distinguish the error sensitivities of different modules, easily leading to amplified force and stress prediction errors.

[0008] Furthermore, the input graph structure of this type of model changes with the material structure, resulting in significant differences in the number of unfolded rows, hidden dimensions, feature collection, and dispersion aggregation forms among different samples. General compilation methods or fixed-shape operator optimization methods typically only cover a portion of the fixed input forms and are difficult to stably adapt to the aforementioned dynamic inference scenarios. Pursuing acceleration of low-precision matrix multiplication alone may be offset by additional overhead such as scale factor calculation, dequantization, program scheduling, automatic differential boundary, and backoff judgment, causing the acceleration effect in local tests to not stably translate into end-to-end benefits in the complete inference process.

[0009] Therefore, existing solutions lack a phased deployment process for inter-atomic potential energy models in MatRIS-like machine learning. Specifically, they lack a complete method that links single-precision baselines, single-precision fusion paths, low-precision fusion paths, runtime condition checks, rollback mechanisms, and end-to-end energy, force, and stress verification. Without this closed-loop process, it is difficult to simultaneously guarantee the accuracy, stability, and actual deployment benefits of low-precision inference.

[0010] In conclusion, the existing technology obviously has inconveniences and defects in practical use, so it is necessary to improve it. Summary of the Invention

[0011] To address the aforementioned shortcomings, the present invention aims to provide a module-aware hybrid precision inference method, apparatus, storage medium, and electronic device for machine learning interatomic potential energy models. This method enables different candidate modules to select the actual execution path based on operational characteristics, the impact of candidate execution paths on prediction errors, and runtime conditions. Furthermore, it allows for dynamic backtracking when the optimized path fails to meet accuracy requirements, performance requirements, or runtime conditions, thereby improving end-to-end inference efficiency while ensuring the quality of energy, force, and stress predictions.

[0012] To solve the above-mentioned technical problems, the present invention is implemented as follows:

[0013] In a first aspect, embodiments of the present invention provide a module-aware mixed-precision inference method for a machine learning interatomic potential energy model, the method comprising:

[0014] The baseline analysis step performs full-precision inference on the machine learning interatomic potential energy model to obtain the baseline of physical quantities and the operational characteristics of candidate modules;

[0015] The strategy generation step generates a mixed-precision strategy for the candidate module based on the operational characteristics and the impact of candidate execution paths on the prediction error.

[0016] The dynamic inference step involves selecting an actual execution path from the candidate execution paths based on the mixed precision strategy and the current module's operating conditions among the candidate modules, thereby obtaining the mixed precision inference result.

[0017] The closed-loop verification step verifies the hybrid precision inference result based on the physical quantity baseline, and updates the hybrid precision strategy based on the precision and performance verification results.

[0018] According to the method of the present invention, the physical quantity baseline includes an energy baseline, a force baseline, and / or a stress baseline;

[0019] The candidate modules include a multilayer perceptron, a gated multilayer perceptron, a line graph attention module, an atomic graph attention module, an edge feature aggregation module, a node feature update module, a readout module, and / or an input gradient path;

[0020] The operational characteristics include input shape, output shape, number of calls, time consumption percentage, weight range, and / or activation range.

[0021] According to the method of the present invention, the candidate execution path includes the original full-precision path, the full-precision fused path, the low-precision path, and the low-precision fused path; the continuous operators in the input gradient path related to force and stress calculation are fused, and full-precision calculation, full-precision accumulation, or full-precision backoff is retained in the error-sensitive input gradient path.

[0022] According to the method of the present invention, in the dynamic inference step, before executing the low-precision fusion path, the device location, number of input rows, hidden dimension, quantization scale, and / or graphics processor expansion availability of the current module are checked, and the runtime check result is expressed as:

[0023]

[0024] in, Indicates the candidate module index. Indicates the device where the current tensor resides. Indicates the current line number of the input. Indicates the hidden dimension. This represents the set of hidden dimensions supported by the fusion operator. Indicates the quantization scale or block-level quantization scale. Indicates whether the corresponding graphics processor extension is available; when When, it is determined that the current module meets the operating conditions of the low-precision fusion path; when When this occurs, it indicates that the current module does not execute the low-precision fusion path and needs to fall back to the full-precision fusion path or the original full-precision path according to the subsequent path selection rules.

[0025] According to the method of the present invention, in the strategy generation step, the energy error increment, force error increment, stress error increment, and local output or input gradient error relative to the physical quantity baseline are obtained respectively when the current module adopts the full-precision fusion path and the low-precision fusion path, and the error sensitivity score of the current module for each of the candidate execution paths is determined according to the following formula:

[0026]

[0027] in, , , and These represent the energy error increment, force error increment, stress error increment, and local output or input gradient error corresponding to the current module, respectively. and These represent the corresponding error thresholds;

[0028] When the error sensitivity score meets a preset condition, the corresponding candidate execution path is determined as an available candidate path, where the preset condition is B. m ≤1; wherein, the available candidate path is the full-precision fusion path or the low-precision fusion path, and the original full-precision path is used as a fallback path.

[0029] According to the method of the present invention, in the dynamic inference step, the activation flag of the low-precision fusion path is determined based on the runtime check results, error sensitivity score, and / or the time consumption of different candidate execution paths:

[0030]

[0031] in, This indicates the time consumed by the current module using the low-precision fusion path. This indicates the time taken for the current module to use the full-precision fusion path; when When, select the low-precision fusion path; when If the full-precision fusion path is available, select the full-precision fusion path; otherwise, select the original full-precision path.

[0032] According to the method of the present invention, the closed-loop verification step includes:

[0033] Compare the module output and input gradients of the candidate execution paths with the corresponding results of the full-precision inference, and filter out the candidate execution paths whose local errors exceed a preset range;

[0034] Perform end-to-end inference on the candidate execution paths that have passed local verification, and compare energy error, force error, stress error and / or inference time.

[0035] The candidate execution paths that meet the error requirements and have performance benefits are written into the mixed precision strategy, and the candidate execution paths that exceed the error limit or have unstable performance benefits are set as fallback paths.

[0036] In a second aspect, embodiments of the present invention provide a module-aware hybrid precision inference device for a machine learning interatomic potential energy model constructed based on any one of the methods described above, the device comprising:

[0037] The baseline analysis module is used to perform full-precision inference on the machine learning interatomic potential energy model to obtain the physical quantity baseline and the operational characteristics of candidate modules;

[0038] The strategy generation module is used to generate a mixed-precision strategy for the candidate module based on the running characteristics and the impact of the candidate execution paths on the prediction error.

[0039] The dynamic inference module is used to select the actual execution path from the candidate execution paths based on the mixed precision strategy and the running conditions of the current module in the candidate modules, and obtain the mixed precision inference result.

[0040] The closed-loop verification module is used to verify the hybrid precision inference result based on the physical quantity baseline, and update the hybrid precision strategy based on the precision and performance verification results.

[0041] Thirdly, embodiments of the present invention provide a storage medium for storing a computer program for performing any of the methods described herein.

[0042] Fourthly, embodiments of the present invention provide an electronic device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the computer program to implement any of the methods described above.

[0043] The present invention has the following technical effects:

[0044] (1) The present invention changes the hybrid precision strategy from a unified setting of the whole model to a candidate module-level selection, which can configure the execution path according to the computational form and error sensitivity of different candidate modules, thereby reducing the risk of energy, force and stress error amplification caused by uniform low precision.

[0045] (2) The present invention is designed to fuse continuous small operators for the input gradient path required for force and stress, which can reduce the number of times the graphics processor kernel is started, the number of intermediate tensor reads and writes, the number of automatic differentiation boundaries and the frame scheduling overhead.

[0046] (3) The present invention adapts material structure samples with dynamic changes in the number of atoms, number of edges and shape of intermediate tensors through runtime condition checks and dynamic rollback mechanisms. When the optimized path is not applicable, it can select an available execution path and improve inference stability.

[0047] (4) The present invention adopts a closed-loop strategy that combines local correctness verification and end-to-end physical quantity verification, and simultaneously evaluates the module output, input gradient, energy, force, stress and inference time, so that the generated hybrid precision strategy is verifiable and deployable.

[0048] (5) This invention can be implemented without retraining the parameters of the original machine learning interatomic potential energy model, reducing the cost of model deployment and hardware adaptation. Attached Figure Description

[0049] Figure 1 This is a schematic diagram of the MatRIS model structure provided in the first embodiment of the prior art;

[0050] Figure 2 This is a flowchart illustrating the module-aware hybrid precision inference method for the interatomic potential energy model of machine learning provided in Embodiment 2 of the present invention.

[0051] Figure 3 This is a schematic diagram of the module-aware hybrid precision strategy provided in Embodiment 3 of the present invention;

[0052] Figure 4This is a schematic diagram of input gradient path fusion calculation provided in Embodiment 4 of the present invention;

[0053] Figure 5 This is a schematic diagram of the runtime condition checking and dynamic rollback mechanism provided in Embodiment 5 of the present invention;

[0054] Figure 6 This is a schematic diagram of the end-to-end physical quantity error closed-loop verification provided in Embodiment Six of the present invention;

[0055] Figure 7 This is a schematic diagram of the device functional modules and data flow provided in Embodiment 7 of the present invention;

[0056] Figure 8 This is a schematic diagram of the module-aware hybrid precision inference device for the machine learning interatomic potential energy model provided in Embodiment 8 of the present invention;

[0057] Figure 9 This is a schematic diagram of the structure of the electronic device provided in Embodiment 9 of the present invention. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0059] It should be noted that references to "an embodiment," "embodiment," "example embodiment," etc., in this specification refer to the described embodiment including specific features, structures, or characteristics, but not every embodiment must include these specific features, structures, or characteristics. Furthermore, such expressions do not refer to the same embodiment. Moreover, when describing specific features, structures, or characteristics in conjunction with embodiments, whether or not explicitly described, it is indicated that incorporating such features, structures, or characteristics into other embodiments is within the knowledge of those skilled in the art.

[0060] Furthermore, certain terms are used in the specification and subsequent claims to refer to specific components or parts. Those skilled in the art will understand that manufacturers may use different names or terms to refer to the same component or part. This specification and subsequent claims do not distinguish components or parts by differences in name, but rather by differences in function. The terms "comprising" and "including" used throughout the specification and subsequent claims are open-ended and should be interpreted as "including but not limited to." Additionally, the term "connection" here includes any direct and indirect electrical connection means. Indirect electrical connection means include connections made through other means.

[0061] The module-aware hybrid precision inference method for the interatomic potential energy model of machine learning provided by the present invention will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.

[0062] Figure 2 This is a flowchart illustrating the module-aware mixed-precision inference method for the inter-atomic potential energy model of machine learning provided in Embodiment 2 of the present invention. The method includes:

[0063] Step S101, baseline analysis step, performs full-precision inference on the machine learning interatomic potential energy model to obtain the physical quantity baseline and the operating characteristics of candidate modules.

[0064] Preferably, the physical quantity baseline includes an energy baseline, a force baseline, and / or a stress baseline, etc.

[0065] Preferably, the candidate modules include multilayer perceptrons, gated multilayer perceptrons, line graph attention modules, atomic graph attention modules, edge feature aggregation modules, node feature update modules, readout modules, and / or input gradient paths, etc.

[0066] Preferably, the operational features include input shape, output shape, number of calls, time consumption percentage, weight range, and / or activation range.

[0067] Step S102, strategy generation step, generates a mixed-precision strategy for candidate modules based on the running characteristics and the impact of candidate execution paths on prediction error.

[0068] Preferably, the candidate execution paths include the original full-precision path, the full-precision fused path, the low-precision path, and the low-precision fused path. Continuous operators in the input gradient paths related to force and stress calculations are fused, and full-precision calculations, full-precision accumulations, or full-precision backoffs are retained in error-sensitive input gradient paths.

[0069] Preferably, in the strategy generation step, the energy error increment, force error increment, stress error increment, and local output or input gradient error relative to the physical quantity baseline are obtained respectively when the current module adopts a full-precision fusion path and a low-precision fusion path, and the error sensitivity score of each candidate execution path corresponding to the current module is determined according to the following formula:

[0070]

[0071] in, , , and These represent the energy error increment, force error increment, stress error increment, and local output or input gradient error corresponding to the current module, respectively. and These represent the corresponding error thresholds.

[0072] When the error sensitivity score meets a preset condition, the corresponding candidate execution path is determined as a usable candidate path. The preset condition is B. m ≤1. Among them, the available candidate paths are full-precision fusion paths or low-precision fusion paths, and the original full-precision path is used as the fallback path.

[0073] Step S103, dynamic inference step: Based on the mixed precision strategy and the running conditions of the current module in the candidate modules, select the actual execution path from the candidate execution paths to obtain the mixed precision inference result.

[0074] Preferably, in the dynamic inference step, before executing the low-precision fusion path, the device location, number of input rows, hidden dimension, quantization scale, and / or graphics processor expansion availability of the current module are checked, and the runtime check results are expressed as follows:

[0075]

[0076] in, Indicates the candidate module index. Indicates the device where the current tensor resides. Indicates the current line number of the input. Indicates the hidden dimension. This represents the set of hidden dimensions supported by the fusion operator. Indicates the quantization scale or block-level quantization scale. Indicates whether the corresponding graphics processor extension is available. At that time, it is determined that the current module meets the operating conditions for a low-precision fusion path. When this occurs, it indicates that the current module will not execute the low-precision fusion path and needs to fall back to the full-precision fusion path or the original full-precision path according to the subsequent path selection rules.

[0077] Preferably, in the dynamic inference step, the activation flag for the low-precision fusion path is determined based on the runtime check results, error sensitivity score, and / or the time consumption of different candidate execution paths:

[0078]

[0079] in, This indicates the time taken by the current module using the low-precision fusion path. This indicates the time taken by the current module to use the full-precision fusion path. When When this is the case, choose a low-precision fusion path. If a full-precision fusion path is available, select the full-precision fusion path. Otherwise, select the original full-precision path.

[0080] Step S104, closed-loop verification step: verify the mixed precision inference results based on the physical quantity baseline, and update the mixed precision strategy based on the precision and performance verification results.

[0081] Preferably, the closed-loop verification step includes:

[0082] Compare the module output and input gradients of the candidate execution paths with the corresponding results of full-precision inference, and filter out candidate execution paths whose local errors exceed the preset range.

[0083] Perform end-to-end inference on candidate execution paths that pass local validation, and compare energy error, force error, stress error and / or inference time.

[0084] Candidate execution paths that meet the error requirements and have performance benefits are written into the mixed precision strategy, and candidate execution paths that exceed the error limit or have unstable performance benefits are set as fallback paths.

[0085] The technical solution of the present invention will be specifically illustrated below with examples:

[0086] I. Model Structure and Inference Task

[0087] This implementation method uses a MatRIS-like machine learning interatomic potential energy model as an example for illustration. Figure 1 As shown, the model input includes atom types, atomic coordinates, and unit cell information. The model is periodically expanded based on periodic boundary conditions, and atomic and line diagrams are constructed based on the cutoff radius. The atomic diagram uses atoms as nodes and interatomic interactions as edges, while the line diagram uses edges in the atomic diagram as nodes and bond angles or three-body relationships formed by adjacent edges as edges.

[0088] After the graph is constructed, feature expansion is performed on the atom type, interatomic distance, and three-body angle to obtain atomic features, edge features, and three-body angle features. The multilayer interaction module updates these features through line graph attention, atomic graph attention, and feature refinement modules. The energy readout module reads out the energy corresponding to each atom and sums it to obtain the total energy E of the system. Then, by differentiating the total energy E with respect to the atomic coordinates R and the deformation variable ε (automatic differentiation), the force F and stress σ are obtained.

[0089] In other embodiments, the machine learning interatomic potential energy model may also be a model with a graph structure, message passing structure, attention structure, equivariant structure or other differentiable potential energy expression structure, and obtains force or stress by differentiating the input variables with respect to the predicted energy or other scalar potential functions during the inference stage.

[0090] II. Terminology and Path Definitions

[0091] In this specification, "full precision" refers to computational precision relative to low precision. In one implementation, full precision is FP32 (single-precision floating-point), therefore, the FP32 paths shown in the figures correspond to the original full precision paths, and the FP32 fusion paths correspond to the full precision fusion paths. Depending on the hardware platform and model baseline, full precision can also be other floating-point formats that can form a precision benchmark.

[0092] The original full-precision path refers to the path that maintains the original model's data precision, computation graph boundaries, and operator calling methods when executing the current module. The full-precision fusion path refers to the path that maintains full-precision computation or full-precision accumulation, merging multiple consecutive operators with data dependencies into a single fusion operator or a group of fusion operators. The low-precision path refers to the path that uses a data format lower than the full precision to execute at least part of the current module's computation and does not require operator fusion. The low-precision fusion path refers to the path that uses low-precision input, low-precision weights, or low-precision intermediate representations to execute fusion operators, and retains full-precision accumulation, full-precision output, or full-precision backoff based on error sensitivity.

[0093] The low-precision data format may include low-precision floating-point formats such as FP16, BF16, and FP8 (including E4M3 and E5M2), or fixed-point quantization formats such as INT8 and INT4. When using a fixed-point quantization format, the weight range and activation range in the calibration data are statistically analyzed by tensor, channel, or data block to determine the quantization scale. m The block-level quantization scale refers to the quantization scale determined for each weight or activation based on a fixed-size data block. When using formats such as FP16 and BF16 that do not require an explicit scale, the scale can be... m Set to a constant or consider it to exist by default. This invention does not limit the specific bit width of full precision and low precision, as long as a relative precision hierarchy can be formed and path selection can be performed based on module error and performance.

[0094] III. Symbol Explanation

[0095] Suppose that the inference process of the machine learning interatomic potential energy model is divided into M candidate modules, and the set of candidate execution paths for the m-th module is denoted as P. m The actual path chosen is denoted as π. m Candidate execution paths may include the original full-precision path, the full-precision fused path, the low-precision path, and the low-precision fused path. For ease of description, the symbols used in this embodiment and their meanings are as follows.

[0096] 1. Module and Path Symbols

[0097]

[0098] 2. Error and Threshold Sign

[0099]

[0100] 3. Performance and Strategy Symbols

[0101]

[0102] IV. Baseline Analysis Steps

[0103] First, the machine learning interatomic potential energy model to be optimized, the inference task, the evaluation dataset, and the hardware operating environment are fixed. The inference task includes at least one of energy prediction, force prediction, and stress prediction. End-to-end inference is performed using the original full-precision path to obtain the end-to-end energy prediction result Y. E Force prediction result Y F and stress prediction results Y S The full-precision inference results, namely the energy baseline, force baseline, and stress baseline, are recorded, along with the average inference latency, total time, and number of successful samples. This full-precision inference result serves as a benchmark for subsequent low-precision paths, fusion paths, and fallback paths. For the m-th module, its original full-precision path time T is recorded. m,fp32 The system also calculates the number of times the module is called, the shape of its input and output, and the percentage of time it takes to complete the task.

[0104] In one implementation, the module splitting boundary is determined based on the fact that the inference time of the machine learning inter-atomic potential energy model is not concentrated on a few large matrix multiplications, but is distributed across gated multilayer perceptrons, multilayer perceptrons, line graph attention, atomic graph attention, edge feature aggregation, and the input gradient paths required for forces and stresses. Especially in small- to medium-scale material structure inference, a large number of small operators and input gradient calculations will bring significant graphics processor scheduling overhead. Therefore, the module boundaries are divided according to the above computational form.

[0105] like Figure 3 As shown, the inference process of the machine learning inter-atomic potential energy model is divided into multiple candidate modules. These candidate modules can be categorized according to model semantic boundaries, operator chain boundaries, automatic differentiation boundaries, or data aggregation boundaries, and include at least one of the following: multilayer perceptron, gated multilayer perceptron, line graph attention module, atomic graph attention module, edge feature aggregation module, node feature update module, readout module, and input gradient path.

[0106] For the Each candidate module is evaluated based on its input shape, output shape, number of calls, time consumption percentage, weight range, and activation range. The number of rows in the current input is also counted. Hidden Dimensions The device where the tensor is located It can also collect data on data type, weight layout, number of aggregated indexes, number of atoms, number of edges, and number of local geometric relations. The statistical results are stored in correspondence with the candidate module identifiers to form the operational characteristics of the candidate modules, which are used to determine whether the module is suitable for low-precision computation, fusion computation, or to retain high-precision paths.

[0107] Module splitting and runtime feature acquisition do not require changing the parameters of the trained model. They can be achieved through runtime hooks, computation graph analysis, operator tracing, performance analyzers, or custom inference encapsulation.

[0108] V. Strategy Generation Steps

[0109] like Figure 3 As shown in the "module decomposition" step, in order to select different precisions and execution paths according to different modules, the inference process of the machine learning inter-atomic potential energy model is first decomposed into modules. The decomposition objects include multilayer perceptrons, gated multilayer perceptrons, line graph attention, atomic graph attention, edge feature aggregation, node feature update, readout modules, and the input gradient paths required for force and stress. Different modules have different computational forms during the inference process; for example, some modules mainly involve matrix multiplication, while others mainly involve attention weight calculation, feature aggregation, or back-input gradient calculation.

[0110] like Figure 3 As shown in the "Module Feature Statistics" and "Error Sensitivity Analysis" steps, to avoid uniformly replacing the entire model with low-precision data, the input shape, output shape, number of calls, time consumption percentage, weight range, activation range, and sensitivity to energy, force, and stress errors are statistically analyzed for each module. Modules that are not sensitive to errors but have a high time consumption percentage are prioritized as low-precision candidate modules; for modules sensitive to force and stress errors, high-precision paths or high-precision accumulations are retained.

[0111] The strategy generation step generates a mixed-precision strategy based on the operational characteristics of candidate modules and the impact of each candidate execution path on the prediction error. The mixed-precision strategy can take the form of a strategy table, rule set, index structure, or conditional branching, and must at least record the candidate module identifier, available candidate paths, path priority, operational conditions, error index, time consumption index, and backoff relationship.

[0112] Each candidate module is connected to both a full-precision fusion path and a low-precision fusion path, while other candidate modules retain their original full-precision paths. This process yields the local output, input gradient, and end-to-end physical quantity results for each path. For candidate modules with independent low-precision operators but no need for fusion, they can also be evaluated by connecting to a low-precision path.

[0113] For the current candidate module, record the energy error increment of the candidate execution path relative to the physical quantity baseline. Force error increment Stress error increment and local output or input gradient error and with and This serves as the corresponding error threshold. The error sensitivity score is expressed as:

[0114]

[0115] When B m When a preset condition is met, the corresponding candidate execution path is determined as a usable candidate path. In one implementation, the preset condition is B. m ≤1. For modules that directly affect energy readout, coordinate gradient propagation, or stress-related deformation gradient propagation, a stricter force error threshold or stress error threshold can be set; for modules that account for a high proportion of time consumption and have a small impact on end-to-end physical quantity errors, a low-precision path or low-precision fusion path can be set first.

[0116] like Figure 3 As shown in the "Module-Level Path Selection" step, based on the results of module splitting, module feature statistics, and error sensitivity analysis, a full-precision path, a full-precision fusion path, a low-precision path, or a low-precision fusion path are selected for different modules, ultimately forming a mixed-precision strategy table. Thus, the mixed-precision strategy shifts from a uniform setting across the entire model to a dynamic selection at the module level, allowing each module to choose an appropriate execution path based on its own computational characteristics and error sensitivity.

[0117] Based on the module sensitivity analysis results, a candidate execution path set P is generated for the m-th module. m For modules that are sensitive to errors but have many small operators, prioritize establishing a full-precision fusion path and record its time T. m,fuse For modules that are insensitive to errors and have significant computational benefits, a low-precision fusion path is established, and its time T is recorded. m,lp .

[0118] Because the full-precision fusion path maintains full-precision calculation or full-precision accumulation, it typically has lower numerical errors and can serve as an intermediate fallback path between the low-precision path and the original full-precision path. The original full-precision path, as the final fallback path, does not become invalid due to the fusion operator or low-precision operator failing to meet the operating conditions.

[0119] VI. Fusion Calculation of Input Gradient Paths

[0120] like Figure 4As shown in the "Input Gradient Path Identification" step, the forces and stresses in machine learning interatomic potential energy models typically depend on the gradient of energy with respect to atomic coordinates, cell parameters, or deformation variables. Therefore, the input gradient path from the energy prediction result to the input variables is first identified, and then the continuous small operators in the input gradient path are fused. This input gradient path differs from the parameter gradient path used to update model parameters; its goal is to obtain the gradient of the input variables.

[0121] like Figure 4 As shown in the "small operator chain fusion" step, the fusionable continuous operators include at least two of the following: small matrix multiplication, normalization, activation functions, gated computation, element-wise operations, attention-based backward computation, edge feature updates, index reading, distributed accumulation, and feature aggregation. Fusion operators can be implemented through GPU kernel extensions, just-in-time compilation, static compilation, or custom operators defined by inference frameworks.

[0122] For gated multilayer perceptrons, tail activation, gated branching, element-wise multiplication, and linear layer input gradient calculation can be fused; for ordinary multilayer perceptrons, linear transformation, activation function, and input gradient calculation can be fused; for attention modules, attention weight inverse calculation, edge feature update, and feature aggregation can be fused; for graph aggregation modules, index reading, distributed accumulation, and directed edge to undirected edge reduction operations can be fused.

[0123] like Figure 4 As shown in the "High-Precision Preservation of Sensitive Paths" step, for paths sensitive to force and stress errors, full-precision calculations, full-precision accumulations, or full-precision backoff paths are preserved in the fusion computation, rather than blindly using low precision. Even if the input, weights, or some intermediate results are in low-precision format, full precision can be used in matrix multiplication accumulation, reduction accumulation, gradient output, or key nonlinear calculations. This reduces the overhead of automatic differentiation boundaries and GPU kernel startup, while controlling input gradient errors to manage force and stress errors.

[0124] VII. Dynamic Reasoning Steps

[0125] like Figure 5 As shown in the “Different Material Structure Samples” and “Current Module Input”, the input material structure of the machine learning interatomic potential energy model has dynamic graph characteristics. The number of atoms, edges and local geometric relationships in different samples are different, which causes the number of input rows, intermediate tensor shape and aggregation index of the current module to change dynamically.

[0126] like Figure 5As shown in the "Runtime Condition Check" step, before executing a low-precision path or a fusion path, the input shape, data type, device location, hidden dimensions, number of atoms, number of edges, weight layout, quantization parameters, and graphics processor operator extension availability of the current module are checked. The corresponding low-precision path or fusion path is only executed if the current input and module state meet the support conditions.

[0127] In one implementation, runtime condition checks include the device where the current tensor resides. Current input line number Hidden Dimensions Quantitative scale and graphics processor expanded availability Runtime check result G m Represented as:

[0128]

[0129] Where H represents the set of hidden dimensions supported by the fusion operator, and the symbol 1{·} represents the characteristic function. When When the current module meets the basic operating conditions of the low-precision fusion path; when At that time, the low-precision fusion path is not executed. Runtime checks may also include input data type, tensor continuity, number of atoms, number of edges, index range, weight layout, shared memory requirements, and graphics processor architecture version.

[0130] like Figure 5 As shown in the "Dynamic Path Selection" step, by combining runtime check results, error sensitivity scores, and candidate execution path times, the activation flag for low-precision fusion paths is determined:

[0131]

[0132] When C m, lp When = 1, the actual chosen path π m For low-precision fusion paths; when C m, lp = 0 and T m, fuse < Tm, fp32 At that time, the actual path π is selected. m The path selected is the full-precision fusion path; when none of the above conditions are met, the actual selected path is π. m This is the original full-precision path. Therefore, it avoids inference failures or uncontrollable errors caused by low-precision paths not meeting certain conditions. For low-precision paths, independent activation conditions can be set based on corresponding device conditions, low-precision operator availability, error score, and time consumption benefits.

[0133] like Figure 5As shown in the "Dynamic Graph Structure Adaptation" section, runtime condition checks and dynamic rollback mechanisms prevent fixed-shape optimization methods from failing on unsuitable samples and ensure that the inference process is not interrupted due to low-precision paths or fusion paths not meeting conditions. This process enables material samples of different structural sizes to use different execution paths.

[0134] In one implementation, path latency is calculated using the median, truncated mean, or other robust statistical values ​​from multiple runs, with a minimum performance gain threshold set to avoid frequent path switching due to measurement noise. Furthermore, path latency and path selection rules can be stored separately for different input row count, atom count, or edge count ranges, allowing the mixed-precision strategy to adapt to different structural sizes.

[0135] VIII. Closed-loop verification steps

[0136] like Figure 6 As shown in the "Local Correctness Verification" step, after a candidate low-precision path or fused path is connected, the correctness of the output and input gradient results of a single module is first verified by comparing them with the full-precision baseline results to determine whether the local error is within a preset range. Local correctness verification can use absolute error, relative error, mean square error, maximum error, normalized error, or a combination of the above errors. Paths that fail local verification will not proceed to subsequent end-to-end physical quantity verification or be included in the priority execution path set.

[0137] like Figure 6 As shown in the "end-to-end physical quantity verification" step, after the local verification is passed, the complete machine learning inter-atomic potential energy model inference process is further executed to obtain the mixed-precision inference result, which is then compared with the energy prediction result Y. E Force prediction result Y F Stress prediction results Y S The error compared to the full-precision baseline is recorded, along with average latency, total execution time, number of successful samples, and path hit rate at different structure sizes. This validation focuses not only on the acceleration effect of individual operators but also on the overall prediction quality and inference efficiency in the final materials simulation task.

[0138] like Figure 6 As shown in the "Policy Update and Retention" step, the module-level hybrid precision policy is updated based on the end-to-end physical quantity verification results. For paths with satisfactory error and stable performance gains, they are retained as default execution paths and their execution priority is increased; for low-precision paths with excessive error or unstable acceleration gains, they are set as default fallback paths; for candidate execution paths with errors exceeding the target threshold or unstable performance gains but still meeting the safety threshold, they can be set as secondary fallback paths; for candidate execution paths exceeding the safety threshold, they are disabled and their corresponding fallback relationships are set to the full-precision fusion path or the original full-precision path.

[0139] This ultimately results in a deployable module-level strategy table. The strategy table records the set of candidate execution paths P for each module. m Actual path selection π m Runtime check results G m Sensitivity score B m Low-precision fusion path enable flag C m,lp It can record various error indicators and rollback paths, as well as candidate module identifiers, path priorities, running conditions, and time consumption indicators.

[0140] The closed-loop validation results are fed back to the policy generation step, where candidate paths, error thresholds, path priorities, or operating conditions are readjusted until a hybrid accuracy policy that meets the requirements of prediction accuracy and end-to-end performance is obtained.

[0141] The device of this invention functionally includes a baseline analysis module, a strategy generation module, a dynamic inference module, and a closed-loop verification module. For ease of explanation, the specific implementation is described below. Figure 7 A specific implementation of the device is shown, comprising a baseline analysis module (module A), a module splitting and sensitivity analysis module (module B), a mixed-precision policy generation module (module C), a fusion operator execution module (module D), a runtime checking and rollback module (module E), and an end-to-end verification module (module F). Module A corresponds to the baseline analysis module; modules B and C together constitute the policy generation module; modules D and E together constitute the dynamic inference module; and module F corresponds to the closed-loop verification module. The internal functional units can be set separately or integrated into the four functional modules.

[0142] Module A, baseline analysis module. (For example...) Figure 7 As shown in "Module A Baseline Analysis Module", this module is used to fix the model, task, dataset, and evaluation metrics, perform raw full-precision end-to-end inference, and obtain the accuracy baselines for energy, force, and stress, as well as the inference time baseline. Simultaneously, this module records the number of calls, input / output shapes, and time percentages for each model sub-module.

[0143] Module B, module splitting and sensitivity analysis module. For example... Figure 7 As shown in the "Module B - Module Decomposition and Sensitivity Analysis Module", this module is used to decompose the machine learning inter-atomic potential energy model into candidate modules such as multilayer perceptron, gated multilayer perceptron, attention computation, edge feature aggregation, node feature update, readout module, and input gradient path. This module is also used to evaluate the impact of different modules on energy, force, and stress errors under low-precision computation or fusion computation.

[0144] Module C, Mixed Precision Strategy Generation Module. For example... Figure 7As shown in the "Module C Hybrid Precision Strategy Generation Module", this module selects a full-precision path, a full-precision fusion path, a low-precision path, or a low-precision fusion path for each candidate module based on the time consumption analysis and sensitivity analysis results output by Module B. This module outputs a module-level hybrid precision strategy table.

[0145] Module D, the fusion operator execution module. For example... Figure 7 As shown in the "Module D Fusion Operator Execution Module", this module is used to execute specific full-precision or low-precision fusion operators, including multilayer perceptron input gradient fusion, gated multilayer perceptron tail fusion, attention-based backward computation fusion, edge feature aggregation fusion, and directed edge-to-undirected edge aggregation fusion. This module is used to reduce the scheduling overhead caused by small operator chains and automatic differentiation boundaries.

[0146] Module E, the runtime inspection and rollback module. (Example) Figure 7 As shown in the “Module E Runtime Check and Rollback Module”, this module is used to check whether the current input tensor and module state meet the execution conditions of the low-precision path or the fusion path during inference. When the conditions are met, the corresponding optimized path is invoked; when the conditions are not met, rollback is performed in the order of low-precision fusion path, full-precision fusion path, and original full-precision path.

[0147] Module F, end-to-end verification module. For example... Figure 7 As shown in "Module F, End-to-End Validation Module," this module is used to validate the effectiveness of mixed-precision strategies in a complete inference task. Validation includes energy error, force error, stress error, average latency, total time consumption, and the number of successful samples. This module updates or eliminates candidate strategies based on the validation results and feeds the updated results back to Module C.

[0148] This implementation does not require retraining the original model parameters of the machine learning interatomic potential energy model. The required data includes calibration data and validation data. Calibration data is used to statistically analyze the module input range, weight range, activation range, and quantization parameters; validation data is used to compare the energy, force, stress errors, and inference time between the mixed-precision path and the full-precision baseline.

[0149] The calibration data is in the form of material structure samples and the module input tensors, output tensors, weight parameters, and intermediate activation values ​​generated during the model inference process.

[0150] The validation data formats include: material structure samples, full-precision baseline inference results, and mixed-precision inference results. Validation metrics include energy error, force error, stress error, average inference delay, total time, and number of successful samples.

[0151] The overall input data of the device includes: the material structure to be inferred, the parameters of the trained machine learning interatomic potential energy model, the inference task configuration, and the error threshold. The overall output data of the device includes: energy, force, and stress prediction results, as well as a module-level hybrid accuracy strategy table. The input and output data of each module are shown in the table below.

[0152]

[0153] like Figure 7 As shown in the module connection diagram, the execution process is as follows: First, the material structure is input into module A to obtain the full-precision baseline and module time statistics; then, the module statistics results are input into module B for sensitivity analysis; module C generates a mixed-precision strategy table based on the sensitivity analysis results; during inference, module E selects the execution path based on the strategy table and runtime conditions, and calls module D to execute the corresponding fusion operator or low-precision operator; finally, module F performs end-to-end verification of the complete inference results and updates the strategy table in module C based on the verification results. This process is iterated repeatedly until a mixed-precision deployment scheme that meets the accuracy requirements and has stable inference benefits is obtained.

[0154] The device input may include the material structure to be inferred, the parameters of the trained model, the inference task configuration, calibration data, validation data, and error thresholds; the device output may include energy prediction results, force prediction results, stress prediction results, and a hybrid accuracy strategy.

[0155] Figure 8 This is a schematic diagram of the module-aware hybrid precision inference device for the interatomic potential energy model of machine learning provided in Embodiment 8 of the present invention. The device 100 includes a baseline analysis module 10, a policy generation module 20, a dynamic inference module 30, and a closed-loop verification module 40, wherein:

[0156] The baseline analysis module 10 is used to perform full-precision inference on the machine learning interatomic potential energy model to obtain the physical quantity baseline and the operating characteristics of the candidate modules.

[0157] The strategy generation module 20 is used to generate a mixed-precision strategy for the candidate module based on the running characteristics and the impact of the candidate execution path on the prediction error.

[0158] The dynamic inference module 30 is used to select the actual execution path from the candidate execution paths according to the mixed precision strategy and the running conditions of the current module in the candidate modules, and obtain the mixed precision inference result.

[0159] The closed-loop verification module 40 is used to verify the mixed precision inference results based on the physical quantity baseline, and update the mixed precision strategy based on the precision and performance verification results.

[0160] Preferably, the physical quantity baseline includes an energy baseline, a force baseline, and / or a stress baseline.

[0161] Preferably, the candidate module includes a multilayer perceptron, a gated multilayer perceptron, a line graph attention module, an atomic graph attention module, an edge feature aggregation module, a node feature update module, a readout module, and / or an input gradient path.

[0162] Preferably, the operational features include input shape, output shape, number of calls, time consumption percentage, weight range, and / or activation range.

[0163] Preferably, the candidate execution paths include the original full-precision path, the full-precision fused path, the low-precision path, and the low-precision fused path. Continuous operators in the input gradient paths related to force and stress calculations are fused, and full-precision calculations, full-precision accumulations, or full-precision backoffs are retained in error-sensitive input gradient paths.

[0164] Preferably, before executing the low-precision fusion path, the dynamic inference module 30 checks the current module's device location, number of input rows, hidden dimensions, quantization scale, and / or graphics processor expansion availability. The runtime check result is expressed as follows:

[0165]

[0166] in, Indicates the candidate module index. Indicates the device where the current tensor resides. Indicates the current line number of the input. Indicates the hidden dimension. This represents the set of hidden dimensions supported by the fusion operator. Indicates the quantization scale or block-level quantization scale. Indicates whether the corresponding graphics processor extension is available. At that time, it is determined that the current module meets the operating conditions for a low-precision fusion path. When this occurs, it indicates that the current module will not execute the low-precision fusion path and needs to fall back to the full-precision fusion path or the original full-precision path according to the subsequent path selection rules.

[0167] Preferably, the strategy generation module 20 obtains the energy error increment, force error increment, stress error increment, and local output or input gradient error relative to the physical quantity baseline when the current module adopts a full-precision fusion path and a low-precision fusion path, respectively, and determines the error sensitivity score of each candidate execution path corresponding to the current module according to the following formula:

[0168]

[0169] in, , , and These represent the energy error increment, force error increment, stress error increment, and local output or input gradient error corresponding to the current module, respectively. and These represent the corresponding error thresholds.

[0170] When the error sensitivity score meets a preset condition, the corresponding candidate execution path is determined as a usable candidate path. The preset condition is B. m ≤1. Among them, the available candidate paths are full-precision fusion paths or low-precision fusion paths, and the original full-precision path is used as the fallback path.

[0171] Preferably, the dynamic inference module 30 determines the activation flag of the low-precision fusion path based on the runtime check results, error sensitivity score, and / or the time consumption of different candidate execution paths:

[0172]

[0173] in, This indicates the time taken by the current module using the low-precision fusion path. This indicates the time taken by the current module to use the full-precision fusion path. When When this is the case, choose a low-precision fusion path. If a full-precision fusion path is available, select the full-precision fusion path. Otherwise, select the original full-precision path.

[0174] Preferably, the closed-loop verification module 40 performs the following actions:

[0175] Compare the module output and input gradients of the candidate execution paths with the corresponding results of full-precision inference, and filter out candidate execution paths whose local errors exceed the preset range.

[0176] Perform end-to-end inference on candidate execution paths that pass local validation, and compare energy error, force error, stress error and / or inference time.

[0177] Candidate execution paths that meet the error requirements and have performance benefits are written into the mixed precision strategy, and candidate execution paths that exceed the error limit or have unstable performance benefits are set as fallback paths.

[0178] The module-aware hybrid precision inference device for machine learning interatomic potential energy models provided in this embodiment of the invention can achieve... Figures 2-6 The various processes implemented in the example of the module-aware hybrid precision inference method for the interatomic potential energy model of machine learning are not described in detail here to avoid repetition.

[0179] The present invention also provides a storage medium for storing, for example, Figures 2-6The computer program for any of the modular awareness hybrid precision inference methods of machine learning interatomic potential energy models. For example, computer program instructions, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the present invention through the operation of the computer, and can achieve the same technical effect. To avoid repetition, they will not be described in detail here. The program instructions for invoking the methods of the present invention may be stored in a fixed or removable storage medium, and / or transmitted through a data stream in a broadcast or other signal carrying medium, and / or stored in the storage medium of a computer device operating according to the program instructions.

[0180] According to one embodiment of the present invention, the present invention also provides such a Figure 9 The illustrated electronic device 400 may optionally include a storage medium 200 for storing a computer program and a processor 300 for executing the computer program. When the computer program is executed by the processor 300, it implements any of the aforementioned machine learning interatomic potential energy models using a module-aware hybrid precision inference method, triggering the electronic device 400 to execute methods and / or technical solutions based on the foregoing embodiments, achieving the same technical effect. To avoid repetition, this will not be elaborated further. It should be noted that the electronic devices in this embodiment include mobile electronic devices and non-mobile electronic devices. For example, mobile electronic devices may be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, super mobile personal computers, netbooks, or personal digital assistants, etc., while non-mobile electronic devices may be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This embodiment does not specifically limit the scope of the invention.

[0181] It should be noted that the present invention can be implemented in software and / or a combination of software and hardware, for example, using an application-specific integrated circuit (ASIC), a general-purpose computer, or any other similar hardware device. In one embodiment, the software program of the present invention can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present invention (including associated data structures) can be stored in a computer-readable recording medium, such as RAM memory, a magnetic or optical drive, a floppy disk, or similar devices. Furthermore, some steps or functions of the present invention can be implemented in hardware, for example, as circuitry that works with a processor to perform the various steps or functions.

[0182] This invention can be implemented on a computer as a computer-based method, or in dedicated hardware, or a combination of both. Executable code or portions thereof for the method according to the invention can be stored on a computer program product. Examples of computer program products include memory devices, optical storage devices, integrated circuits, servers, online software, etc. Optionally, the computer program product includes non-transitory program code components stored on a computer-readable medium so as to execute the method according to the invention when the program product is executed on a computer.

[0183] In an optional embodiment, the computer program includes computer program code components adapted to perform all the steps of the method according to the invention when the computer program is run on a computer. Optionally, the computer program is embodied on a computer-readable medium.

[0184] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of the present invention is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0185] Of course, the present invention may have other various embodiments. Without departing from the spirit and essence of the present invention, those skilled in the art can make various corresponding changes and modifications according to the present invention, but these corresponding changes and modifications should all fall within the protection scope of the appended claims.

Claims

1. A module-aware hybrid precision inference method for machine learning inter-atomic potential energy models, characterized in that, The method includes: The baseline analysis step performs full-precision inference on the machine learning interatomic potential energy model to obtain the baseline of physical quantities and the operational characteristics of candidate modules; The strategy generation step generates a mixed-precision strategy for the candidate module based on the operational characteristics and the impact of candidate execution paths on the prediction error. The dynamic inference step involves selecting an actual execution path from the candidate execution paths based on the mixed precision strategy and the current module's operating conditions among the candidate modules, thereby obtaining the mixed precision inference result. The closed-loop verification step verifies the hybrid precision inference result based on the physical quantity baseline, and updates the hybrid precision strategy based on the precision and performance verification results.

2. The method according to claim 1, characterized in that, The physical quantity baselines include energy baselines, force baselines, and / or stress baselines; The candidate modules include a multilayer perceptron, a gated multilayer perceptron, a line graph attention module, an atomic graph attention module, an edge feature aggregation module, a node feature update module, a readout module, and / or an input gradient path; The operational characteristics include input shape, output shape, number of calls, time consumption percentage, weight range, and / or activation range.

3. The method according to claim 2, characterized in that, The candidate execution paths include the original full-precision path, the full-precision fused path, the low-precision path, and the low-precision fused path; The strategy generation step further includes: fusing continuous operators in the input gradient path related to force and stress calculation, and retaining full-precision calculation, full-precision accumulation, or full-precision backoff in the error-sensitive input gradient path.

4. The method according to claim 3, characterized in that, Before executing the low-precision fusion path in the dynamic inference step, the device location, number of input rows, hidden dimensions, quantization scale, and / or graphics processor expansion availability of the current module are checked. The runtime check results are expressed as follows: in, Indicates the candidate module index. Indicates the device where the current tensor resides. Indicates the current line number of the input. Indicates the hidden dimension. This represents the set of hidden dimensions supported by the fusion operator. Indicates the quantization scale or block-level quantization scale. Indicates whether the corresponding graphics processor extension is available; when When, it is determined that the current module meets the operating conditions of the low-precision fusion path; when When this occurs, it indicates that the current module does not execute the low-precision fusion path and needs to fall back to the full-precision fusion path or the original full-precision path according to the subsequent path selection rules.

5. The method according to claim 4, characterized in that, In the strategy generation step, the energy error increment, force error increment, stress error increment, and local output or input gradient error relative to the physical quantity baseline are obtained when the current module adopts the full-precision fusion path and the low-precision fusion path, respectively. The error sensitivity score of the current module for each of the candidate execution paths is determined according to the following formula: in, , , and These represent the energy error increment, force error increment, stress error increment, and local output or input gradient error corresponding to the current module, respectively. and These represent the corresponding error thresholds; When the error sensitivity score meets a preset condition, the corresponding candidate execution path is determined as an available candidate path, where the preset condition is B. m ≤1; wherein, the available candidate path is the full-precision fusion path or the low-precision fusion path, and the original full-precision path is used as a fallback path.

6. The method according to claim 5, characterized in that, In the dynamic inference step, the activation flag of the low-precision fusion path is determined based on the runtime check results, error sensitivity score, and / or the time consumption of different candidate execution paths: in, This indicates the time consumed by the current module using the low-precision fusion path. This indicates the time taken for the current module to use the full-precision fusion path; when When, select the low-precision fusion path; when If the full-precision fusion path is available, select the full-precision fusion path; otherwise, select the original full-precision path.

7. The method according to claim 1, characterized in that, The closed-loop verification steps include: Compare the module output and input gradients of the candidate execution paths with the corresponding results of the full-precision inference, and filter out the candidate execution paths whose local errors exceed a preset range; Perform end-to-end inference on the candidate execution paths that have passed local verification, and compare energy error, force error, stress error and / or inference time. The candidate execution paths that meet the error requirements and have performance benefits are written into the mixed precision strategy, and the candidate execution paths that exceed the error limit or have unstable performance benefits are set as fallback paths.

8. A module-aware hybrid precision inference device based on a machine learning interatomic potential energy model constructed according to any one of claims 1 to 7, characterized in that, The device includes: The baseline analysis module is used to perform full-precision inference on the machine learning interatomic potential energy model to obtain the physical quantity baseline and the operational characteristics of candidate modules; The strategy generation module is used to generate a mixed-precision strategy for the candidate module based on the running characteristics and the impact of the candidate execution paths on the prediction error. The dynamic inference module is used to select the actual execution path from the candidate execution paths based on the mixed precision strategy and the running conditions of the current module in the candidate modules, and obtain the mixed precision inference result. The closed-loop verification module is used to verify the hybrid precision inference result based on the physical quantity baseline, and update the hybrid precision strategy based on the precision and performance verification results.

9. A storage medium, characterized in that, Used to store a computer program for performing the method according to any one of claims 1 to 7.

10. An electronic device comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 7.