Search

CN-121998032-A - Model processing method, device, equipment, storage medium and computer program product

CN121998032ACN 121998032 ACN121998032 ACN 121998032ACN-121998032-A

Abstract

The application provides a model processing method, a device, equipment, a storage medium and a computer program product, wherein the method comprises the steps of determining an nth module from models to be migrated, wherein the nth module comprises at least one operator, n is a positive integer which is sequentially increased, adding the nth module into a model deployed in first hardware acceleration equipment to obtain a first model, adding the nth module into a model deployed in second hardware acceleration equipment to obtain a second model, performing model training on the first model to obtain a first model training result, performing model training on the second model to obtain a second model training result, determining a first precision difference between the first model and the second model based on the difference between the first model training result and the second model training result, and determining a target operator with abnormal precision from at least one operator contained in the nth module when the first precision difference is larger than a first preset threshold.

Inventors

  • DAI LINGJUN
  • ZHOU QIN

Assignees

  • 上海东方算芯科技有限公司

Dates

Publication Date
20260508
Application Date
20260402

Claims (12)

  1. 1. A method of model processing, the method comprising: Determining an nth module from a model to be migrated, wherein the nth module comprises at least one operator, and n is a positive integer which increases in sequence; adding the nth module to a model deployed in first hardware acceleration equipment to obtain a first model, and adding the nth module to a model deployed in second hardware acceleration equipment to obtain a second model; performing model training on the first model to obtain a first model training result, and performing model training on the second model to obtain a second model training result; Determining a first difference in accuracy between the first model and the second model based on a difference between the first model training result and the second model training result; And when the first precision difference is larger than a first preset threshold value, determining a target operator with abnormal precision from at least one operator contained in the nth module.
  2. 2. The method of claim 1, wherein adding the nth module to a model deployed in a first hardware acceleration device to obtain a first model, and adding the nth module to a model deployed in a second hardware acceleration device to obtain a second model, comprises: Determining the deployment mode of the nth module; Based on the deployment mode, adding the nth module into a model deployed in the first hardware acceleration equipment to obtain the first model; And adding the nth module to a model deployed in the second hardware acceleration equipment based on the deployment mode to obtain the second model.
  3. 3. The method according to claim 2, wherein adding the nth module to a model deployed in the first hardware acceleration device based on the deployment manner, to obtain the first model, includes: when the deployment mode is hardware accelerator deployment, deploying the nth module into a first hardware accelerator of the first hardware acceleration device; The first model is constructed based on the nth module deployed in the first hardware accelerator and a model deployed in the first hardware accelerator device.
  4. 4. The method according to claim 2, wherein adding the nth module to a model deployed in the first hardware acceleration device based on the deployment manner, to obtain the first model, includes: When the deployment mode is a general-purpose processor deployment mode, deploying the nth module into a first general-purpose processor of the first hardware acceleration device; The first model is constructed based on the nth module deployed in the first general-purpose processor and a model deployed in the first hardware acceleration device.
  5. 5. The method according to claim 4, wherein when the deployment mode is a general-purpose processor deployment, the determining, from at least one operator included in the nth module, a target operator with an abnormal precision includes: for the mth operator contained in the nth module, executing the following processing: Migrating the mth operator deployed in the first general processor of the first hardware acceleration device to the first hardware accelerator of the first hardware acceleration device to obtain a third model, wherein M is a positive integer which is sequentially increased, M is less than or equal to M, and M is the number of operators contained in the nth module; migrating the mth operator deployed in the second general processor of the second hardware acceleration device to a second hardware accelerator of the second hardware acceleration device to obtain a fourth model; performing model training on the third model to obtain a third model training result, and performing model training on the fourth model to obtain a fourth model training result; Determining a second difference in accuracy between the third model and the fourth model based on a difference between the third model training result and the fourth model training result; and when the second precision difference is larger than a second preset threshold value, determining the mth operator as the target operator.
  6. 6. The method according to claim 1, wherein the determining, from at least one operator included in the nth module, a target operator with an abnormal precision includes: for the mth operator contained in the nth module, executing the following processing: Determining historical input data and historical output data of the mth operator from the first model training result, wherein M is a positive integer which is sequentially increased, M is less than or equal to M, and M is the number of operators contained in the nth module; Processing the historical input data through the mth operator deployed on the second hardware acceleration device to obtain output data; And determining the mth operator as the target operator when the difference between the historical output data and the output data is greater than a difference threshold.
  7. 7. The method of claim 1, wherein determining an nth module from the model to be migrated comprises: Carrying out module splitting on the model to be migrated to obtain a plurality of modules; Performing precision exception prediction on each module to obtain a precision exception grade of the module, and performing detection priority assessment on the module based on the precision exception grade and the number of operators contained in the module to obtain the detection priority of the module; And sequencing the plurality of modules based on the detection priority of each module to obtain sequenced modules, and determining the nth module from the sequenced modules.
  8. 8. The method of claim 7, wherein the module splitting the model to be migrated to obtain a plurality of modules includes: Constructing a calculation graph of the model to be migrated, wherein nodes in the calculation graph are operators in the model to be migrated, and edges in the calculation graph are data flow dependency relations among the operators; Dividing the calculation graph based on a preset operator fusion rule to obtain a plurality of subgraphs, and determining the plurality of modules based on the plurality of subgraphs.
  9. 9. A model processing apparatus, characterized in that the apparatus comprises: The model disassembly module is used for determining an nth module from the model to be migrated, wherein the nth module comprises at least one operator, and n is a positive integer which increases in sequence; The model deployment module is used for adding the nth module to a model deployed in the first hardware acceleration equipment to obtain a first model, and adding the nth module to a model deployed in the second hardware acceleration equipment to obtain a second model; The model training module is used for carrying out model training on the first model to obtain a first model training result, and carrying out model training on the second model to obtain a second model training result; a difference determination module configured to determine a first difference in accuracy between the first model and the second model based on a difference between the first model training result and the second model training result; the difference determining module is further configured to determine, when the first precision difference is greater than a first preset threshold, a target operator with abnormal precision from at least one operator included in the nth module.
  10. 10. An electronic device, the electronic device comprising: A memory for storing computer executable instructions or computer programs; a processor for implementing the model processing method according to any one of claims 1 to 8 when executing computer-executable instructions or computer programs stored in the memory.
  11. 11. A computer-readable storage medium storing computer-executable instructions or a computer program, wherein the computer-executable instructions or the computer program when executed by a processor implement the model processing method of any one of claims 1 to 8.
  12. 12. A computer program product comprising computer executable instructions or a computer program, which when executed by a processor implements the model processing method of any of claims 1 to 8.

Description

Model processing method, device, equipment, storage medium and computer program product Technical Field The present application relates to the field of artificial intelligence, and in particular, to a model processing method, apparatus, device, storage medium, and computer program product. Background Artificial intelligence (AI, artificial Intelligence) is a theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, sense environment, acquire knowledge and use knowledge to obtain an optimal result, wherein deep learning is a core research field of machine learning based on an artificial neural network, and the core is that large-scale parallel computation is performed on hardware acceleration equipment through the neural network model to realize efficient training and reasoning. To fully exploit hardware performance and maintain technology advancement, it is often necessary to migrate a sophisticated neural network model from one hardware acceleration device to another. However, because of inherent differences of different hardware acceleration devices in bottom implementation, calculation logic and precision control, a phenomenon that training results are inconsistent often occurs after a model is migrated, and in a complex neural network model, small calculation errors caused by the hardware differences can be accumulated and amplified continuously along with a training iteration process, so that final problem investigation is extremely difficult, and related technologies generally face challenges of low positioning efficiency of precision anomaly problems. Disclosure of Invention The embodiment of the application provides a model processing method, a model processing device, model processing equipment, a model processing storage medium and a model processing computer program product, which can realize efficient operator-level precision anomaly problem positioning. The technical scheme of the embodiment of the application is realized as follows: the embodiment of the application provides a model processing method, which comprises the following steps: Determining an nth module from a model to be migrated, wherein the nth module comprises at least one operator, and n is a positive integer which increases in sequence; Adding the nth module to a model deployed in first hardware acceleration equipment to obtain a first model, and adding the nth module to a model deployed in second hardware acceleration equipment to obtain a second model; performing model training on the first model to obtain a first model training result, and performing model training on the second model to obtain a second model training result; Determining a first difference in accuracy between the first model and the second model based on a difference between the first model training result and the second model training result; And when the first precision difference is larger than a first preset threshold value, determining a target operator with abnormal precision from at least one operator contained in the nth module. The embodiment of the application provides a model processing device, which comprises: The model disassembly module is used for determining an nth module from the model to be migrated, wherein the nth module comprises at least one operator, and n is a positive integer which increases in sequence; The model deployment module is used for adding the nth module to a model deployed in the first hardware acceleration equipment to obtain a first model, and adding the nth module to a model deployed in the second hardware acceleration equipment to obtain a second model; The model training module is used for carrying out model training on the first model to obtain a first model training result, and carrying out model training on the second model to obtain a second model training result; a difference determination module configured to determine a first difference in accuracy between the first model and the second model based on a difference between the first model training result and the second model training result; the difference determining module is further configured to determine, when the first precision difference is greater than a first preset threshold, a target operator with abnormal precision from at least one operator included in the nth module. An embodiment of the present application provides an electronic device, including: A memory for storing computer executable instructions or computer programs; And the processor is used for realizing the model processing method provided by the embodiment of the application when executing the computer executable instructions or the computer programs stored in the memory. The embodiment of the application provides a computer readable storage medium, which stores a computer program or computer executable instructions for realizing the model processing method provided by th