Model migration method and device based on graphics processor environment, equipment and medium

CN122985241APending Publication Date: 2026-10-27CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611314874.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-27
Publication Date
2026-10-27

AI Technical Summary

Benefits of technology

[0010]有益效果:本发明涉及模型部署技术领域,公开了一种基于图形处理器环境的模型迁移方法、装置、设备及介质,包括:获取待迁移模型及相关配置、环境和验证数据;提取模型参数字典并依据目标图形处理器环境转换权重张量,生成目标模型参数字典;对目标模型参数字典进行标准化封装,结合配置文件形成标准模型目录结构;将标准模型目录结构转换为模型执行数据,并经验证生成模型迁移结果。本发明可应用于金融科技及医疗健康等业务场景中,通过转换权重张量、标准化模型参数并重构模型目录,使源端模型形成目标图形处理器环境可执行的模型数据,再经验证确认迁移结果,从而提升异构图形处理器之间模型迁移的兼容性和可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985241A_ABST
    Figure CN122985241A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of model deployment, and discloses a model migration method and device based on a graphics processor environment, equipment and a medium, which comprises the following steps: obtaining a to-be-migrated model and related configurations, environment and verification data; extracting a model parameter dictionary and converting a weight tensor according to a target graphics processor environment to generate a target model parameter dictionary; standardizing and packaging the target model parameter dictionary to form a standard model directory structure in combination with a configuration file; converting the standard model directory structure into model execution data, and generating a model migration result after verification. The application can be applied to business scenarios such as financial technology and medical health, and can convert a weight tensor, standardize model parameters and reconstruct a model directory, so that a source-end model forms model data executable in a target graphics processor environment, and the migration result is verified and confirmed, thereby improving the compatibility and reliability of model migration between heterogeneous graphics processors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model deployment technology, and in particular to a model migration method, apparatus, device, and medium based on a graphics processor environment. Background Technology

[0002] As the demand for training and deploying large models in different graphics processing unit (GPU) environments continues to increase, the architectural differences between the model training environment and the target deployment environment are gradually becoming a major obstacle in model application. Existing models are usually saved according to the model framework, weight tensor data type, parameter organization method, and model file format corresponding to the source GPU environment. When the model is migrated to a heterogeneous GPU environment, the original model file is difficult to directly convert into model data that can be loaded and executed in the target environment, which makes it impossible for existing large models to successfully complete cross-GPU migration.

[0003] In the fintech sector, large-scale models have been applied to scenarios such as intelligent risk control, fraud detection, credit review, insurance claims, intelligent customer service, and financial text analysis. When financial institutions migrate existing large-scale models from overseas graphics processing unit (GPU) environments to domestic GPU environments, the source model weights, model configurations, and word segmentation configurations are often not directly recognizable by the target model framework. Existing methods struggle to create executable models consistent with the target GPU environment, becoming a major technical obstacle in the localization and deployment of large-scale financial models.

[0004] In the healthcare sector, large-scale models have been applied to scenarios such as electronic medical record analysis, medical text processing, clinical auxiliary analysis, and health consultation. These models typically have complex structures and large-scale weighted data. When existing models are migrated to graphics processor environments with different architectures, the lack of a unified conversion and verification basis between the source model files and the target model framework can easily cause the migrated model to fail to load and execute properly in the target graphics processor environment, thus limiting the continuous deployment of large-scale healthcare models in heterogeneous computing environments. Summary of the Invention

[0005] The main objective of this invention is to provide a model migration method, apparatus, device, and storage medium based on a graphics processor environment, aiming to solve the technical problem that the lack of a unified model migration method for heterogeneous graphics processor environments in the prior art makes it difficult to convert large source models into model data that can be directly loaded and executed in the target graphics processor environment.

[0006] To achieve the above objectives, the present invention provides a model transfer method based on a graphics processor environment, comprising: Obtain the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and validation data; Based on the model configuration data, the model loading interface is called to load the model to be migrated, and a model parameter dictionary including parameter names and weight tensors corresponding to the parameter names is extracted from the loaded model to be migrated. Based on the target graphics processor environment data, the weight tensors in the model parameter dictionary are transformed to generate the target weight tensor, and the target model parameter dictionary is generated according to the correspondence between the parameter names and the target weight tensor. Based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data, the target model parameter dictionary is standardized and encapsulated into a secure tensor model file containing a model format identifier; Based on the model configuration data and the word segmenter configuration data, a standard model configuration file and a word segmenter configuration file are generated respectively. The security tensor model file, the standard model configuration file, and the word segmenter configuration file are combined into a standard model directory structure. Based on the target graphics processor environment data and the model format identifier, the standard model directory structure is converted into model execution data, and the model execution data is verified based on the verification data to generate model migration results.

[0007] Furthermore, to achieve the above objectives, the present invention provides a model transfer apparatus based on a graphics processor environment, comprising: The migration data acquisition module is used to acquire the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and verification data. The model parameter extraction module is used to call the model loading interface based on the model configuration data to load the model to be migrated, and extract a model parameter dictionary including parameter names and weight tensors corresponding to the parameter names from the loaded model to be migrated; The weight tensor conversion module is used to convert the weight tensors in the model parameter dictionary based on the target graphics processor environment data, generate the target weight tensor, and generate the target model parameter dictionary according to the correspondence between the parameter names and the target weight tensor. The secure tensor encapsulation module is used to standardize and encapsulate the target model parameter dictionary into a secure tensor model file containing a model format identifier based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data. The model directory construction module is used to generate a standard model configuration file and a word segmenter configuration file based on the model configuration data and the word segmenter configuration data, respectively, and combine the security tensor model file, the standard model configuration file and the word segmenter configuration file into a standard model directory structure; The model migration verification module is used to convert the standard model directory structure into model execution data based on the target graphics processor environment data and the model format identifier, and to verify the model execution data based on the verification data to generate model migration results.

[0008] Furthermore, to achieve the above objectives, the present invention also provides a computer device, the computer device including a memory, a processor, and a model migration program based on a graphics processor environment stored in the memory and executable on the processor, wherein when the model migration program based on the graphics processor environment is executed by the processor, it implements the steps of the model migration method based on the graphics processor environment as described above.

[0009] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a model migration program based on a graphics processor environment, wherein when the model migration program based on the graphics processor environment is executed by a processor, it implements the steps of the model migration method based on the graphics processor environment as described above.

[0010] Beneficial Effects: This invention relates to the field of model deployment technology and discloses a model migration method, apparatus, device, and medium based on a graphics processor environment. The method includes: acquiring the model to be migrated and its related configuration, environment, and verification data; extracting a model parameter dictionary and transforming the weight tensor according to the target graphics processor environment to generate a target model parameter dictionary; standardizing and encapsulating the target model parameter dictionary and combining it with a configuration file to form a standard model directory structure; converting the standard model directory structure into model execution data and verifying it to generate model migration results. This invention can be applied to business scenarios such as fintech and healthcare. By transforming weight tensors, standardizing model parameters, and reconstructing the model directory, the source model can be transformed into executable model data for the target graphics processor environment. The migration results are then verified, thereby improving the compatibility and reliability of model migration between heterogeneous graphics processors. Attached Figure Description

[0011] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 This is a schematic diagram of an application environment for a model transfer method based on a graphics processor environment according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating an embodiment of the model transfer method based on a graphics processor environment according to the present invention. Figure 3 for Figure 2 A detailed flowchart of step S10; Figure 4 for Figure 2 A detailed flowchart of step S20; Figure 5 for Figure 2 A detailed flowchart of step S30; Figure 6 for Figure 2 A detailed flowchart of step S40; Figure 7 for Figure 2 A detailed flowchart of step S50; Figure 8 for Figure 2 A detailed flowchart of step S60; Figure 9 This is a schematic diagram of the functional modules of a preferred embodiment of the model transfer device based on a graphics processor environment of the present invention; Figure 10 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 11 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation

[0012] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.

[0013] The model transfer method based on a graphics processor environment provided in this embodiment of the invention can be applied to, for example... Figure 1 In this application environment, the client communicates with the server via a network. The server can obtain the model to be migrated, its related configuration, environment, and verification data from the client; extract the model parameter dictionary and transform the weight tensor according to the target graphics processor environment to generate the target model parameter dictionary; standardize and encapsulate the target model parameter dictionary, combining it with configuration files to form a standard model directory structure; convert the standard model directory structure into model execution data, and generate the model migration result after verification. This invention can be applied to business scenarios such as fintech and healthcare. By transforming the weight tensor, standardizing model parameters, and reconstructing the model directory, the source model is made into model data executable by the target graphics processor environment, and the migration result is verified, thereby improving the compatibility and reliability of model migration between heterogeneous graphics processors. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will be described in detail below through specific embodiments.

[0014] Please see Figure 2 , Figure 2This is a flowchart illustrating an embodiment of the model transfer method based on a graphics processor environment provided by the present invention. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0015] like Figure 2 As shown, the model transfer method based on the graphics processor environment proposed in this invention includes the following steps: S10: Obtain the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and verification data; In this embodiment, regarding the model migration task, model weight files are read from the model storage directory, object storage space, or model repository, and the model to be migrated is determined based on the model identifier, version information, shard index, and file checksum. The model to be migrated may consist of a single weight file, multiple weight shards, or model checkpoints; when multiple weight shards are used together, the parameter range corresponding to each shard is checked according to the shard index to avoid omission or mixing in other model versions.

[0016] Model configuration data is read from the structure configuration file or model configuration object, including model hierarchy data, attention structure data, hidden dimension data, and data type information. Tokenizer configuration data is read from the tokenizer configuration file, vocabulary file, or serialized tokenizer object, including segmentation methods, special tags, and tag mapping relationships. The correspondence between the model to be transferred, the model configuration data, and the tokenizer configuration data is verified using the model version identifier, configuration version identifier, and vocabulary size.

[0017] Source graphics processor (GPU) environment data is collected from source-side device interfaces, model framework runtime information, and software component lists, including processor architecture, model framework, supported data types, and model storage formats. Target GPU environment data is collected from target-side resource interfaces, framework configuration files, and operator support lists, including processor architecture, training framework, inference framework, supported data types, operator range, and model storage format requirements. Validation data is read from validation sets, anonymized business data, or structured test data, including validation input data and validation output structure data consistent with the model task type. All types of data are associated using the same migration task identifier, and the data source location, version information, and validation results are recorded.

[0018] When model files are stored in a local directory, directory scanning and file list comparison are used to locate weight files, configuration files, word segmenter files and validation data. The file correspondence is confirmed by file name, version information, fragment index and check value. An environmental information acquisition program is used to read the processor architecture, framework version, data type support range and storage format requirements of the source and target ends, and the reading results are written to the same migration task record.

[0019] When model files are distributed across object storage, model repositories, and container environments, the system uses the object storage interface to read weight shards, the model repository interface to read model configuration data and tokenizer configuration data, the container environment interface to read source framework information, and the resource management interface to read target graphics processor environment data. For cases where multiple model versions coexist, inconsistent data combinations are filtered out based on the correspondence between model version, configuration version, and tokenizer version.

[0020] In the fintech business, for anti-fraud identification models, the weight shards, structure configurations and financial terms of transaction behavior models are read from the model repository. Processor architecture, framework version, data type and model storage format requirements are collected from the source and domestic graphics processor environments, respectively. De-identified transaction sequences and risk output structures are read from the controlled directory.

[0021] In the field of healthcare business, for the medical text analysis model in the health management platform, the model weight file is read from object storage, the model structure data and medical terminology segmentation data are read from the configuration directory, the processor and framework information are collected from the source and target interfaces, and the health consultation text, examination description and corresponding output structure are read from the de-identified dataset.

[0022] This embodiment reduces data preparation errors caused by missing model files, misconfigured configurations, and incomplete environmental information by uniformly obtaining model weights, model structure information, word segmentation configurations, source environment information, target environment information, and verification criteria, and by verifying file integrity, version consistency, and data correspondence.

[0023] S20, based on the model configuration data, call the model loading interface to load the model to be migrated, and extract the model parameter dictionary including parameter names and weight tensors corresponding to the parameter names from the loaded model to be migrated; In this embodiment, the model type, number of layers, hidden dimensions, attention structure, parameter data type, and parameter sharing relationships in the model configuration data are used to form the model loading parameters. The model loading parameters determine the model structure to be created, the position of parameters in each layer, and the weight reading method, enabling model weights to be written to the structural positions corresponding to the parameter names. The model configuration data can originate from structured configuration files or configuration objects in the model storage directory, and after reading, it is converted into a parameter format recognizable by the model loading interface according to field identifiers.

[0024] The model loading interface can use the loading interface provided by the model framework, or it can use the encapsulated model structure creation interface and weight reading interface. The interface creates an in-memory model structure based on the model loading parameters, reads a single weight file or multiple weight slices from the model to be migrated, and writes each weight to the corresponding parameter position according to the weight index. For models stored in slices, the weight slices can be read one by one according to the slice index, and the loading is completed after verifying the parameter name, tensor dimension, and data type. The loaded model to be migrated contains the established model hierarchy and the weight data filled in each parameter position.

[0025] Parameter names can be formed by combining the hierarchical path, layer identifier, and parameter type in the model structure, used to distinguish weights, biases, and normalized parameters in different layers. The weight tensor is a multi-dimensional set of values ​​stored in the parameter location, containing tensor values, tensor dimensions, and data type information. By recursively accessing parameter items in the model structure, the parameter name and corresponding weight tensor are read from each parameter item and written into a key-value structure in hierarchical order, where the parameter name serves as the key and the weight tensor as the value, thus forming the model parameter dictionary. For shared parameters, the reference relationship between shared parameter names and the same weight tensor can be preserved to avoid duplicate copying of weight data.

[0026] When the model to be migrated is stored in a single weight file, a complete model structure is created using model configuration data. The weight file path and data type parameters are passed to the model loading interface, which reads the weight data one by one and writes it to each parameter location. After the model is loaded, the parameter items are accessed sequentially according to the model hierarchy, and the parameter names and weight tensors are written to an ordered key-value structure.

[0027] When the model to be migrated is stored using multiple weight shards, a shard index is used to determine the parameter range contained in each weight shard. The weight shards are read one by one according to the model hierarchy, and the read weight data is written to the corresponding parameter location. In environments with limited available memory, the corresponding temporary data can be released after the parameters are extracted from one weight shard before reading the next weight shard. Finally, the key-value records formed by merging the shards according to the parameter name and model hierarchy are merged.

[0028] In the fintech business, for anti-fraud models that take transaction sequences, account status, and risk event text as input and output risk categories, the number of layers, hidden dimensions, and attention structure are read from the model configuration data. The corresponding weight slices are loaded by calling the model loading interface. Then, the parameter names and weight tensors of each attention layer, feedforward layer, and output layer are extracted to form a model parameter dictionary.

[0029] In the healthcare business field, for medical text analysis models that take health consultation texts and examination descriptions as inputs and output health risk classification results, a text encoding layer, an attention layer, and a classification output layer are created based on the model configuration data. The weight data in the model to be transferred is loaded, and the parameter names and corresponding weight tensors of each layer are extracted from the loaded model to form a model parameter dictionary.

[0030] This embodiment creates a model structure consistent with the model to be migrated through model configuration data, and uses the model loading interface to write weight data into the corresponding parameter positions, which can ensure that the parameter names and weight tensors have a clear correspondence; by traversing the model structure to form a model parameter dictionary, the problems of missing weight fragments, mismatched parameter positions, and unrecognizable parameter names can be reduced.

[0031] S30, based on the target graphics processor environment data, transform the weight tensor in the model parameter dictionary to generate a target weight tensor, and generate a target model parameter dictionary according to the correspondence between the parameter name and the target weight tensor; In this embodiment, the target data type, supported precision range, storage alignment requirements, and available storage capacity in the target graphics processor environment data are used to determine the transformation parameters of the weight tensors. The parameter names, weight tensors, current data types, and tensor dimensions are read from the model parameter dictionary. A transformation record corresponding to the parameter name is created for each weight tensor, maintaining the association between the transformation object, the target data type, and the tensor structure.

[0032] Weight tensors can be transferred to host storage for data type conversion, or they can be directly converted if both the source and target sides support the corresponding conversion operation. When converting from a high-precision data type to a low-precision data type, tensor values ​​are rounded, overflow is checked, and abnormal values ​​are checked. If the data types are the same, the tensor values ​​are retained, and a new tensor object conforming to the target storage requirements is constructed. The converted numerical data is used to construct the target weight tensor according to the original tensor dimensions and their order.

[0033] Parameter names and target weight tensors are written into the target parameter record in a one-to-one correspondence. Then, the target parameter records are combined according to the parameter order in the model parameter dictionary to form the target model parameter dictionary. When parameter sharing exists, the reference relationship between multiple parameter names and the same target weight tensor is retained to reduce redundant storage and maintain the original parameter association.

[0034] When the host storage capacity can accommodate all weight tensors, the weight tensors in the model parameter dictionary are transferred to the host storage space in batch read mode. The conversion is completed item by item according to the data type supported by the target graphics processor. The target weight tensor is constructed according to the original tensor dimensions and written into the target model parameter dictionary according to the parameter arrangement order.

[0035] When the model size exceeds the available host storage capacity, a hierarchical or block-based transformation method is used to read the weight tensors. Each time, one model level or one tensor data block is read, data type conversion and target weight tensor construction are completed, and the target parameter record is written to it, while the corresponding temporary data is released. After all parameter records are completed, the target model parameter dictionary is formed by combining the parameter names and their order.

[0036] In the field of fintech business, for large models used for transaction risk identification, the weight tensors of the attention layer, feedforward layer and classification output layer are converted into target data types according to the data types supported by domestic graphics processors. The correspondence between each parameter name and the target weight tensor is preserved, and a target model parameter dictionary is formed according to the original parameter hierarchy.

[0037] In the healthcare business, for health consultation text analysis models, in an environment with limited host storage capacity, the weight tensors are read in batches according to the model hierarchy. The weights of the text encoding layer, attention layer and risk classification layer are converted into target data types. The target weight tensor is constructed based on the original tensor dimensions and combined to form the target model parameter dictionary.

[0038] This embodiment determines the data type and storage requirements of the weight tensor based on the target graphics processor environment, and maintains the correspondence between parameter names, tensor dimensions, and parameter arrangement order. This reduces conversion errors caused by unsupported weight data types, tensor structure changes, and parameter mapping misalignments, ensuring that the target model parameter dictionary is consistent with the weight representation requirements of the target graphics processor.

[0039] S40, based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data, the target model parameter dictionary is standardized and encapsulated into a secure tensor model file containing a model format identifier; In this embodiment, the source model framework data and source model storage format data in the source graphics processor environment data are used to identify the parameter naming method, parameter hierarchical organization method, and tensor arrangement method. The target training framework data, target inference framework data, and target model storage format requirements in the target graphics processor environment data are used to determine the parameter names, tensor dimension order, parameter arrangement order, and file organization format that the target can recognize. The model hierarchy data, attention structure data, and hidden dimension data in the model configuration data are used to locate the position of each parameter in the model structure, avoiding incorrect mapping of weight tensors with similar names.

[0040] Based on the differences between the two frameworks, a parameter transformation relationship is established. The parameter names in the target model parameter dictionary are converted to the target-side naming format. The tensor dimension order is adjusted according to the target-side tensor reading method, and the parameter records are rearranged according to the model hierarchy. The standardization process retains the numerical content of the target weight tensor and the parameter correspondence, and only unifies the parameter identification, dimension organization, and hierarchical arrangement to form a standardized model parameter dictionary.

[0041] The secure tensor model file consists of metadata header data and binary tensor data. The metadata header data records the parameter names, data types, tensor dimensions, and tensor data locations. The binary tensor data is organized into target weight tensors consecutively according to the parameter arrangement order. The model format identifier is generated based on the target training framework, target inference framework, and target model storage format requirements, and is written into the metadata header data to indicate the parameter organization form used in the file and the applicable target framework type.

[0042] When the target model parameter dictionary can be loaded into the host storage space as a whole, the parameter name, tensor dimension order and parameter level position are adjusted item by item using a parameter mapping table. All standardized parameters are then written into the metadata header data and binary tensor data to form a single secure tensor model file.

[0043] When the size of the target model parameter dictionary exceeds the available host storage capacity, a layered encapsulation method is adopted to read the target parameter records sequentially according to the model level. After completing the parameter name conversion and tensor dimension adjustment, the parameters are written to the temporary tensor area, and the parameter data position is recorded cumulatively. After all parameters are written, metadata header data is generated and combined with the temporary tensor area to form a secure tensor model file.

[0044] When the target training framework and inference framework use different parameter naming formats, a model format that includes both training framework identifiers and inference framework identifiers is used to identify the scope of application of the record file, and a standardized model parameter dictionary is compiled based on parameter naming formats that can be recognized by both types of frameworks.

[0045] In the field of fintech business, for transaction risk identification models, the parameter names in the target model parameter dictionary can be converted into names that can be recognized by domestic graphics processor inference frameworks, based on the naming method of the attention layer and classification layer in the source framework. The order of the weight tensor dimensions can be adjusted, and the weights of each layer of the risk identification model can be encapsulated into a secure tensor model file containing model format identifiers.

[0046] In the field of healthcare business, for health consultation text analysis models, the parameter levels of the text encoding layer, attention layer and risk classification layer can be determined based on the model configuration data. The parameters of each layer are rearranged according to the requirements of the target framework, and the standardized weights and corresponding metadata of the medical text model are encapsulated into a secure tensor model file.

[0047] This embodiment unifies parameter names, tensor dimension order, and parameter hierarchy by combining the source-side parameter organization method, target-side model storage requirements, and model structure information. It also encapsulates standardized parameters into secure tensor model files containing explicit metadata and model format identifiers, which can reduce parameter identification errors caused by inconsistencies in parameter naming, tensor arrangement, and file format between heterogeneous frameworks.

[0048] S50, Based on the model configuration data and the word segmenter configuration data, a standard model configuration file and a word segmenter configuration file are generated respectively, and the security tensor model file, the standard model configuration file and the word segmenter configuration file are combined into a standard model directory structure; In this embodiment, the model hierarchy, attention structure, hidden dimensions, data types, and model categories in the model configuration data are written into structured configuration content according to preset field names and field levels. Numeric types, Boolean types, and array types are standardized to generate a standard model configuration file. The standard model configuration file can be a structured text file or a binary configuration file, and its content corresponds to the model structure in the secure tensor model file.

[0049] The segmentation method, special tags, tag mapping relationships, and vocabulary reference information in the segmenter configuration data are written to the segmenter configuration file in a unified field format. Special tags include text start tags, text end tags, padding tags, and unknown tags. The tag mapping relationship records the correspondence between each special tag and its value, avoiding version mismatches between the segmenter configuration and the model configuration.

[0050] The directory locations of the security tensor model file, standard model configuration file, and word segmenter configuration file are configured according to file type and file name. The directory locations can be located in the same model directory, or they can be divided into subdirectories according to the weight file, model configuration file, and word segmenter configuration file, and the file names and storage paths are recorded through the directory index, thus forming the standard model directory structure.

[0051] When the number of model files is small and a single directory is convenient for management, a flat directory structure is used to organize the security tensor model files, standard model configuration files, and word segmenter configuration files. The model configuration data and word segmenter configuration data are serialized into structured text files respectively. The three files are written to the same directory with fixed file names, and a directory index is generated that records the file names and file types.

[0052] When the security tensor model file consists of multiple files, a hierarchical directory structure is used to organize the various types of files. The weight file is written to the weight subdirectory, the standard model configuration file is written to the configuration subdirectory, and the word segmenter configuration file and vocabulary file are written to the word segmentation subdirectory. The directory index records the relative path, version information, and file checksum of each file, which is used to identify all files corresponding to the same model version.

[0053] In the fintech business, for the transaction risk identification model, the model hierarchy, attention structure and data type are written into the standard model configuration file, and the transaction terms, risk event tags and special tags are mapped into the word segmenter configuration file, and written into the transaction risk model directory together with the security tensor model file.

[0054] In the healthcare business field, for the health consultation text analysis model, the text encoding layer, attention layer and classification layer configurations are written into the standard model configuration file, and the medical term tags, examination item tags and special tags are mapped into the word segmenter configuration file, and organized with the security tensor model file according to weight, configuration and word segmentation directory.

[0055] This embodiment unifies the model configuration fields and word segmentation configuration fields, and organizes the model weights and configuration files according to clear file types, file names and directory locations. This can reduce model file recognition errors caused by differences in configuration fields, missing files and chaotic directory locations, and keep the model weights, model structure configuration and word segmentation configuration consistent.

[0056] S60, based on the target graphics processor environment data and the model format identifier, the standard model directory structure is converted into model execution data, and the model execution data is verified based on the verification data to generate model migration results.

[0057] In this embodiment, the processor architecture, target inference framework, operator support range, data type, and storage capacity in the target graphics processor environment data are used to determine the model conversion method. The model format identifier is used to identify the metadata structure, weight arrangement, and parameter organization of the secure tensor model file, and to establish a correspondence with the standard model configuration file and the word segmenter configuration file.

[0058] The model is parsed according to the standard model directory structure, reading the model hierarchy, parameter names, weight tensors, and word segmentation configuration. The model structure is then established, and weight tensors are bound to their corresponding parameter positions. Based on the target inference framework and operator support range, the operators in the model structure are converted to operators supported by the target graphics processor. A computation graph is constructed according to the operator connections, and then, combined with the target processor architecture, storage configuration, and data type, model execution data is generated. Model execution data may include the compiled computation graph, weight reference information, storage allocation information, and runtime configuration.

[0059] The validation input data in the validation data is converted into model input data through word segmentation configuration. After the model execution data is loaded into the target graphics processor, target output data and running status data are generated. The number of tensors, tensor dimensions, and output fields of the target output data are compared with the validation output structure data. At the same time, the model loading status, operator running status, and anomaly information are checked to form a model migration result that includes migration status, structure comparison results, and anomaly locations.

[0060] When the target inference framework supports offline compilation, a pre-compilation method is used to parse the standard model directory structure, convert model operators into target operators, and generate offline model files. Weight tensors are written to the offline model files according to their parameter positions or external weight references are created. The offline model files and runtime configuration together constitute the model execution data. During verification, the model execution data is loaded into the target graphics processor once, and inference and output structure comparison are performed according to the verification data.

[0061] When the target inference framework supports dynamic graph loading, a runtime construction method is used to read the standard model configuration file, create the model structure, and load the weight data from the security tensor model file. The computation graph is then built layer by layer according to the range supported by the target operators. When encountering model operators that are not directly supported, multiple target operators supported by the target inference framework are combined to form equivalent computation nodes, and then model execution data is generated and verification is completed.

[0062] In the fintech business, for transaction anti-fraud models, the standard model directory structure is converted into model execution data supported by domestic graphics processing units (GPUs). The verification input data includes anonymized transaction sequences, account status, and risk event text. The verification output structure data includes the number of risk categories, the dimensions of the risk score tensor, and output fields. The model migration results record the model loading status, output structure comparison results, and the location of abnormal operators.

[0063] In the healthcare business field, for medical text analysis models in health management platforms, the text encoding layer, attention layer, and classification layer are converted into computational graphs supported by the target graphics processor. The input data is verified to include de-identified health consultation texts and examination descriptions, and the output structure data is verified to include health risk categories and output vector dimensions. Based on this, model transfer results are generated.

[0064] This embodiment accurately parses model files by identifying model formats, and completes operator conversion, weight binding, and computation graph construction in conjunction with the target graphics processor environment, so that the standard model directory structure forms model execution data that can be loaded on the target end. Then, by comparing the verification input, verification output structure, and running status, it can identify model loading failures, unsupported operators, and abnormal output structures, thereby improving the accuracy and verifiability of heterogeneous graphics processor migration results.

[0065] In one embodiment, such as Figure 3 As shown, step S10 above includes: S101, Receive the model migration task, read the source model directory location, source environment identifier, target environment identifier and verification data storage location from the model migration task, and generate migration resource index data; S102, based on the source model directory location in the migration resource index data, locate the model weight file, model configuration file and word segmentation configuration file, and determine the model weight file as the model to be migrated; S103, extract model hierarchical data, attention structure data, hidden dimension data and data type information from the model configuration file to obtain model configuration data; S104, Extract the segmentation method, special tags and tag mapping relationship from the segmentation configuration file to obtain the segmenter configuration data; S105, from the source graphics processor environment corresponding to the source environment identifier in the migration resource index data, collect source processor architecture data, source model framework data, source data type and source model storage format data to obtain source graphics processor environment data; S106, collect target processor architecture data, target training framework data, target inference framework data, target data type, target operator support data and target model storage format requirements from the target graphics processor environment corresponding to the target environment identifier in the migration resource index data to obtain target graphics processor environment data; S107, Based on the verification data storage location in the migration resource index data, read the verification input data and verification output structure data corresponding to the model to be migrated to obtain the verification data.

[0066] In this embodiment, the model migration task is generated by a task scheduling interface, configuration file, or task message. The task content includes at least the source model directory location, source environment identifier, target environment identifier, and verification data storage location. Upon receiving the model migration task, integrity and data format checks are performed on the task fields to confirm that the directory location is accessible, the environment identifier uniquely points to the runtime environment, and the verification data storage location can locate the verification file. The source model directory location is used to limit the search scope of model files, the source and target environment identifiers are used to distinguish between the migration-out and migration-in environments, and the verification data storage location is used to locate the data required for migration result verification. The fields are associated according to the task identifier to generate migration resource index data. The migration resource index data can be stored in the form of key-value records, structured data objects, or index tables, recording the location, identifier, version, and access status of various resources.

[0067] Based on the source model directory location in the migration resource index data, the directory contents are scanned. Model weight files, model configuration files, and word segmentation configuration files are identified by file name, file type, configuration tags, and shard index. Model weight files store model parameters and can consist of a single weight file or multiple weight shards. When using shard storage, the number of shards, parameter range, and file order are checked according to the shard index, and all weight shards under the same model version are considered as the model to be migrated. Model configuration files record model structure information, and word segmentation configuration files record text tag conversion information. During file identification, file checksums, model version identifiers, and modification times are also checked to rule out missing files, duplicate shards, or mixed versions.

[0068] The model configuration file is used to read model layer data, attention structure data, hidden dimension data, and data type information. Model layer data indicates the number of model layers, their order, and layer type; attention structure data indicates the number of attention heads, query key-value structure, and parameter sharing method; hidden dimension data indicates the dimensions of feature vectors in each layer and the dimensions of intermediate layers; and data type information indicates the numerical precision used for the weight tensors. During the reading process, each field is located according to the field path in the configuration file, and type conversions are performed for strings, integers, booleans, and arrays. The data relationships between model layer, hidden dimensions, and the number of attention heads are checked to form the model configuration data.

[0069] The segmentation method, special tags, and tag mapping relationships are read from the segmentation configuration file. The segmentation method determines whether the text is divided into character, word, sub-word, or byte units; special tags include start tags, end tags, padding tags, and unknown tags; the tag mapping relationship records the mapping between text units or special tags and numerical identifiers. When the segmentation configuration file consists of multiple files, the main segmenter configuration, vocabulary file, and special tag file are read, and the contents are merged according to the segmenter version and vocabulary size to form the segmenter configuration data.

[0070] The source graphics processor environment is accessed based on the source environment identifier. Source processor architecture data is read through the device information interface, source model framework data and source data types are read through the model framework interface, and source model storage format data is read through model directory information or weight file metadata. Source processor architecture data may include processor model, number of devices, and storage capacity; source model framework data may include framework type, framework version, and runtime component version; source data types record the tensor precision supported by the source environment and used by the model to be migrated; source model storage format data records the encapsulation form, fragmentation form, and parameter organization method of the weight file. The collected results are combined according to the source environment identifier to form the source graphics processor environment data.

[0071] Access the target graphics processor environment based on the target environment identifier. Read the target processor architecture data through the resource management interface, the target training framework data and target inference framework data through the framework configuration interface, the target data type and target operator support data through device capability information, and the target model storage format requirements through model loading configuration. Target operator support data can be a list of operators consisting of operator name, operator version, input / output data type, and tensor dimension requirements; target model storage format requirements can include file type, parameter naming requirements, tensor arrangement requirements, and file organization requirements. Version association is performed on the device information, framework information, and format requirements in the target environment to form the target graphics processor environment data.

[0072] The verification input data and verification output structure data are read based on the verification data storage location in the migration resource index data. Verification input data may include text, tokenized sequences, or structured input, and must be consistent with the task type and word segmentation configuration of the model to be migrated. Verification output structure data records the output fields, number of output tensors, tensor dimensions, and data types. After reading the verification file, the model identifier, version identifier, and input format in the verification data are checked. Data that does not match the model to be migrated is excluded, and the qualified verification input data and verification output structure data are combined into the verification data.

[0073] This embodiment uses a model migration task to uniformly record the location of model files, the environmental identifiers at both ends, and the location of validation data. It also locates, reads, collects, and associates the model weight files, configuration files, word segmentation files, source environment information, target environment information, and validation data with versions. This can reduce data preparation deviations caused by missing model files, mixed use of weight fragments, mismatched configuration versions, and incomplete environment information, and ensure that the model to be migrated and related data maintain a clear and consistent correspondence.

[0074] In one embodiment, such as Figure 4 As shown, step S20 above includes: S201, Read the model hierarchy data, attention structure data, hidden dimension data and data type information from the model configuration data to obtain the model loading parameters; S202, Generate a model loading request based on the model loading parameters, including model structure parameters, data type parameters, and weight reading parameters; S203, the model loading request is sent to the model loading interface, the model structure is constructed according to the model loading request through the model loading interface, the model weight data is read from the model to be migrated, and the model weight data is loaded into the parameter position in the model structure to obtain the loaded model to be migrated; S204, traverse the parameter items in the loaded model to be transferred, extract the parameter name and weight tensor from each parameter item, determine the hierarchical position of each parameter item in the model structure based on the model structure and the parameter name, and write the parameter name, the weight tensor and the hierarchical position into the parameter record accordingly to generate a parameter record set; S205, traverse the parameter record set according to the hierarchical position, write the parameter name and weight tensor in each parameter record into the key-value structure, and generate the model parameter dictionary.

[0075] In this embodiment, the model hierarchy data in the model configuration data is used to determine the number of layers, layer types, and hierarchical arrangement of the model; the attention structure data is used to determine the number of attention heads, query parameters, key parameters, and value parameters; the hidden dimension data is used to determine the dimensions of the input / output tensors and intermediate feature tensors of each layer; and the data type information is used to determine the numerical precision used for the model parameters. After reading all the data, the field names, field types, and field levels are converted according to the model loading interface requirements to obtain model loading parameters that describe the model structure and weight reading method.

[0076] Model structure parameters are generated by combining model hierarchical data, attention structure data, and hidden dimension data. They describe the nodes, node connections, and parameter slots in each layer of the model to be built. Data type parameters are generated based on data type information and specify the tensor precision after the weight data is loaded. Weight read parameters record the file location, shard index, parameter read order, and storage format of the model to be transferred. Writing these three types of parameters into the same request object generates a model loading request, ensuring that model structure construction and weight read use a consistent model version and parameter organization method.

[0077] After receiving a model loading request, the model loading interface creates model layers based on the model structure parameters and sets the parameter positions of weight parameters, bias parameters, and normalization parameters in each model layer. When the model to be migrated is stored in a single file, the parameter index and model weight data in the parameter reading file are read according to the weights. When the model to be migrated is stored in shards, each weight shard is read sequentially according to the shard index, and the parameter names, tensor dimensions, and data types in the shards are verified. The read model weight data is loaded into the parameter positions in the model structure according to the parameter names or parameter indexes, so that each parameter position in the model structure has a corresponding weight tensor.

[0078] The loaded model to be transferred contains the model structure and model weight data already written to each parameter location. Parameter items include parameter names, weight tensors, and the parameter's location within the model structure. Parameter names can be formed by combining the model layer name, layer number, and parameter category, used to distinguish attention weights, feedforward weights, bias data, and normalized parameters. Weight tensors include tensor values, data types, tensor dimensions, and storage location, used to represent the multidimensional weight data corresponding to the parameter item.

[0079] The traversal operation accesses each parameter item according to the hierarchical arrangement in the model structure. It reads the parameter name and weight tensor from the parameter location and determines the hierarchical position by combining the parent level, current level, and parameter category in the model structure. The hierarchical position can be represented by a hierarchical path, layer number, and parameter sequence number. The parameter name, weight tensor, and hierarchical position are written to the same parameter record, ensuring that each parameter record simultaneously reflects the parameter identifier, parameter content, and model structure position. For shared weight parameters, multiple references between parameter names and the same weight tensor can be recorded to avoid duplicate copying of weight data.

[0080] The parameter record set is traversed according to its hierarchical position, ensuring that the order in which the parameter records are written matches the order in which the parameters are arranged in the model structure. The parameter name in each parameter record serves as the key, and the weight tensor serves as the value, written into a key-value structure. When parameter names are duplicated, a complete parameter name can be generated based on the hierarchical position to avoid overwriting of the same type of parameter in different model layers. After all parameter records are written, a model parameter dictionary is formed, allowing the location of the corresponding weight tensor by parameter name.

[0081] This embodiment generates model loading parameters through model configuration data and controls model structure construction and weight data reading with a unified model loading request, which enables model weights to be accurately loaded to the corresponding parameter positions. By traversing the model to be migrated after loading and recording parameter names, weight tensors and hierarchical positions, the correspondence between model structure and parameter content can be maintained. By organizing the parameter records through a key-value structure, the omission of weight fragments, parameter name conflicts and parameter position mismatches can be reduced, thereby improving the completeness and accuracy of model parameter extraction.

[0082] In one embodiment, such as Figure 5 As shown, step S30 above includes: S301, Read the target data type from the target graphics processor environment data, and sequentially read the parameter name, the weight tensor corresponding to the parameter name, the data type information of the weight tensor, and the tensor dimension data from the model parameter dictionary, and generate tensor transformation data corresponding to the parameter name based on the data type information and the target data type; S302, the weight tensor is transferred to the host storage space to generate host weight data; S303, Based on the tensor transformation data, the host weight data is converted into the target data type to generate target tensor data; S304, Construct a target weight tensor based on the target tensor data and the tensor dimension data; S305, generate target parameter records based on the correspondence between the parameter names and the target weight tensors, and combine the target parameter records according to the parameter arrangement order in the model parameter dictionary to generate a target model parameter dictionary.

[0083] In this embodiment, the target data type is read from the target graphics processor environment data, and each parameter item in the model parameter dictionary is accessed sequentially. Each parameter item includes at least a parameter name, a weight tensor, data type information, and tensor dimension data. The parameter name is used to maintain a unique correspondence between the weight tensor before and after the transformation, the data type information reflects the current numerical representation of the weight tensor, and the tensor dimension data records the number of dimensions, the length of each dimension, and the order of the dimensions.

[0084] Tensor transformation data is generated based on the data type information of the weight tensor and the target data type. The tensor transformation data may include the source data type, target data type, element byte width, numerical conversion method, rounding method, and exception handling method. The tensor transformation data is stored in association with parameter names, ensuring that different parameter items use their corresponding transformation parameters, avoiding parameter mixing during batch conversions.

[0085] When a weight tensor is stored in the source graphics processor's storage space, the tensor values ​​are copied to the host storage space, retaining the parameter names, tensor dimension data, and parameter arrangement positions to form host weight data. When a weight tensor uses non-contiguous storage, the tensor elements can be rearranged according to the tensor step size to form a contiguous host storage area. When the size of the weight tensor exceeds the single available storage capacity, it can be transferred in blocks according to element ranges or tensor dimensions, with each data block maintaining the same parameter names and block position identifiers.

[0086] The tensor elements in the host weight data are converted according to the tensor transformation data. When the source data type and the target data type are consistent, the tensor values ​​are retained and stored uniformly. When the two data types are inconsistent, the tensor elements are converted according to the numerical range and precision of the target data type, and overflow values, invalid values, and infinity values ​​are checked. The converted tensor elements are written to the target data buffer in the original element order to form the target tensor data.

[0087] Based on the tensor dimension data, the target tensor data is reconstructed into a target weight tensor, maintaining the original weight tensor's number of dimensions, length of each dimension, and dimension order. The target data type is then written into the tensor attributes. When using block-based transformation, the target tensor data is written into the corresponding tensor region according to the block position identifier of each data block, completing the overall reconstruction of the target weight tensor.

[0088] Write the parameter name and its corresponding target weight tensor into the target parameter record, and combine the target parameter records according to the parameter order in the model parameter dictionary to form the target model parameter dictionary. The parameter name serves as the key, and the target weight tensor serves as the value. When shared weights exist, the reference relationship between multiple parameter names and the same target weight tensor can be preserved. When duplicate parameter names are found, parameter items can be distinguished according to their parameter hierarchy position to avoid the target weight tensor being overwritten.

[0089] This embodiment determines the target data type based on the target graphics processor environment and completes the data type conversion and tensor reconstruction of the weight tensor in the host storage space, which can reduce the limitations of the source storage form on the conversion process. By preserving the correspondence between parameter names, tensor dimensions and parameter arrangement order, it can reduce the probability of tensor structure changes, parameter misalignment and weight overlay, so that the generated target model parameter dictionary meets the data representation requirements of the target graphics processor.

[0090] In one embodiment, such as Figure 6 As shown, step S40 above includes: S401, Read source model framework data and source model storage format data from the source graphics processor environment data, read target training framework data, target inference framework data and target model storage format requirements from the target graphics processor environment data, read model hierarchy data, attention structure data and hidden dimension data from the model configuration data, and generate parameter transformation basic data; S402, read parameter names, parameter order, and tensor dimension data of target weight tensors from the target model parameter dictionary, and determine the parameter name correspondence, tensor dimension adjustment method, and parameter level position based on the parameter transformation basic data, parameter names, parameter order, and tensor dimension data, and generate parameter transformation relationship; S403, adjust the parameter names in the target model parameter dictionary according to the parameter name correspondence in the parameter transformation relationship, adjust the tensor dimension order of the target weight tensor according to the tensor dimension adjustment method, and adjust the parameter arrangement order in the target model parameter dictionary according to the parameter hierarchical position to generate a standardized model parameter dictionary; S404, Read the standard parameter name, the standard weight tensor corresponding to the standard parameter name, the standard data type information and the standard tensor dimension data from the standardized model parameter dictionary, generate metadata header data based on the standard parameter name, the standard data type information and the standard tensor dimension data according to the target model storage format requirements, and convert the standard weight tensor into binary tensor data; S405, based on the target training framework data, the target inference framework data, and the target model storage format requirements, determine the model format identifier, write the model format identifier into the metadata header data, and combine the metadata header data and the binary tensor data to generate a secure tensor model file.

[0091] In this embodiment, source model framework data and source model storage format data are read from the source graphics processor environment data to determine the composition of source parameter names, model layer numbering, weight tensor dimension arrangement, and parameter file organization. Target training framework data, target inference framework data, and target model storage format requirements are read from the target graphics processor environment data to determine the target-end identifiable parameter naming format, tensor arrangement, file field structure, and weight storage method. Model layer data, attention structure data, and hidden dimension data are read from the model configuration data to identify the model layer, parameter category, and corresponding tensor size of each parameter. The above data are combined into basic parameter transformation data, enabling the source parameter organization to be compared with the target requirements according to the same model structure.

[0092] The parameter names, parameter order, and tensor dimension data of the target weight tensor are read from the target model parameter dictionary. Parameter names identify the parameter's level and category; the parameter order indicates the parameter's organizational order in the dictionary; and the tensor dimension data represents the number of dimensions, length of each dimension, and dimension arrangement of the target weight tensor. Based on the parameter transformation baseline data, the correspondence between the source and target name fragments is identified, and the layer number, attention parameters, feedforward parameters, and normalization parameters' corresponding parameter hierarchy positions are determined by combining the model hierarchy data. The tensor dimension adjustment method is determined based on the differences in the organization of tensor input and output dimensions between the source and target sides, thus forming the parameter transformation relationship.

[0093] Replace the parameter prefixes, hierarchical identifiers, and parameter category identifiers in the target model parameter dictionary according to the parameter name correspondence, ensuring that the converted parameter names meet the reading requirements of the target framework. Change the dimension arrangement order of the target weight tensors according to the tensor dimension adjustment method, and update the adjusted tensor dimension data synchronously. Reorganize the parameter arrangement order according to the parameter hierarchical position, ensuring that attention parameters, feedforward parameters, and normalized parameters in the same model layer maintain their corresponding organizational order. Combine the parameter records after completing the name, dimension, and order organization into a standardized model parameter dictionary.

[0094] The standard parameter names, standard weight tensors, standard data type information, and standard tensor dimension data are read from the standardized model parameter dictionary. Based on the target model's storage format requirements, a parameter name field, data type field, dimension field, data offset field, and data length field are generated for each standard parameter, and these are combined into metadata header data according to the parameter's order. The data offset field marks the starting position of the standard weight tensor in the file data area, and the data length field is determined based on the standard data type and standard tensor dimension data.

[0095] The standard weight tensor is converted into consecutive byte data according to the order of the metadata header data records and written sequentially to the tensor data area to form binary tensor data. During the writing process, the data length of each tensor is checked to ensure consistency with the metadata record, and the data areas of adjacent tensors are checked to ensure that the parameter name can be located in the corresponding tensor content through the offset position in the metadata.

[0096] The model format identifier is determined based on the target training framework data, target inference framework data, and target model storage format requirements. The model format identifier records the file format type, format version, parameter organization, and applicable framework information, and is written into the metadata header data. The metadata header data and binary tensor data are combined according to the target model storage format requirements to form a secure tensor model file, ensuring that the file content consists of structured metadata and tensor byte data.

[0097] This embodiment establishes parameter transformation relationships by combining the source model organization form, target model storage requirements, and model structure data. This unifies parameter names, tensor dimension order, and parameter arrangement order. By recording parameter attributes and tensor storage locations through metadata header data and organizing standard weight tensors into continuous binary tensor data, the probability of parameter name mismatch, tensor dimension misalignment, and unrecognizable file structure can be reduced. This ensures that the generated secure tensor model file has clear parameter index relationships and model format information.

[0098] In one embodiment, such as Figure 7 As shown, step S50 above includes: S501, read model hierarchical data, attention structure data and hidden dimension data from the model configuration data, read target data type from the target graphics processor environment data, and write the model hierarchical data, attention structure data, hidden dimension data and target data type into the model hierarchical field, attention structure field, hidden dimension field and data type field respectively to generate model configuration field data; S502, Generate a standard model configuration file based on the model configuration field data; S503, Read the segmentation method, special tags and tag mapping relationship from the segmenter configuration data, and write the segmentation method, special tags and tag mapping relationship into the segmentation method field, special tags field and tag mapping field respectively to generate segmentation configuration field data; S504, Generate a word segmenter configuration file based on the word segmentation configuration field data; S505, based on the file types and file names of the security tensor model file, the standard model configuration file, and the word segmenter configuration file, determine the directory locations of the security tensor model file, the standard model configuration file, and the word segmenter configuration file in the model directory, and generate directory file index data; S506, according to the directory file index data, write the security tensor model file, the standard model configuration file and the word segmenter configuration file into the corresponding directory location to generate the standard model directory structure.

[0099] In this embodiment, the model hierarchy data includes the number of model layers, layer types, and hierarchical arrangement; the attention structure data includes the number of attention heads, query parameters, key parameters, and value parameters; and the hidden dimension data includes model hidden dimensions and intermediate layer dimensions. According to the field names, field types, and field levels specified in the target model configuration format, each piece of data is written to the model hierarchy field, attention structure field, and hidden dimension field, respectively. Before writing, integers, booleans, strings, and arrays are type-converted to ensure that the field values ​​conform to the serialization requirements of the configuration file.

[0100] The target data type is used to record the numerical precision used by the weight tensors in the security tensor model file. The target data type is written to the data type field to ensure that the data type recorded in the configuration file matches the actual data type of the model weights. The model hierarchy field, attention structure field, hidden dimension field, and data type field are combined in a preset field order to form the model configuration field data.

[0101] Model configuration field data is serialized according to a structured file format, and field hierarchy is saved through nested objects or field paths. During serialization, the system checks whether required fields are complete, whether field value types are correct, and whether the model hierarchy matches the hidden dimensions. After the checks are completed, a standard model configuration file is generated.

[0102] The segmentation method records the text partitioning and tag generation methods. Special tags include text start tags, text end tags, padding tags, and unknown tags. The tag mapping relationship records the correspondence between special tags or text units and numerical identifiers. The segmentation method, special tags, and tag mapping relationship are written into the corresponding fields, and it is verified that all special tags have corresponding numerical identifiers, forming the segmentation configuration field data. The segmentation configuration field data is serialized according to the field structure recognizable by the target segmenter to generate the segmenter configuration file.

[0103] The directory locations are determined based on the file types and names of the security tensor model file, the standard model configuration file, and the word segmenter configuration file. The security tensor model file is written to the weight file location, the standard model configuration file is written to the model configuration location, and the word segmenter configuration file is written to the word segmentation configuration location. Each file name, file type, and relative directory location is written into the directory file index data, ensuring that file location is independent of the specific storage root path.

[0104] Create corresponding directories based on the directory file index data, and write the three files to their respective directory locations. After writing, verify that the file names, file types, and relative paths match the directory file index data, and organize the file directories and directory file index data together into a standard model directory structure.

[0105] This embodiment unifies the model structure field, target data type field, and word segmentation configuration field, and organizes the model weight file and configuration file according to file type, file name, and relative directory location. This can reduce model file recognition anomalies caused by inconsistent field formats, incorrect weight data type records, missing configuration files, and misaligned file paths, and ensure that the model weight, model structure configuration, and word segmentation configuration maintain a clear correspondence.

[0106] In one embodiment, such as Figure 8 As shown, step S60 above includes: S601, based on the target graphics processor environment data, determine the target inference framework data and the target operator support data, parse the security tensor model file in the standard model directory structure according to the model format identifier, and parse the standard model configuration file and the word segmenter configuration file according to the target inference framework data to generate model structure data, weight data and word segmentation data; S602, determine the model operator based on the model structure data, determine the target operator corresponding to the model operator from the target operator support data, establish the operator correspondence between the model operator and the target operator, and construct the target computation graph data based on the model structure data and the operator correspondence. S603, bind the weight data to the parameter nodes in the target computation graph data, compile the target computation graph data after binding the weight data based on the target inference framework data, and generate model execution data; S604, based on the target graphics processor environment data, the model structure data and the weight data, determine the model parallel parameters, storage allocation parameters, batch processing parameters and key-value cache parameters, and generate target runtime configuration data; S605, based on the model parallel parameters, storage allocation parameters, batch processing parameters and key-value cache parameters in the target running configuration data, load the model execution data into the target graphics processor corresponding to the target graphics processor environment data, establish a model running instance, and collect the model loading status; S606, Read the verification input data and verification output structure data from the verification data, perform word segmentation encoding on the verification input data according to the word segmentation data, generate model verification input data, pass the model verification input data into the model running instance, generate target-end inference results and collect model running status, compare the output structure of the target-end inference results with the verification output structure data, generate inference comparison results, and generate model migration results based on the inference comparison results, the model loading status and the model running status.

[0107] In this embodiment, the type, version, and model loading interface of the target inference framework are read from the target graphics processor environment data. The operator names, operator versions, input / output data types, and tensor dimension requirements supported by the target graphics processor are also read, forming target inference framework data and target operator support data. The model format identifier is used to determine the metadata organization and tensor data storage method of the secure tensor model file, thereby reading parameter names, data types, tensor dimensions, data offset positions, and corresponding weight content. The standard model configuration file is parsed according to the configuration fields of the target inference framework to obtain the model hierarchy, attention structure, hidden dimensions, and parameter connection relationships; the word segmenter configuration file is parsed to obtain the word segmentation method, special tags, and tag mapping relationships. The parsing results form model structure data, weight data, and word segmentation data, respectively.

[0108] Model operators are determined based on the layer type, node connection relationships, and parameter configuration in the model structure data. Then, corresponding target operators are selected from the target operator support data according to the operator name, input / output structure, and data type. When a model operator can be carried out by a single target operator, a one-to-one correspondence between operators is established; when multiple target operators need to be combined, the order and connection relationships of the target operators are recorded. Target computation graph data is established by combining the node positions, data flow direction, and operator correspondences in the model structure, ensuring that the input, output, and parameter nodes of each target operator are consistent with the model structure.

[0109] Weight data is bound to the target computation graph data according to the correspondence between parameter names and parameter nodes. During binding, the data type, tensor dimensions, and parameter node requirements of the weight tensors are checked, and binding anomalies are recorded when inconsistencies in dimensions or data types are found. After binding, the target computation graph data is compiled by the target inference framework. The compilation includes generating the operator scheduling order, arranging tensor storage areas, generating target instructions, and solidifying weight reference relationships, generating model execution data that can be loaded by the target graphics processor. The model execution data may include the compiled computation graph, target instruction data, weight reference information, and storage layout information.

[0110] Model parallelism parameters are determined based on the number of devices in the target graphics processor, inter-device communication capabilities, and model hierarchy distribution. These parameters configure how model layers or tensors are partitioned across multiple graphics processors. Storage allocation parameters are determined based on the available storage capacity of the target graphics processor, the size of the model structure data, and the weight data. These parameters allocate weight storage areas, intermediate tensor storage areas, and output storage areas. Batch processing parameters are determined based on available storage capacity, input length, and model hierarchy. Key-value caching parameters are determined based on the number of attention layers, the number of attention heads, hidden dimensions, data types, and allowed sequence lengths. The combination of these parameters forms the target runtime configuration data.

[0111] Based on the target runtime configuration data, the model execution data is loaded into the target graphics processor, weight storage areas and tensor storage areas used during runtime are allocated, model parallelism, batch size, and key-value cache areas are configured, and a model runtime instance is established. The model loading status records the model execution data parsing results, weight loading results, storage allocation results, operator initialization results, and exception information to reflect whether the model runtime instance has been successfully established.

[0112] The validation input data and validation output structure data are read from the validation data. The validation input data is converted into a tag sequence according to the segmentation method, special tags, and tag mapping relationships in the segmentation data, generating model validation input data. After the model validation input data is passed to the model running instance, the target-side inference results and model running status are collected. The model running status includes operator running results, storage usage status, and anomaly information. The output fields, tensor quantity, tensor dimension, and data type in the target-side inference results are compared with the validation output structure data to generate inference comparison results. Based on the inference comparison results, model loading status, and model running status, the migration is determined to be complete, and structural differences, loading anomalies, and running anomalies are recorded to generate model migration results.

[0113] This embodiment parses model files using model format identifiers and combines them with the target inference framework to complete operator mapping, weight binding, and computation graph compilation. It can convert the standard model directory structure into model execution data that can be loaded by the target graphics processor. By configuring running parameters through model structure, weight scale, and target environment capabilities, and by using verification data to check loading status, running status, and output structure, it can promptly identify operator incompatibility, abnormal weight binding, storage allocation failure, and inconsistent output structure, thereby improving the accuracy and verifiability of heterogeneous graphics processor model migration results.

[0114] In one embodiment, a financial institution has completed the pre-training and business fine-tuning of a large-scale transaction anti-fraud model on an existing graphics processing unit (GPU) cluster. The model input includes anonymized transaction logs, account behavior sequences, device risk information, merchant information, and risk event text. The model output includes risk categories, risk scores, and abnormal transaction locations. To migrate the model to a Huawei Ascend 910B environment, a model migration task is created, recording the source model directory location, source environment identifier, target environment identifier, and verification data storage location. The source model directory stores the model weight file, model configuration file, word segmentation configuration file, and weight shard index. The verification data storage location stores the anonymized transaction sequences and their corresponding output structure requirements. The target environment can use Huawei Ascend 910B 800T or 800I computing cards. The environment data records the 7nm manufacturing process, 64GB HBM2e (second generation high bandwidth memory enhanced version) video memory, single-machine eight-card configuration, and the computing power support range corresponding to FP32 (32-bit floating point), FP16 (16-bit floating point), BF16 (brain floating point 16-bit format) and INT8 (8-bit integer). It also records the version of MindSpore (Ascend AI framework), MindFormers (Ascend large model suite) and MindIE (Ascend inference engine), the supported operators and model storage format requirements.

[0115] The weight file, model configuration file, and word segmentation configuration file are located based on the source model directory. When weights are saved as a single file, the corresponding file is identified as the model to be transferred. When weights are saved in segments, the number of segments, parameter ranges, and file verification values ​​are checked based on the segment index, and all weight segments of the same model version are collectively identified as the model to be transferred. The model layer number, number of attention heads, hidden dimensions, and parameter data types are read from the model configuration file, and the sub-word segmentation method, text start marker, text end marker, padding marker, unknown marker, and marker mapping relationship are read from the word segmentation configuration file. The financial vocabulary can include business terms such as transaction type, account status, chargeback reason, risk event, insurance liability, and claim materials, ensuring that the word segmentation configuration is consistent with the vocabulary used during the training of the existing model.

[0116] Based on the model configuration data, model structure parameters, data type parameters, and weight reading parameters are generated. The model loading interface provided by MindFormers or Hugging Face Transformers (model development library) is then called to load the model to be migrated. The model loading interface creates an embedding layer, multi-head attention layer, feedforward layer, normalization layer, and output layer based on the model's layer count, attention structure, and hidden dimensions. Weight data is written to the corresponding parameter positions according to the weight shard index. After model loading, the parameter items of each layer are traversed, and the `state_dict` (model parameter dictionary) is extracted. The keys in `state_dict` record parameter names, such as attention query weights, attention key weights, attention value weights, feedforward layer weights, and normalization parameters. The values ​​record the corresponding multi-dimensional weight tensors. During traversal, the model layer where the parameter resides, the parameter order, tensor dimensions, and data type are recorded simultaneously to avoid confusion between similar parameters in different model layers.

[0117] Based on the data types supported by the Huawei Ascend 910B environment, the weight tensors in the model parameter dictionary are converted item by item. When the source weights use FP32 and the target environment uses BF16 or FP16, the weight tensors are transferred to the host storage space. Tensor conversion data is generated according to the source data type, target data type, rounding method, and numerical range, and then each tensor element is converted to the target data type. When the weight scale exceeds the available host storage capacity, the conversion is performed in batches according to the model layer or tensor data block. Each data block retains the parameter name, block position, and tensor dimension information. The converted data is reconstructed into the target weight tensor according to the original tensor dimensions, maintaining the correspondence between parameter names, tensor dimensions, and parameter arrangement order, forming the target model parameter dictionary.

[0118] By combining the source model framework, source model storage format, target training framework, target inference framework, and model structure, the target model parameter dictionary is standardized. When the source and target ends use different parameter naming formats, the hierarchical prefix, attention parameter name, feedforward parameter name, and normalized parameter name are converted into names that the target framework can recognize. If the source and target ends have different requirements for the arrangement of weight input and output dimensions, the tensor dimension order is adjusted according to the tensor reading method of the target end, and the tensor dimension data is updated synchronously. Each parameter is rearranged according to the model hierarchy and parameter category to form a standardized model parameter dictionary. The standard parameter name, data type, tensor dimension, data offset position, and data length are written into the metadata header. The standard weight tensors are organized into continuous binary tensor data according to the parameter arrangement order, and then encapsulated using safetensors. The format field in the metadata header can be set to pt to indicate that the file is saved according to the PyTorch (Torch deep learning framework) parameter organization format, so that the target end can correctly parse the parameter names and weight data.

[0119] The number of model layers, number of attention heads, hidden dimensions, and target data type are written into the model layer field, attention structure field, hidden dimension field, and data type field, respectively, generating a config.json file (model configuration file). The tokenization method, special tags, and tag mapping relationships are written into tokenizer_config.json (tokenizer configuration file). The secure tensor model file, model configuration file, and tokenizer configuration file are written into the model directory according to the requirements of the target inference framework. The weight file can be written into the weight directory, the model configuration file into the configuration directory, and the tokenizer configuration file and vocabulary file into the tokenization directory. The directory file index records the file name, file type, relative path, version information, and checksum, forming a standard Hugging Face model directory structure, enabling the converted model to continue to be used for training or inference in the Huawei Ascend environment.

[0120] MindIE parses the secure tensor model file based on the model format identifier and generates model structure data, weight data, and word segmentation data based on the model configuration file and word segmenter configuration file. It determines model operators based on multi-head attention, feedforward, normalization, and output nodes in the model structure, and then identifies target operators from the list of operators supported by Huawei Ascend 910B. When a model operator can be carried by a single target operator, a one-to-one correspondence is established; when multiple target operators need to be combined, a combination relationship is established according to the input-output relationship. Multi-head attention, layer normalization, and activation operations can be converted into fusion operators based on the support of the target inference framework, reducing intermediate tensor read / write operations. Weight data is bound to parameter nodes in the target computation graph according to parameter names. After being compiled by MindIE, the target computation graph generates model execution data that can be loaded by the target graphics processor.

[0121] The model parallelism parameters, storage allocation parameters, batch processing parameters, and key-value (KV) cache parameters are determined based on the number of Huawei Ascend 910B devices, inter-device communication capabilities, number of model layers, weight scale, and input sequence length. In a single-machine eight-card environment, data parallelism, tensor parallelism, or pipelined parallelism can be adopted according to the model scale. Storage allocation parameters are used to divide the weight storage area, intermediate tensor storage area, and output storage area. Batch processing parameters are used to determine the number of transaction sequences received in a single run. KV cache parameters are used to determine the attention layer cache space and maximum sequence length. When further weight compression is required, PTQ (Post-Training Quantization) can be used to convert FP16 or BF16 weights to INT8. When high accuracy in risk scoring is required, QAT (Quantization Aware Training) can be used to correct quantization errors. Model execution data is loaded into the Huawei Ascend 910B according to the target running configuration, completing weight loading, storage allocation, operator initialization, and model running instance establishment.

[0122] The system reads anonymized transaction logs, account behavior sequences, device risk information, and risk event text from the verification data. Based on the segmented data, these are converted into a tagged sequence, and text start, end, and padding markers are added to generate the model verification input data. The model execution instance outputs risk categories, risk scores, and abnormal transaction locations, while simultaneously collecting model loading status, operator execution status, storage usage information, and anomaly information. The output fields, tensor count, tensor dimensions, and data types in the target-side inference results are compared with the verification output structure. For example, the number of output tensors in the risk classification model should match the number of classification heads, the tensor dimensions of the risk score should match the preset number of categories, and the abnormal transaction location should match the length of the input transaction sequence. The inference comparison results, model loading status, and model execution status are jointly written into the model migration results to record whether the migration is complete, the positions of differing parameters or operators, and the target-side execution status. This completes the migration, loading, and verification of the large-scale financial anti-fraud model from the existing GPU environment to the Huawei Ascend 910B full-stack domestic environment.

[0123] In one embodiment, a model migration apparatus based on a graphics processor environment is provided, which corresponds one-to-one with the model migration method based on a graphics processor environment described in the above embodiments. (Refer to...) Figure 9 , Figure 9 This is a schematic diagram of the functional modules of a preferred embodiment of the model migration device based on a graphics processor environment according to the present invention. The model migration device based on a graphics processor environment includes: a migration data acquisition module 10, a model parameter extraction module 20, a weight tensor transformation module 30, a security tensor encapsulation module 40, a model catalog construction module 50, and a model migration verification module 60. Detailed descriptions of each functional module are as follows: The migration data acquisition module 10 is used to acquire the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and verification data. Model parameter extraction module 20 is used to call the model loading interface based on the model configuration data to load the model to be migrated, and extract a model parameter dictionary including parameter names and weight tensors corresponding to the parameter names from the loaded model to be migrated; The weight tensor conversion module 30 is used to convert the weight tensors in the model parameter dictionary based on the target graphics processor environment data, generate a target weight tensor, and generate a target model parameter dictionary according to the correspondence between the parameter names and the target weight tensor. The secure tensor encapsulation module 40 is used to standardize and encapsulate the target model parameter dictionary into a secure tensor model file containing a model format identifier based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data. The model directory construction module 50 is used to generate a standard model configuration file and a word segmenter configuration file based on the model configuration data and the word segmenter configuration data, respectively, and combine the security tensor model file, the standard model configuration file and the word segmenter configuration file into a standard model directory structure; The model migration verification module 60 is used to convert the standard model directory structure into model execution data based on the target graphics processor environment data and the model format identifier, and to verify the model execution data based on the verification data to generate model migration results.

[0124] In one embodiment, the migration data acquisition module 10 is specifically used for: Receive a model migration task, read the source model directory location, source environment identifier, target environment identifier, and verification data storage location from the model migration task, and generate migration resource index data; Based on the source model directory location in the migration resource index data, the model weight file, model configuration file, and word segmentation configuration file are located, and the model weight file is determined as the model to be migrated. Model configuration data is obtained by extracting model hierarchical data, attention structure data, hidden dimension data, and data type information from the model configuration file. Extract the segmentation method, special tags, and tag mapping relationships from the segmentation configuration file to obtain the segmenter configuration data; From the source graphics processor environment corresponding to the source environment identifier in the migration resource index data, source processor architecture data, source model framework data, source data type and source model storage format data are collected to obtain source graphics processor environment data; From the target graphics processor environment corresponding to the target environment identifier in the migration resource index data, collect the target processor architecture data, target training framework data, target inference framework data, target data type, target operator support data, and target model storage format requirements to obtain the target graphics processor environment data; Based on the verification data storage location in the migration resource index data, the verification input data and verification output structure data corresponding to the model to be migrated are read to obtain the verification data.

[0125] In one embodiment, the model parameter extraction module 20 is specifically used for: The model loading parameters are obtained by reading the model hierarchy data, attention structure data, hidden dimension data, and data type information from the model configuration data. A model loading request is generated based on the model loading parameters, including model structure parameters, data type parameters, and weight reading parameters; The model loading request is sent to the model loading interface. The model structure is constructed according to the model loading request through the model loading interface. The model weight data is read from the model to be migrated and loaded into the parameter position in the model structure to obtain the loaded model to be migrated. Traverse the parameter items in the loaded model to be transferred, extract the parameter name and weight tensor from each parameter item, determine the hierarchical position of each parameter item in the model structure based on the model structure and the parameter name, and write the parameter name, the weight tensor and the hierarchical position into the parameter record accordingly to generate a parameter record set; Traverse the parameter record set according to the hierarchical position, and write the parameter name and weight tensor in each parameter record into the key-value structure to generate the model parameter dictionary.

[0126] In one embodiment, the weight tensor transformation module 30 is specifically used for: Read the target data type from the target graphics processor environment data, and sequentially read the parameter name, the weight tensor corresponding to the parameter name, the data type information of the weight tensor, and the tensor dimension data from the model parameter dictionary. Generate tensor transformation data corresponding to the parameter name based on the data type information and the target data type. The weight tensor is transferred to the host storage space to generate host weight data; Based on the tensor transformation data, the host weight data is converted into the target data type to generate target tensor data; Construct a target weight tensor based on the target tensor data and the tensor dimension data; Target parameter records are generated based on the correspondence between the parameter names and the target weight tensors. The target parameter records are then combined according to the parameter arrangement order in the model parameter dictionary to generate the target model parameter dictionary.

[0127] In one embodiment, the security tensor encapsulation module 40 is specifically used for: Read source model framework data and source model storage format data from the source graphics processor environment data; read target training framework data, target inference framework data and target model storage format requirements from the target graphics processor environment data; read model hierarchy data, attention structure data and hidden dimension data from the model configuration data; and generate parameter transformation basic data. Read parameter names, parameter order, and tensor dimension data of target weight tensors from the target model parameter dictionary. Based on the parameter transformation base data, parameter names, parameter order, and tensor dimension data, determine the parameter name correspondence, tensor dimension adjustment method, and parameter hierarchical position to generate parameter transformation relationships. The parameter names in the target model parameter dictionary are adjusted according to the parameter name correspondence in the parameter transformation relationship, the tensor dimension order of the target weight tensor is adjusted according to the tensor dimension adjustment method, and the parameter arrangement order in the target model parameter dictionary is adjusted according to the parameter hierarchical position to generate a standardized model parameter dictionary; Read the standard parameter name, the standard weight tensor corresponding to the standard parameter name, the standard data type information, and the standard tensor dimension data from the standardized model parameter dictionary. Based on the target model storage format requirements, generate metadata header data based on the standard parameter name, the standard data type information, and the standard tensor dimension data, and convert the standard weight tensor into binary tensor data. Based on the target training framework data, the target inference framework data, and the target model storage format requirements, a model format identifier is determined, the model format identifier is written into the metadata header data, and the metadata header data and the binary tensor data are combined to generate a secure tensor model file.

[0128] In one embodiment, the model catalog building module 50 is specifically used for: Read model hierarchy data, attention structure data, and hidden dimension data from the model configuration data; read target data type from the target graphics processor environment data; and write the model hierarchy data, attention structure data, hidden dimension data, and target data type into the model hierarchy field, attention structure field, hidden dimension field, and data type field, respectively, to generate model configuration field data. A standard model configuration file is generated based on the model configuration field data; Read the segmentation method, special tags, and tag mapping relationship from the segmenter configuration data, and write the segmentation method, special tags, and tag mapping relationship into the segmentation method field, special tags field, and tag mapping field respectively to generate segmentation configuration field data; A word segmenter configuration file is generated based on the word segmentation configuration field data; Based on the file types and file names of the security tensor model file, the standard model configuration file, and the word segmenter configuration file, determine the directory locations of the security tensor model file, the standard model configuration file, and the word segmenter configuration file in the model directory, and generate directory file index data; According to the directory file index data, the security tensor model file, the standard model configuration file, and the word segmenter configuration file are written to the corresponding directory locations to generate the standard model directory structure.

[0129] In one embodiment, the model transfer verification module 60 is specifically used for: Based on the target graphics processor environment data, the target inference framework data and target operator support data are determined. The security tensor model file in the standard model directory structure is parsed according to the model format identifier. The standard model configuration file and the word segmenter configuration file are parsed according to the target inference framework data to generate model structure data, weight data and word segmentation data. Based on the model structure data, model operators are determined, target operators corresponding to the model operators are determined from the target operator support data, and operator correspondence between the model operators and the target operators is established. Target computation graph data is constructed based on the model structure data and the operator correspondence. The weight data is bound to the parameter nodes in the target computation graph data, and the target computation graph data after the weight data has been bound is compiled based on the target inference framework data to generate model execution data; Based on the target graphics processor environment data, the model structure data, and the weight data, determine the model parallel parameters, storage allocation parameters, batch processing parameters, and key-value cache parameters, and generate the target runtime configuration data. Based on the model parallel parameters, storage allocation parameters, batch processing parameters, and key-value cache parameters in the target runtime configuration data, the model execution data is loaded into the target graphics processor corresponding to the target graphics processor environment data, a model runtime instance is established, and the model loading status is collected. The verification input data and verification output structure data are read from the verification data. The verification input data is segmented and encoded according to the word segmentation data to generate model verification input data. The model verification input data is passed to the model running instance to generate target-end inference results and collect model running status. The output structure of the target-end inference results is compared with the verification output structure data to generate inference comparison results. Based on the inference comparison results, the model loading status and the model running status, model migration results are generated.

[0130] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides determination and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When executed by the processor, the computer program implements the functions or steps of a model migration method based on a graphics processor environment on the server side.

[0131] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides determination and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements client-side functions or steps of a model migration method based on a graphics processor environment.

[0132] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Obtain the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and validation data; Based on the model configuration data, the model loading interface is called to load the model to be migrated, and a model parameter dictionary including parameter names and weight tensors corresponding to the parameter names is extracted from the loaded model to be migrated. Based on the target graphics processor environment data, the weight tensors in the model parameter dictionary are transformed to generate the target weight tensor, and the target model parameter dictionary is generated according to the correspondence between the parameter names and the target weight tensor. Based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data, the target model parameter dictionary is standardized and encapsulated into a secure tensor model file containing a model format identifier; Based on the model configuration data and the word segmenter configuration data, a standard model configuration file and a word segmenter configuration file are generated respectively. The security tensor model file, the standard model configuration file, and the word segmenter configuration file are combined into a standard model directory structure. Based on the target graphics processor environment data and the model format identifier, the standard model directory structure is converted into model execution data, and the model execution data is verified based on the verification data to generate model migration results.

[0133] In one embodiment, a computer-readable storage medium is provided, which may be non-volatile or volatile, and a computer program is stored thereon, which, when executed by a processor, performs the following steps: Obtain the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and validation data; Based on the model configuration data, the model loading interface is called to load the model to be migrated, and a model parameter dictionary including parameter names and weight tensors corresponding to the parameter names is extracted from the loaded model to be migrated. Based on the target graphics processor environment data, the weight tensors in the model parameter dictionary are transformed to generate the target weight tensor, and the target model parameter dictionary is generated according to the correspondence between the parameter names and the target weight tensor. Based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data, the target model parameter dictionary is standardized and encapsulated into a secure tensor model file containing a model format identifier; Based on the model configuration data and the word segmenter configuration data, a standard model configuration file and a word segmenter configuration file are generated respectively. The security tensor model file, the standard model configuration file, and the word segmenter configuration file are combined into a standard model directory structure. Based on the target graphics processor environment data and the model format identifier, the standard model directory structure is converted into model execution data, and the model execution data is verified based on the verification data to generate model migration results.

[0134] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.

[0135] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0136] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0137] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.

[0138] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A model transfer method based on a graphics processor environment, characterized in that, Includes the following steps: Obtain the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and validation data; Based on the model configuration data, the model loading interface is called to load the model to be migrated, and a model parameter dictionary including parameter names and weight tensors corresponding to the parameter names is extracted from the loaded model to be migrated. Based on the target graphics processor environment data, the weight tensors in the model parameter dictionary are transformed to generate the target weight tensor, and the target model parameter dictionary is generated according to the correspondence between the parameter names and the target weight tensor. Based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data, the target model parameter dictionary is standardized and encapsulated into a secure tensor model file containing a model format identifier; Based on the model configuration data and the word segmenter configuration data, a standard model configuration file and a word segmenter configuration file are generated respectively. The security tensor model file, the standard model configuration file, and the word segmenter configuration file are combined into a standard model directory structure. Based on the target graphics processor environment data and the model format identifier, the standard model directory structure is converted into model execution data, and the model execution data is verified based on the verification data to generate model migration results.

2. The model transfer method based on a graphics processor environment as described in claim 1, characterized in that, Obtain the model to be transferred, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and validation data, including: Receive a model migration task, read the source model directory location, source environment identifier, target environment identifier, and verification data storage location from the model migration task, and generate migration resource index data; Based on the source model directory location in the migration resource index data, the model weight file, model configuration file, and word segmentation configuration file are located, and the model weight file is determined as the model to be migrated. Model configuration data is obtained by extracting model hierarchical data, attention structure data, hidden dimension data, and data type information from the model configuration file. Extract the segmentation method, special tags, and tag mapping relationships from the segmentation configuration file to obtain the segmenter configuration data; From the source graphics processor environment corresponding to the source environment identifier in the migration resource index data, source processor architecture data, source model framework data, source data type and source model storage format data are collected to obtain source graphics processor environment data; From the target graphics processor environment corresponding to the target environment identifier in the migration resource index data, collect the target processor architecture data, target training framework data, target inference framework data, target data type, target operator support data, and target model storage format requirements to obtain the target graphics processor environment data; Based on the verification data storage location in the migration resource index data, the verification input data and verification output structure data corresponding to the model to be migrated are read to obtain the verification data.

3. The model transfer method based on a graphics processor environment as described in claim 1, characterized in that, Based on the model configuration data, the model loading interface is called to load the model to be migrated. From the loaded model to be migrated, a model parameter dictionary is extracted, including parameter names and weight tensors corresponding to the parameter names, including: The model loading parameters are obtained by reading the model hierarchy data, attention structure data, hidden dimension data, and data type information from the model configuration data. A model loading request is generated based on the model loading parameters, including model structure parameters, data type parameters, and weight reading parameters; The model loading request is sent to the model loading interface. The model structure is constructed according to the model loading request through the model loading interface. The model weight data is read from the model to be migrated and loaded into the parameter position in the model structure to obtain the loaded model to be migrated. Traverse the parameter items in the loaded model to be transferred, extract the parameter name and weight tensor from each parameter item, determine the hierarchical position of each parameter item in the model structure based on the model structure and the parameter name, and write the parameter name, the weight tensor and the hierarchical position into the parameter record accordingly to generate a parameter record set; Traverse the parameter record set according to the hierarchical position, and write the parameter name and weight tensor in each parameter record into the key-value structure to generate the model parameter dictionary.

4. The model transfer method based on a graphics processor environment as described in claim 1, characterized in that, Based on the target graphics processor environment data, the weight tensors in the model parameter dictionary are transformed to generate a target weight tensor, and a target model parameter dictionary is generated according to the correspondence between the parameter names and the target weight tensor, including: Read the target data type from the target graphics processor environment data, and sequentially read the parameter name, the weight tensor corresponding to the parameter name, the data type information of the weight tensor, and the tensor dimension data from the model parameter dictionary. Generate tensor transformation data corresponding to the parameter name based on the data type information and the target data type. The weight tensor is transferred to the host storage space to generate host weight data; Based on the tensor transformation data, the host weight data is converted into the target data type to generate target tensor data; Construct a target weight tensor based on the target tensor data and the tensor dimension data; Target parameter records are generated based on the correspondence between the parameter names and the target weight tensors. The target parameter records are then combined according to the parameter arrangement order in the model parameter dictionary to generate the target model parameter dictionary.

5. The model transfer method based on a graphics processor environment as described in claim 1, characterized in that, Based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data, the target model parameter dictionary is standardized and encapsulated into a secure tensor model file containing a model format identifier, including: Read source model framework data and source model storage format data from the source graphics processor environment data; read target training framework data, target inference framework data and target model storage format requirements from the target graphics processor environment data; read model hierarchy data, attention structure data and hidden dimension data from the model configuration data; and generate parameter transformation basic data. Read parameter names, parameter order, and tensor dimension data of target weight tensors from the target model parameter dictionary. Based on the parameter transformation base data, parameter names, parameter order, and tensor dimension data, determine the parameter name correspondence, tensor dimension adjustment method, and parameter hierarchical position to generate parameter transformation relationships. The parameter names in the target model parameter dictionary are adjusted according to the parameter name correspondence in the parameter transformation relationship, the tensor dimension order of the target weight tensor is adjusted according to the tensor dimension adjustment method, and the parameter arrangement order in the target model parameter dictionary is adjusted according to the parameter hierarchical position to generate a standardized model parameter dictionary; Read the standard parameter name, the standard weight tensor corresponding to the standard parameter name, the standard data type information, and the standard tensor dimension data from the standardized model parameter dictionary. Based on the target model storage format requirements, generate metadata header data based on the standard parameter name, the standard data type information, and the standard tensor dimension data, and convert the standard weight tensor into binary tensor data. Based on the target training framework data, the target inference framework data, and the target model storage format requirements, a model format identifier is determined, the model format identifier is written into the metadata header data, and the metadata header data and the binary tensor data are combined to generate a secure tensor model file.

6. The model transfer method based on a graphics processor environment as described in claim 1, characterized in that, Based on the model configuration data and the word segmenter configuration data, a standard model configuration file and a word segmenter configuration file are generated respectively. The security tensor model file, the standard model configuration file, and the word segmenter configuration file are combined into a standard model directory structure, including: Read model hierarchy data, attention structure data, and hidden dimension data from the model configuration data; read target data type from the target graphics processor environment data; and write the model hierarchy data, attention structure data, hidden dimension data, and target data type into the model hierarchy field, attention structure field, hidden dimension field, and data type field, respectively, to generate model configuration field data. A standard model configuration file is generated based on the model configuration field data; Read the segmentation method, special tags, and tag mapping relationship from the segmenter configuration data, and write the segmentation method, special tags, and tag mapping relationship into the segmentation method field, special tags field, and tag mapping field respectively to generate segmentation configuration field data; Generate a word segmenter configuration file based on the word segmentation configuration field data; Based on the file types and file names of the security tensor model file, the standard model configuration file, and the word segmenter configuration file, determine the directory locations of the security tensor model file, the standard model configuration file, and the word segmenter configuration file in the model directory, and generate directory file index data; According to the directory file index data, the security tensor model file, the standard model configuration file, and the word segmenter configuration file are written to the corresponding directory locations to generate the standard model directory structure.

7. The model transfer method based on a graphics processor environment as described in claim 1, characterized in that, Based on the target graphics processor environment data and the model format identifier, the standard model directory structure is converted into model execution data, and the model execution data is verified based on the verification data to generate model migration results, including: Based on the target graphics processor environment data, the target inference framework data and target operator support data are determined. The security tensor model file in the standard model directory structure is parsed according to the model format identifier. The standard model configuration file and the word segmenter configuration file are parsed according to the target inference framework data to generate model structure data, weight data and word segmentation data. Based on the model structure data, model operators are determined, target operators corresponding to the model operators are determined from the target operator support data, and operator correspondence between the model operators and the target operators is established. Target computation graph data is constructed based on the model structure data and the operator correspondence. The weight data is bound to the parameter nodes in the target computation graph data, and the target computation graph data after the weight data has been bound is compiled based on the target inference framework data to generate model execution data; Based on the target graphics processor environment data, the model structure data, and the weight data, determine the model parallel parameters, storage allocation parameters, batch processing parameters, and key-value cache parameters, and generate the target runtime configuration data. Based on the model parallel parameters, storage allocation parameters, batch processing parameters, and key-value cache parameters in the target runtime configuration data, the model execution data is loaded into the target graphics processor corresponding to the target graphics processor environment data, a model runtime instance is established, and the model loading status is collected. The verification input data and verification output structure data are read from the verification data. The verification input data is segmented and encoded according to the word segmentation data to generate model verification input data. The model verification input data is passed to the model running instance to generate target-end inference results and collect model running status. The output structure of the target-end inference results is compared with the verification output structure data to generate inference comparison results. Based on the inference comparison results, the model loading status and the model running status, model migration results are generated.

8. A model transfer device based on a graphics processor environment, characterized in that, The model transfer device based on the graphics processor environment includes: The migration data acquisition module is used to acquire the model to be migrated, model configuration data, word segmenter configuration data, source graphics processor environment data, target graphics processor environment data, and verification data. The model parameter extraction module is used to call the model loading interface based on the model configuration data to load the model to be migrated, and extract a model parameter dictionary including parameter names and weight tensors corresponding to the parameter names from the loaded model to be migrated; The weight tensor conversion module is used to convert the weight tensors in the model parameter dictionary based on the target graphics processor environment data, generate the target weight tensor, and generate the target model parameter dictionary according to the correspondence between the parameter names and the target weight tensor. The secure tensor encapsulation module is used to standardize and encapsulate the target model parameter dictionary into a secure tensor model file containing a model format identifier based on the source graphics processor environment data, the target graphics processor environment data, and the model configuration data. The model directory construction module is used to generate a standard model configuration file and a word segmenter configuration file based on the model configuration data and the word segmenter configuration data, respectively, and combine the security tensor model file, the standard model configuration file and the word segmenter configuration file into a standard model directory structure; The model migration verification module is used to convert the standard model directory structure into model execution data based on the target graphics processor environment data and the model format identifier, and to verify the model execution data based on the verification data to generate model migration results.

9. A computer device, characterized in that, The computer device includes a memory, a processor, and a graphics processor-based model migration program stored in the memory and executable on the processor. When executed by the processor, the graphics processor-based model migration program implements the steps of the graphics processor-based model migration method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The storage medium stores a model migration program based on a graphics processor environment, which, when executed by a processor, implements the steps of the model migration method based on a graphics processor environment as described in any one of claims 1-7.