Verifiable edge learning reasoning method for CPU + GPU heterogeneous platform
By adopting asynchronous mechanism and multi-TA collaborative design on the CPU+GPU heterogeneous platform, convolution weight verification and convolution calculation verification are performed in TEE, which solves the problem of verification failure and large delay during the inference process of deep learning models on edge devices. problem, achieving efficient and reliable deep learning inference and attack detection.
Patent Information
- Application Number
- CN202410627538.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-05-21
AI Technical Summary
Existing technologies have problems in protecting the inference process of deep learning models, such as verification failure, difficulty in implementation, large delay, and insufficient protection of model weights. Especially when facing error injection attacks on edge devices, it is difficult to ensure convolution. Layer reasoning correctness and data integrity.
An asynchronous mechanism is used to simultaneously perform convolution weight verification and convolution calculation verification in TEE on a CPU+GPU heterogeneous platform. By generating hash signatures in TEE and using the IFA algorithm to verify the GPU-accelerated convolution layer inference results, the model is ensured. The correctness and completeness of the inference, and the model files are stored encrypted to protect their confidentiality during the deployment phase.
It achieves low-latency, high-reliability deep learning inference, reduces verifiable inference time overhead, improves real-time performance on heterogeneous edge platforms, reduces main thread waiting time and enhances convolution through multi-TA collaborative design. Validation robustness and attack detection accuracy.
Smart Images

Figure CN118657215A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence security, and in particular to a verifiable edge learning reasoning method for a CPU+GPU heterogeneous platform. Background Art
[0002] Deep learning models are mainly composed of convolutional layers, activation layers, pooling layers, upsampling layers, etc. Among them, the number of convolutional layers not only accounts for the majority of the total number of layers in classic image classification and target recognition models. At the same time, the core calculation of these convolutional layers is time-consuming multi-dimensional matrix multiplication operations, and their reasoning time accounts for more than 90% of the entire model. Therefore, these convolutional layers are more likely to be attacked during the deep learning reasoning process. Ensuring the verifiability and reliability of these convolutional layer reasoning runtimes can improve the availability of deep learning reasoning results.
[0003] Although edge intelligence technology has certain advantages in terms of latency, bandwidth usage, and privacy protection, it also inevitably introduces some new challenges. First, the computing performance of edge devices is limited, and the architectures of these devices are diverse. In order to maximize the performance of these heterogeneous edge computing platforms, these devices usually run customized and simplified operating systems, and there is no guarantee whether these customized system software has major security vulnerabilities. Second, edge intelligence devices are usually deployed at the edge of the network and presented in a decentralized mode, which makes it impossible for edge devices to receive timely maintenance by dedicated personnel like centralized servers. The above two deficiencies of edge intelligence also provide opportunities for malicious attackers, posing serious challenges to the correctness of deep learning model reasoning and data integrity in edge devices. Third, the rapid growth of edge intelligence application demand has also promoted the rapid development of CPU+GPU heterogeneous platforms for edge deep learning reasoning. How to use the GPU computing resources in these heterogeneous edge platforms to accelerate deep learning reasoning has also become one of the key issues in current research.
[0004] TEE technology is often used in deep learning to protect model weights or model input data from being stolen. Among them, the Trusted Execution Environment TEE is an independent code execution environment that can ignore security threats from the Rich Execution Environment REE. OP-TEE is a highly portable open source TEE implementation framework. It divides the CPU processor into two states, namely the secure state and the non-secure state. Secure storage is one of the important functions of TEE. Its goal is to ensure that the information stored in the TEE cannot be obtained and maliciously tampered with by attackers, and to be able to promptly revoke or redo the write operation when an error occurs, so as to avoid the writing of erroneous information.
[0005] For matrix multiplication of n×n matrices A and B, the Freivalds algorithm is a time complexity of O(n 2) matrix verification algorithm, which can save computing time compared to repeatedly calculating the matrix multiplication operation. However, when generating random vectors, the value of each vector element is limited to 0 or 1. Therefore, the Freivalds algorithm has a 1 / 2 probability of missed detection. And when the Freivalds algorithm faces intentional tampering by an attacker, the attacker only needs to ensure that the arithmetic sum of each row before and after the modification is consistent with the arithmetic sum of each column to invalidate the Freivalds algorithm.
[0006] Fault injection attack is an attack method against software systems or network applications. It intentionally introduces errors or abnormal situations to disrupt the normal execution of the program, or exploits system vulnerabilities to bypass authentication to steal and tamper with memory data. There are three main methods for defending and detecting fault injection attacks in deep learning reasoning: the first is to verify the convolutional layer reasoning results based on algorithm-based fault tolerance technology (ABFT); the second is to modify the data distribution of the deep learning model weights. When the deep learning model weights are modified by fault injection attacks, the impact on the model reasoning results is reduced, even if the deep learning model is more robust to fault injection attacks; the third is to select some important layers through algorithms, such as convolutional layers that are time-consuming and have an important impact on the reasoning results, and perform repeated calculations or use TEE hardware isolation mechanisms to protect the input and calculation processes of these layers from attacks.
[0007] The method usually adopted by the first type of solution mentioned above is to verify the integrity of the convolution weights or the correctness of the convolution calculation results in real time during the deep learning model reasoning process; compared with repeatedly calculating the convolution layer reasoning, this solution has a smaller time overhead, but the convolution verification algorithm executed in an unsafe state itself may also be tampered with by attackers, resulting in the verification result not necessarily being credible. The second type of solution is a passive defense strategy, and its implementation requires redesigning and training the deep learning model, which not only has a large workload but also affects the accuracy of model reasoning. The third type of solution offloads important layers to TEE for execution, and uses TEE to protect the reasoning of these layers from attacks, but the layers offloaded to TEE can only use the CPU for reasoning, and cannot use the GPU for parallel acceleration, and the running memory of TEE is small, resulting in the solution being unable to meet the low-latency reasoning requirements of larger models. In summary, the existing relevant technical solutions mainly focus on protecting the integrity of model weights and the correctness of convolution layer reasoning during deep learning reasoning. However, these protection measures have problems such as verification failure, difficulty in implementation, large latency, and insufficient protection of model weights. This is because deep learning models are usually stored in external storage media before being loaded into memory. If an attacker obtains the corresponding access rights and directly modifies the model file in the external storage, this attack method is simpler than modifying the weights in memory. In addition, error injection attacks can affect the intermediate calculation process of the deep learning model, and the memory allocation in the intermediate calculation process is temporary; once the calculation is completed, except for the inference result data and weight data, the memory space occupied by other data will be released; therefore, the attacker must complete the attack operation within the effective time of the memory data related to the attack target. The convolutional layer reasoning in the deep learning model meets this requirement of a larger attack time window, which makes the convolutional layer calculation the main object of edge deep learning reasoning attacks and a more successful attack target, and it is also the key reasoning process that the present invention intends to protect.
[0008] To this end, the present invention proposes a new solution, the basic idea of which is to offload the fault-tolerant verification process of convolutional reasoning to TEE, while model reasoning is still performed on the GPU of REE. This solution solves the technical defects of the first and third solutions, not only ensuring the reliability of the convolutional verification process, but also the model reasoning process does not need to wait for the completion of the verification task, but can be performed simultaneously with the verification process, and the model reasoning task can be accelerated in parallel using the GPU in the heterogeneous platform. At the same time, the solution proposed by the present invention can solve the problems of high technical implementation difficulty and reduced model accuracy caused by the redesign and training of the model in the second solution. Summary of the invention
[0009] The purpose of the present invention is to provide a low-latency, highly reliable verifiable deep learning reasoning method for a CPU+GPU heterogeneous edge platform, which can reduce the time overhead of verifiable reasoning while protecting the privacy and integrity of the deep learning model, and improve the real-time performance of verifiable deep learning reasoning on the heterogeneous edge platform.
[0010] To achieve the above purpose, the technical solution of the present invention is: a verifiable edge learning reasoning method for CPU+GPU heterogeneous platform, and it is named DarkneTV, which is characterized in that an asynchronous mechanism is used to implement the GPU-accelerated model reasoning task in REE and the convolution weight verification and convolution calculation process verification of TEE hardware isolation in CPU using CPU+GPU heterogeneous platform at the same time. Through the weight parameter verification and convolution calculation process verification executed in TEE, the verifiable reasoning and acceleration of the deep learning model on the edge device are realized, and the integrity of the deep learning model and the correctness of the reasoning result are protected; the verifiable reasoning process is divided into a deployment phase and a reasoning phase; the deployment phase generates a hash signature (Hash Signature) of each layer of the deep learning model in TEE, and uses the secure storage service of TEE to encrypt the model structure file, weight file and hash signature, and then saves the encrypted model file in the REE file system; the reasoning phase ensures the integrity of the convolution layer weight by comparing the hash signature of the weight parameter in TEE, and uses the designed IFA algorithm to verify the correctness of the convolution operation result on GPU in REE to determine whether the convolution layer reasoning accelerated by GPU in REE is attacked. The present invention not only supports the integrity protection of deep learning model weights in memory, but also supports the integrity and privacy protection of model weights in external memory. At the same time, it provides a TEE hardware isolation verification mechanism for convolutional layer reasoning, which is computationally time-consuming and vulnerable to attack, to ensure the correctness of convolution calculation results and the verifiability of model reasoning results.
[0011] Furthermore, in order to reduce the missed attack rate of the Freivalds algorithm, the IFA algorithm with a high attack detection rate designed by the present invention specifically includes:
[0012] The random vector introduced in the Freivalds algorithm The element value range of is extended from {0,1} to the floating point number between (0.00,1.00], and A and B are used to represent the two input feature matrices of the matrix multiplication operation in the im2col (image to column) convolution algorithm, and the sizes of A and B are m×k and k×n respectively, and the size of the convolution calculation output matrix C is m×n;
[0013] Defining vectors and vector Using the infinity norm To represent the error between the two sides of the equation to be verified, the error upper limit ε suitable for attack detection is calculated according to the size of A, B and C r , when the error value calculated by the IFA algorithm is Does not exceed the upper error limit ε r , it means that the convolution calculation result is reliable, otherwise it is considered that the convolution calculation result has been attacked or a soft error (Soft Error) has occurred in the calculation process.
[0014] Furthermore, the upper limit of error ε r The calculation formula is: r =λmk / 2 24 , where λ is a constant coefficient value set to 0.10.
[0015] Furthermore, the deployment phase is specifically as follows:
[0016] DarkneTV first builds a deep learning model instance by reading the model structure file and the model weight file; then the model instance is transferred to TA1 (Trusted Application) in TEE. TA1 encrypts each layer of the model (including weight parameters) through the secure storage function of OP-TEE, and uses the SHA-256 algorithm to calculate the hash signature HA1 corresponding to the weight parameters of each layer; after using the TEE secure storage service to generate encrypted files of the model parameters and hash signatures for each layer, it is stored in the ordinary file system of REE.
[0017] Furthermore, the reasoning stage is specifically as follows:
[0018] After DarkneTV finishes reading the encrypted file of the deep learning model, it creates a thread pool and establishes a session connection with TEE; it calls the corresponding TEEClient interface to start the security application TA1 running in TEE to decrypt the model structure, the weight parameters A of each layer and its hash signature HA1; after decryption, the model structure and the weight parameters A of each layer are transferred to the memory of REE, while its hash signature HA1 remains in the secure memory of TA1; DarkneTV reads the input data (input image or the output feature map of its previous layer) from the external memory to the REE memory, and starts to use the GPU in the heterogeneous platform to perform edge reasoning of the deep learning model, where the input data is recorded as matrix B; during the reasoning process, the operator reasoning of each layer is first performed in the GPU. If the current layer is a convolution layer, its input weight parameter A, input data B and the output feature map C of the convolution calculation are transferred to the TEE shared memory in a memory-mapped manner, so as to perform hash verification on the weight A and verify the convolution operator reasoning process in the TEE to verify the correctness of the convolution calculation result. If the current layer is a non-convolutional layer, operator inference is performed directly in the GPU without the need to perform hash verification of the weight parameter A and correctness verification of the output feature map C in the TEE; in this way, each layer in the deep learning model is executed in sequence until the inference of all layers of the model is completed and the prediction results are output.
[0019] Furthermore, when the model inference reaches the convolution layer, DarkneTV uses the memory mapping method to map the memory data (convolution weight parameter A and input data B) stored in the GPU to the shared memory area of the TEE, and then the DarkneTV main thread uploads the pointer address of the weight parameter A and input data B in the memory mapping area to TA1, and then TA1 reads the data from the shared memory to the TEE secure memory; after the data reading is completed, TA1 temporarily enters the waiting state;
[0020] The main thread of DarkneTV submits a task to the thread pool, allowing the idle thread in the thread pool to start and execute TA1 to perform the PC (Pre-Check) verification step. At the same time, the main thread of DarkneTV continues to execute the reasoning of the current convolution layer;
[0021] After the main thread completes the convolution calculation, the main thread uploads the pointer of the output feature map of the convolution calculation to TA2, where the output feature map is recorded as matrix C; TA2 reads the output feature map C and returns; the main thread submits a task to the thread pool and continues to execute the reasoning task of the subsequent layer. The idle thread in the thread pool starts TA2 asynchronously and uses the CPU to asynchronously execute the SC (Subsequent Check) verification step and the EC (Error Check) verification step;
[0022] Furthermore, the PC verification step is specifically as follows:
[0023] TA1 generates a random vector according to the size of the weight parameter A read The vector It is composed of floating point numbers in the interval (0.0,1.0); TA1 uses the SHA-256 algorithm to generate a new hash signature for the read weight, recorded as HA2, and determines whether it is the same as HA1 stored in the secure memory; if different, it means that the weight parameter A of the convolution layer in the REE memory has been attacked, and an error warning is directly returned and output, and the current convolution layer reasoning of the DarkneTV main thread is terminated; if the same, it means that the weight parameter A of the layer in the REE memory has not been attacked, then TA1 uses the weight parameter A, input data B and random vector Generate vector in Then TA1 temporarily enters a waiting state, waiting for the main thread to complete the convolution inference calculation using the GPU.
[0024] Furthermore, the SC verification step and the EC verification step are specifically as follows:
[0025] SC check: TA2 obtains random vector And according to the read output feature map C and Generate vector in
[0026] EC verification: TA2 calculates the upper limit of error ε based on the size of A, B and C r , where ε r =λmk / 2 24 ; TA2 obtains vector And calculate When the vector The infinite norm of Less than the upper error limit ε r , it indicates that the result of the current convolution calculation is correct (not attacked), the verification of the convolution layer GPU inference calculation is completed, and TA2 temporarily enters the waiting state; when the vector The infinite norm of Greater than ε r , it means that the output feature map C or input data B of the convolution calculation has been attacked, causing the GPU convolution calculation result to be wrong, and the verification result is directly returned and an error warning is output.
[0027] Furthermore, in the PC check, SC check and EC verification steps, the intermediate calculation results of the convolution verification process are stored through TAsync and securely communicated with TA1 and TA2:
[0028] TA1 generates random vectors After that, TA1 then performs the remaining steps of the PC check (generating HA2 and checking that HA1 = HA2) until vector Analogy vector It will also be uploaded to TAsync’s secure memory;
[0029] TA2 obtains the data uploaded by TA1 from TAsync After that, read the output feature map C and generate the vector At the same time, TA2 obtains the data uploaded by TA1 from TAsync. And perform the remaining tasks of EC verification (generate an upper limit ε r and calculation And use the IFA algorithm to detect whether the convolution calculation process is attacked).
[0030] Furthermore, DarkneTV uses synchronization mechanisms such as semaphores to ensure that TAsync exists before the EC verification step. data.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] (1) The IFA algorithm designed in the present invention is based on the Freivalds algorithm, and the random vector The value range of the element is extended from {0,1} to a floating point number between (0.00,1.00]. This improvement reduces the missed detection rate of the Freivalds algorithm in a single detection, so that the IFA algorithm can obtain a higher attack detection rate without having to run it repeatedly for multiple times; and enhances the robustness of the convolution verification algorithm, so that the method in which the attacker specifically modifies the matrix multiplication calculation result becomes easier to detect, and improves the accuracy of attack detection. The present invention adopts the method of left-multiplying a vector by a matrix to reduce the number of floating-point multiplication operations required for convolution verification, and introduces a maximum error threshold for each verification to allow a certain floating-point calculation error, thereby improving the calculation speed and effectiveness of convolution verification.
[0033] (2) The present invention divides verifiable reasoning into a deployment phase and a reasoning phase, which not only takes into account the integrity protection of the deep learning model weights in memory, but also provides confidentiality and integrity protection of the model weights in external memory through the TEE secure storage service, while providing TEE isolated correctness verification for the calculation results of the convolution operation, and protecting the correctness of the convolution calculation results accelerated by the GPU in the REE. The deployment phase aims to protect the confidentiality and integrity of the deep learning model in the external memory, while the reasoning phase aims to protect the integrity of the model weights in the memory and the correctness of the reasoning results. First, the correctness of the convolution layer weights is ensured by comparing the hash signature in the TEE, and then the designed IFA algorithm is used to verify the convolution operation results accelerated by the GPU in the REE in the TEE to determine whether the convolution reasoning process has been attacked.
[0034] (3) The present invention proposes a verifiable model reasoning scheme for multi-TA collaboration, which offloads the IFA algorithm used for convolution calculation result verification to TEE for execution, and offloads the model reasoning task to the GPU in REE for reasoning acceleration. In this way, the correctness of the model reasoning result can be verified in the secure execution environment isolated by TEE, and the GPU of the heterogeneous edge platform can be used to accelerate the model reasoning in REE. The multi-TA collaborative reasoning design is to reduce the waiting time of the DarkneTV main thread. This scheme not only ensures the reliability of the convolution verification process, but also makes the model reasoning process do not need to wait for the completion of the convolution weight verification and convolution calculation result verification tasks. In this way, on the CPU+GPU heterogeneous edge platform, the convolution verification in TEE can be carried out simultaneously with the model reasoning accelerated by GPU in REE, while protecting the correctness of the model reasoning results and improving the speed of verifiable reasoning. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is the process of the DarkneTV deployment phase of the present invention;
[0036] Figure 2 It is the process of the DarkneTV reasoning phase on the CPU+GPU heterogeneous edge platform of the present invention;
[0037] Figure 3 It is a schematic diagram of the detection of the error insertion attack by DarkneTV of the present invention;
[0038] Figure 4 This is a verifiable reasoning flow chart of multi-TA collaboration of the present invention.
[0039] Figure 5 This is the inference result of the YOLOv4-tiny model under different attack amplitudes when the modification ratio is 2.00%.
[0040] Figure 6The figure shows a comparison of the verifiable inference speed and its acceleration ratio in the CPU and CPU+GPU modes of the present invention. DETAILED DESCRIPTION
[0041] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings.
[0042] The present invention proposes a verifiable edge learning reasoning method for CPU+GPU heterogeneous platforms. Based on the CPU+GPU collaborative computing capability of the heterogeneous edge platform and the TEE hardware isolation mechanism, an edge deep learning reasoning method that supports GPU parallel acceleration and TEE convolution computing verification is designed.
[0043] First, the IFA algorithm designed by the present invention is improved on the basis of the Freivalds algorithm, where the random vector elements The value range of is extended from {0,1} to the floating point number between (0.00,1.00]. This improvement reduces the missed detection rate of the Freivalds algorithm in a single detection and improves the attack detection accuracy of the IFA algorithm. This is because by enhancing the robustness of the convolution verification algorithm, the attacker's targeted modification of the convolution calculation result can still be detected. At the same time, the present invention adopts the method of vector left multiplication matrix to reduce the number of floating-point multiplication operations required for convolution verification, and introduces the maximum error threshold of each verification to allow a certain floating-point calculation error, thereby improving the calculation speed and effectiveness of convolution verification.
[0044] Secondly, the verifiable reasoning method DarkneTV designed by the present invention can detect error injection attacks in the deep learning reasoning process on the CPU+GPU heterogeneous edge platform, protect the integrity of the model weights in external storage and memory, and ensure the reliability of the edge deep learning reasoning results. Among them, "Darknet" means that the DarkneTV method implements deep learning reasoning based on the Darknet framework, "T" means the trusted execution environment (TEE), and "V" means verifiable. Therefore, "DarkneTV" represents a verifiable deep learning reasoning method based on Darknet and TEE. The basic idea is to offload the convolution verification task to the CPU core in the TEE to protect the reliability of the convolution verification process. In order to reduce time overhead, an asynchronous multi-threading method is adopted so that the model reasoning process executed in REE will not be interrupted by the convolution verification process executed in the TEE, but will be carried out simultaneously with the convolution verification process. Specifically, DarkneTV divides the verifiable reasoning process into a deployment phase and a reasoning phase. In the deployment phase, the present invention generates a hash signature of each layer of weights in TEE, and encrypts the model structure file, weight file and hash signature, and then saves them in the file system of REE. In the reasoning phase, the present invention ensures the correctness of the convolution layer weights by comparing the hash signatures in TEE, and verifies the convolution operation results accelerated by GPU in REE using the IFA algorithm to determine whether there is an attack on each convolution layer reasoning process. The present invention not only takes into account the integrity protection of the deep learning model weights in memory, but also provides confidentiality and integrity protection of the model weights in external memory through the TEE security storage service, and provides a TEE security isolation verification mechanism for the calculation results of the convolution operation, ensuring the correctness of the convolution calculation results during the model reasoning process, thereby improving the verifiability and reliability of heterogeneous edge deep learning reasoning. The present invention is adapted to a variety of CPU+GPU heterogeneous edge devices that support TEE, and uses the collaborative computing method of CPU and GPU to accelerate verifiable edge deep learning reasoning. At the same time, in order to reduce the waiting time of the DarkneTV main thread, a multi-TA collaborative convolution verification method is designed to further reduce the convolution verification time in the CPU+GPU collaborative reasoning process.
[0045] In summary, the present invention proposes a multi-TA collaborative verifiable edge learning and reasoning solution, which offloads the algorithm fault-tolerant verification process of convolution calculation to TEE, and accelerates model reasoning using GPU in REE, ensuring the correctness of the model reasoning results while utilizing the higher-performance GPU in the heterogeneous edge platform to accelerate the entire verifiable reasoning process.
[0046] 1. In this embodiment, under the premise that the deep learning model has been trained and the model weights have not been attacked, DarkneTV introduces a verifiable reasoning mechanism of CPU+GPU collaboration, which consists of two stages, namely the deployment stage and the reasoning stage.
[0047] Deployment phase:
[0048] The deployment phase process is as follows Figure 1 As shown in the figure, this stage aims to protect the confidentiality and integrity of the model structure files and weight files stored in the external memory, and ensure the correctness of the weights and model structures loaded into the memory during the inference stage. This stage needs to be performed in an offline or secure environment, unless the encrypted model structure and weights need to be updated, in which case this stage only needs to be performed once. DarkneTV first builds a deep learning model instance by reading the model structure file and the model weight file; then the model instance is transferred to the TA of TEE, which uses the SHA-256 algorithm to generate the hash signature HA1 corresponding to each layer of weight parameters, and then encrypts each model operator (including weight parameters) and its hash signature through the TEE secure storage function; after successfully generating the encrypted files of each model operator and its hash signature, it is stored in the ordinary file system of REE. These hash signatures will serve as an important basis for verifying the integrity of each layer of weight data in the subsequent inference stage.
[0049] Reasoning stage:
[0050] Figure 2 It shows the process of the verifiable reasoning stage on the CPU+GPU heterogeneous platform in the absence of soft errors and attacks. DarkneTV creates a thread pool, starts CA (ClientApplication) and establishes a connection with TEE, and starts TA1 to perform model loading LM operation and model decryption DM operation. LM (Load Model) means that TA1 reads the encrypted model file from the file system of REE, and DM (Decrypt Model) means that TEE decrypts the read encrypted file to obtain the model structure, the weight parameters A of each layer, and the hash signature HA1. After the model file is decrypted, the model structure and the weight data of each layer will be transferred to the shared memory of REE, while the hash signature remains in the secure memory of TA1.
[0051] After executing the LM and DM operations, the main thread of DarkneTV reads the model input data B from the external memory into the REE memory, and starts to use the GPU to perform the deep learning model inference task of the input. When performing the inference of the convolution layer, an idle child thread is called from the thread pool to create a connection with the TEE, and TA1 is activated to execute the weight verification step PC, and perform hash verification and calculation of the left formula in the IFA algorithm. Because the CPU cannot directly read the memory data of the GPU, and in order to reduce the performance overhead of memory data copying, DarkneTV uses the memory mapping method to map the memory data occupied by the convolution weight parameter A in the GPU to the shared memory. Then, the DarkneTV main thread transfers the pointer address of the memory mapping area to TA1, and TA1 reads the convolution weight parameter A and input data B through the shared memory. After the data reading is completed, TA1 enters the waiting state. During execution, TA1 will lock the thread that calls its interface, and the main thread of DarkneTV is mainly responsible for GPU parallel reasoning of deep learning models, so the convolution verification process cannot be called by the main thread of TA1. The main thread of DarkneTV will submit a task to the thread pool, allowing the idle threads in the thread pool to guide TA1 to complete the convolution weight verification step PC, while the main thread continues to execute the reasoning of the current convolution layer. The PC step generates a new hash signature HA2 for the read-in convolution weight parameter A, and determines whether it is the same as the HA1 previously stored in TA1's secure memory; if different, it means that the weight of the convolution layer in REE has been attacked, and the verification result and output error warning of the convolution layer are directly returned, and the reasoning process of the input instance executed by the main thread of DarkneTV is interrupted; if HA1 and HA2 are the same, it means that the weight of the convolution layer in REE memory has not been attacked, and the reasoning task of the input instance of the main thread continues to execute; further, TA1 performs the calculation of the left formula of IFA, that is, TA1 generates a random vector based on the size of the weight matrix A. And based on matrices A, B and random vectors Calculating vectors After that, TA1 temporarily enters a waiting state.
[0052] After waiting for the main thread to complete the convolution calculation, the main thread uploads the pointer of the output feature map C of the convolution calculation to TA2. TA2 then reads the content of C by itself and temporarily enters the waiting state. After the main thread submits the convolution verification task to the thread pool, it continues to execute the next layer of reasoning. The idle thread in the thread pool guides TA2 to perform SC verification and EC verification operations to calculate the right-hand side of the IFA algorithm and detect attacks. SC refers to the calculation of TA2 based on C and calculate EC refers to the upper limit of error ε calculated by TA2 based on A, B and C r , and calculate When the vector The infinite norm of Less than ε r , it means that the result of the convolution calculation is correct and the verification step of this layer ends; if this layer is not the last layer, the reasoning process continues. Otherwise, it means that the convolution calculation process is attacked and the convolution calculation result is wrong, so the reasoning of the input instance is terminated and an error warning is output. r and The calculation method of will be explained in detail later.
[0053] Figure 3 The figure shows the processing flow of DarkneTV for error insertion attacks. CASE 1 shows that when no error is detected, DarkneTV will normally perform convolution calculations and convolution verification steps such as PC, SC and EC. After completing the attack detection, TA2 enters a temporary waiting state and does not output any information. When HA1≠HA2 is detected in the PC stage, that is, when the integrity of the weight parameters (matrix A) in the memory is destroyed (as shown in CASE 2), the subsequent steps of TA1 and TA2 will no longer be executed, but will directly output error warnings and enter a waiting state, and interrupt the current input reasoning process of the DarkneTV main thread. When TA1 does not detect an attack on the convolution weight parameter A, but TA2 detects that the convolution calculation process (convolution calculation result C or input data B) is attacked (as shown in CASE 3), it will verify the vector in the EC stage. The infinite norm of is detected. At this time, DarkneTV's processing steps are basically the same as the error handling steps in Case 2. In the worst case, TA's secure memory will also be randomly modified by the attacker (as shown in Case 4). DarkneTV's convolution weight check and convolution verification can still take effect, because no matter whether the matrices A, B, C are tampered with or the feature vectors HA1, HA2, and In the case where precise modification is not possible, HA1 = HA2 and The probability of success is very low.
[0054] 2. Verifiable reasoning optimization with multi-TA collaboration.
[0055] In order to improve the security of TAs running in TEE, TEE adds the following four restrictions to TAs: First, each TA is only allowed to have one thread, but multiple TAs can be started at the same time; Second, the secure memory of each TA is private, and unauthorized access by other threads (including other TAs) is strictly prohibited, so multi-TA collaboration cannot execute fine-grained parallel strategies like REE's multi-threaded programs; Third, for synchronization security, when two interfaces of the same TA are called simultaneously by two threads of CA, one of the interfaces will be temporarily blocked, waiting for the completion of the call of the other interface, and then the other blocked interface will be awakened to perform the corresponding operation; Fourth, TEE's secure memory is small and is not suitable for supporting too many TAs running simultaneously.
[0056] In the CPU+GPU collaborative verifiable reasoning mode of the heterogeneous platform, if the parallel computing performance of the GPU significantly exceeds the single-threaded computing performance of the CPU in the edge device, it is possible that the main thread of DarkneTV has completed the convolution calculation before the weight verification in the PC stage is completed. At this time, the main thread of DarkneTV needs to wait for the verification of TA1 to be completed before transmitting the output matrix C of the convolution reasoning. This waiting process may give attackers an opportunity.
[0057] In order to reduce the waiting time of the DarkneTV main thread, the present invention designs a verifiable reasoning scheme with multi-TA collaboration (such as Figure 4 As shown). This solution takes into account the limitations of the TEE secure memory size in edge devices and uses three TAs to provide convolution weight verification and convolution reasoning verification for the verifiable deep learning model inference process on heterogeneous edge platforms. The three TAs are named TA1, TA2, and TAsync, where TA1 is mainly responsible for the verification step PC of the convolution weight parameter A, and TA2 is responsible for the verification steps SC and EC. TAsync is a TA used for data synchronization and secure communication between TA1 and TA2. When the interfaces of TA1 and TA2 are called, no new instance is created, but it communicates directly with the existing TAsync, so it can provide synchronization services for TA1 and TA2, and can be used to store intermediate variable values in the model reasoning verification process (such as and ).
[0058] like Figure 4 As shown, when the main thread of DarkneTV runs to the convolution layer, the matrices A and B are uploaded to the secure memory of TA1, and TA1 generates a random vector according to the size of A. and transferred to the secure memory of TAsync, after which TA1 performs the remaining steps of the PC check (hash checksum generation vector ); similarly, Generated It will also be uploaded to TAsync. After completing the convolution calculation, the main thread of DarkneTV can directly upload the convolution calculation result C to the secure memory of TA2 without waiting for the verification step of the PC stage to be completed. Then TA2 obtains the previously uploaded TA1 from TAsync. After the transfer is completed, TAsync is released TA2 starts to execute the detection steps of the SC stage and generates vector After that, get the PC phase generated by TA1 from TAsync DarkneTV uses a semaphore-based synchronization mechanism to ensure that TAsync already exists before performing EC verification. When After a successful transfer from TAsync to TA2, the secure memory it occupies in TAsync will be released.
[0059] 3. IFA algorithm design
[0060] Based on the Freivalds algorithm, the IFA algorithm expands the value range of random vector elements from {0,1} to floating point numbers in the interval (0.0,1.0]. This improvement reduces the single detection miss rate of attack detection on the convolution calculation process, so that the IFA algorithm can obtain high detection accuracy without repeated execution. At the same time, the robustness of the convolution verification algorithm is enhanced, making it easier to detect the attacker's targeted modification of the matrix multiplication calculation results, thereby improving the accuracy of attack detection. At the same time, the IFA algorithm uses the method of vector left multiplication matrix to reduce the number of floating-point multiplication operations required for convolution verification, and introduces the maximum error threshold for each verification to allow a certain floating-point calculation error, thereby improving the calculation speed and effectiveness of convolution verification.
[0061] The above advantages of the IFA algorithm are demonstrated as follows:
[0062] Assume that the two input matrices after the im2col convolution operation is converted into matrix multiplication are A and B, whose sizes are m×k and k×n respectively, and the output matrix is represented by C, whose size is m×n. The random vector is still Represents. Then the equation finally verified by the Freivalds algorithm is: Then the above equation can be transformed into A× Where 0 represents the zero matrix, according to the above equation and the matrix multiplication distribution ratio is When A×B=C, because A×BC=0, so when Any value of the elements of However, when the result of matrix multiplication C is modified by the attacker and becomes a new matrix C', then A×B-C'≠0, so only when The IFA algorithm will miss detection only when
[0063] For a more intuitive approach, define D = A × B - C' ≠ 0, then the equation becomes At this point, the above equation can be expanded as follows:
[0064]
[0065] Where D x,y represents the element at the matrix coordinate (x,y), ω x Representation vector The x-th element in the equation starts at 0. Then the above equation can be transformed into the following system of equations:
[0066]
[0067] If and only if a non-zero vector Only when is the solution of the equation group, the IFA algorithm will miss detection, thus effectively reducing the missed detection rate of attack detection. is a random vector with a low probability of being a solution to the system of equations, and Generated only in TEE. Due to the confidentiality of TEE, attackers cannot obtain the data stored in TEE secure memory. 's specific value, so it is impossible to crack it in a targeted manner.
[0068] Expanding random vectors The value range of can effectively reduce the missed detection rate of attack detection, but it also brings two new problems: On the one hand, because the IFA algorithm involves more floating-point operations, the time overhead of a single attack detection increases. For example, the calculation of the left form of the Freivalds algorithm only requires m×k multiplications, while the calculation of the right form of the Freivalds algorithm does not require multiplication. After the random vector value range is expanded to floating-point numbers between (0.0,1.0], the left form of IFA requires m×k+k×n multiplications, and the calculation of the right form of IFA requires m×n multiplications. On the other hand, since floating-point numbers in computers cannot represent all decimals, floating-point multiplication requires the mantissa of the result to be truncated to the range that the floating-point number can represent, and the discarded mantissa becomes a rounding error. Due to the rounding error of floating-point multiplication, the calculation result of A×B will not be strictly equal to C, and Nor is it strictly equal to These floating point errors are unacceptable for error injection attack detection, because if the attacker intentionally modifies the convolution calculation results, the large error range will make the IFA algorithm unable to distinguish whether it is a normal rounding error or an attacker's tampering. After research, it was found that these errors mainly come from the accumulation of rounding errors caused by floating point addition operations. The IFA algorithm requires multiple addition operations, the purpose of which is to compress the data of a row or column of the matrix into an element in the vector.
[0069] To solve the above two problems, the method of multiplying the vector by the matrix is adopted ( and vector ) replaces the method of multiplying the vector by the matrix in the Freivalds algorithm ( and vector ), avoid calculating vector and vector The floating point number is accumulated n times. Since the upper limit of the error of a single-precision floating point multiplication is 0.50×2 -23 , so we can use the formula Determine whether the convolution operation is attacked. Represents the error of a single calibration, which is calculated as follows: max(|v0|,|v1|,…,|v n-1 |), where |v i |, i∈{0,1,2,…,n-1} represents a vector The absolute value of each element of , that is, the value of the infinity norm of the vector is equal to the maximum absolute value of the vector elements. r represents the maximum acceptable error limit, ε r =λmk / 2 24 , λ is a constant value set artificially, usually set to 0.10, that is, if IFA calculates If the value does not exceed the upper limit of the error, it means that the result of the convolution calculation has not been attacked. Otherwise, it means that the result of the convolution calculation has been attacked or a soft error has occurred in the calculation process.
[0070] Table 1 IFA algorithm
[0071]
[0072] The IFA algorithm is shown in Table 1. Its input is the matrix A, B, C and their sizes m, k and n. The output of the algorithm is the judgment result (True or False) of whether the convolution operation result is reliable. True means that the convolution calculation process has not been attacked (i.e., reliable), while False means that the convolution calculation process has been attacked (i.e., unreliable), and the output convolution calculation result is incorrect. The 1st to 4th rows of Table 1 are the generated random vectors. The second line (rand()+1) / (RAND_MAX+1) is to ensure the random vector The value of the element in is not 0. Lines 5-6 are the left formula for calculating IFA Get vector The time complexity of these two steps is O(mk) and O(kn) respectively. Line 7 is the right-hand side of the IFA calculation. Get vector Its time complexity is O(mn). Line 8 is the calculation of this check Line 9 determines whether it is within the maximum error range and returns the verification result of the IFA algorithm.
[0073] In summary, the verifiable edge learning reasoning method DarkneTV proposed in the present invention for CPU+GPU heterogeneous platforms has the following advantages over the prior art: First, compared with the Freivalds algorithm, the IFA algorithm designed by the present invention can improve the accuracy of attack detection in the convolution calculation process and reduce the missed detection rate of its attacks; second, by encrypting and storing the deep learning model based on the TEE secure storage function, the integrity and confidentiality of the model in the external storage device are protected; at the same time, the hash check of the convolution weight parameters and the verification of the convolution calculation results protected by the TEE hardware isolation mechanism protect the integrity of the weight parameters in the device memory during the model reasoning process and the reliability of the deep learning model reasoning results. Third, the multi-TA collaborative verifiable reasoning scheme adopts an asynchronous mechanism to realize the simultaneous execution of the convolution weight check and verification on the CPU in the TEE on the heterogeneous platform and the GPU-accelerated deep learning model reasoning in the REE, which effectively improves the speed of verifiable deep learning reasoning on the heterogeneous edge platform while protecting the correctness of the deep learning model reasoning results.
[0074] 4. Implementation Cases
[0075] The present invention uses the Hikey 960 development board as a CPU+GPU heterogeneous edge platform to test the performance of DarkneTV and its effectiveness in the face of error injection attacks. The CPU of Hikey 960 is equipped with 4 CortexA73 cores with a maximum main frequency of 2.36GHZ and 4 CortexA53 cores with a maximum main frequency of 1.84GHZ. The GPU model is ARM Mali-G71MP8, with a main frequency of 1037MHZ. The Hikey 960 development board has 4GB LPDDR4 memory, of which 64MB is divided into TEE secure memory.
[0076] Table 2 describes the operating system and implementation dependencies used in the experimental test of the present invention. The operating system used in the present invention is Debian 11, and the kernel is Linux 4.19-hikey customized for Hikey960. TEE implementation uses OP-TEE3.20.0, and GPU parallel acceleration is implemented based on OpenCL 1.2.
[0077] Table 2 DarkneTV software dependencies
[0078]
[0079] The attack detection accuracy of the IFA algorithm and the verifiable reasoning speed of multi-TA collaboration are used as two core indicators to evaluate the performance of the verifiable reasoning method DarkneTV designed by the present invention for CPU+GPU heterogeneous platforms. At the same time, four classic deep learning models, Darknet19, Resnet18, YOLOv3-tiny and YOLOv4-tiny, are used to analyze the results of the implementation cases of the present invention.
[0080] (1) Error injection attack simulation
[0081] The IFA algorithm is based on the equation The difference between the left and right vectors is used to determine whether the convolution operation is attacked. First, the attacker's attack on the convolution calculation can be achieved by modifying the input A and B or the output C. However, the attacker's modification of the matrix A or B will be reflected in the convolution output matrix C, and the purpose of the attacker's modification of the convolution input data is also to cause the output of the modified convolution calculation result C, so measuring the attack detection performance of the IFA algorithm on the convolution output matrix C can effectively evaluate the attack detection accuracy and effectiveness of the IFA algorithm. In addition, the convolution output matrix C is mainly sensitive to the numerical changes before and after the attack, but not to the numerical changes after the attack. Therefore, the method of randomly modifying several elements in the convolution output matrix C is used to simulate the error injection attack on the convolution calculation result, and the element modification ratio and the element value modification amplitude l2 norm are used to control the realization of different error injection attacks. The modification ratio indicates the percentage of the number of modified elements in matrix C to the total number of elements in the matrix. The larger the value, the more elements modified by the attacker. The modification amplitude l2 norm indicates the l2 norm of the vector obtained by expanding the difference between the two matrices before and after the attacker modified matrix C. The larger the value, the greater the difference between the modified element value and the value of the original matrix response element.
[0082] (2) Random error injection attack case
[0083] In order to more intuitively demonstrate the impact of different degrees of error injection attacks on deep learning reasoning results, this paper takes YOLOv4-tiny as an example and measures the reasoning results under different attack amplitudes l2 when the modification ratio is 2.00%. Figure 5 As shown. Among them, Figure 5 (a) represents the normal reasoning result in the absence of attack; Figure 5 (b) is l2 = 0.19 × 10 -1 The modification amplitude and modification ratio of 2.00% attack the inference results of each convolutional layer in the model, compared with the inference results without attack ( Figure 5 As shown in (a), the bounding box size and position of the detected target objects have not changed, only the confidence of the three target objects has changed by ±0.02%. Figure 5 (c) shows the inference result when the value of the attack amplitude l2 norm increases to 1.00. Figure 5 Compared with (a), the size and position of the detected target object’s bounding box remain unchanged, but the confidence change of the target object increases to about ±0.61%. When the modification range of the error injection attack is not restricted, the inference results of YOLOv4-tiny after the attack are as follows: Figure 5As shown in (d), it may not be possible to correctly detect all target objects in the input image. This shows that even a modification ratio of only 2.00% can have a significant impact on the deep learning reasoning results, resulting in unavailability and serious errors in the reasoning results.
[0084] (3) Analysis of attack detection accuracy of IFA algorithm
[0085] In the present invention, the main task of the IFA algorithm is to detect whether the result calculated by the matrix multiplication in the im2col convolution algorithm is correct. The detection result can be divided into four situations: actually attacked and the IFA algorithm detects the attack (True Positive, TP), actually attacked but the IFA algorithm does not detect it (False Negative, FN), actually not attacked but the IFA algorithm believes it is attacked (False Positive, FP), actually not attacked and the IFA algorithm does not detect the attack (True Negative, TN). Therefore, the situation of using the IFA algorithm to verify the convolution calculation results can be regarded as a binary classification problem, and its accuracy can be evaluated by referring to the accuracy calculation method of the classification method. Assuming that n is used TP 、n TN 、n FP and n FN They represent the number of four different situations in the multiple attack detection results of the IFA algorithm. The attack detection accuracy rate p of the IFA algorithm can be calculated using the following formula: acc :
[0086]
[0087] Table 3. The accuracy of attack detection of YOLOv4-tiny verifiable reasoning under different modification ratios and modification amplitude l2 norms
[0088]
[0089]
[0090] Taking YOLOv4-tiny as an example, the above-mentioned error injection attack simulation method is used to perform random error insertion attacks on 10% of the convolutional layers in the model, and the attack detection accuracy of the IFA algorithm under different modification ratios and different modification amplitude l2 norms is tested, and the results are shown in Table 3. Among them, the first column of Table 3 represents the modification amplitude l2 norm of the simulated attack on the matrix C, the first row percentage data represents the modification ratio of the simulated attack on the elements of the matrix C, and the remaining percentage data represents the attack detection accuracy of the IFA algorithm. This embodiment shows that the attack detection accuracy of the IFA algorithm can reach more than 92.59%, which shows that the IFA algorithm has a higher attack detection accuracy. Under the same modification ratio, as the modification amplitude l2 norm value increases, the accuracy of the IFA algorithm also increases. Moreover, after the modification amplitude l2 norm of the attack reaches a certain threshold (such as 0.017), the IFA algorithm can reach a detection accuracy of 100.00%. This proves that when the modification ratio remains unchanged, there is a threshold for the modification amplitude that enables the IFA algorithm to detect all error injection attacks, which is sufficient to illustrate the applicability of the IFA algorithm in verifiable edge deep learning inference.
[0091] (4) Verifiable reasoning speed and acceleration ratio of multi-TA collaboration
[0092] Here, the verifiable reasoning accelerated by GPU on the CPU+GPU heterogeneous edge platform designed by the present invention is recorded as CPU+GPU verifiable reasoning. In order to illustrate the performance advantages of the DarkneTV method proposed by the present invention through comparative analysis of reasoning speed, a method of verifiable reasoning using only the CPU on the heterogeneous edge platform is introduced, which is recorded as CPU verifiable reasoning. Different from CPU+GPU verifiable reasoning, CPU verifiable reasoning uses the CPU for deep learning model reasoning and TEE-isolated convolution weight verification and convolution calculation verification at the same time, and does not use the GPU in the heterogeneous platform to accelerate model reasoning. What is the same between the two is that both use TEE to protect the integrity of the model weights on the heterogeneous edge platform and verify the reliability of the convolution calculation process.
[0093] Using image classification models (Darknet19 and Resnet18) and target detection models (YOLOv3-tiny and YOLOv4-tiny) as test models, we measured the inference speed under two verifiable inference modes and calculated the speedup ratio. The results are as follows: Figure 6 shown. Figure 6 It not only shows the inference speed of single TA and multi-TA verifiable reasoning in CPU and CPU+GPU modes, but also shows the verifiable reasoning speedup ratio of multi-TA compared to single TA and CPU+GPU mode compared to pure CPU mode. The CPU verifiable reasoning mode of single TA is the slowest, with an average speed of about Figure 4.53-6.82 seconds; the multi-TA collaborative CPU+GPU can verify the fastest inference speed, with an average speed of about 0.97-1.19 seconds per image.
[0094] Figure 6 The four broken lines representing the acceleration ratio are all greater than 1.00, which shows that both the multi-TA collaborative method and the GPU-accelerated verifiable reasoning method can help improve the speed of verifiable reasoning on the CPU+GPU heterogeneous edge platform. In the pure CPU mode, the acceleration ratio of multi-TA collaborative verifiable reasoning is 1.01-1.03 times that of single TA verifiable reasoning; while in the CPU+GPU mode, the acceleration ratio increases to 1.11-1.89 times. Compared with CPU+GPU verifiable reasoning, the acceleration effect of multi-TA collaboration in the CPU verifiable reasoning process is lower. This is due to two reasons: (1) The CPU performance on the heterogeneous edge platform is limited. The simultaneous execution of model reasoning tasks and TEE-isolated convolution weight verification and convolution calculation verification results in fewer idle computing resources, making it impossible to obtain a more ideal reasoning acceleration ratio. However, in the CPU+GPU verifiable reasoning mode, the model reasoning task is executed by the higher-performance GPU on the heterogeneous platform, and more CPU idle resources will be used to perform TEE-isolated convolution weight verification (PC verification) and convolution calculation verification (SC verification and EC verification), so that the multi-TA collaboration mechanism in this CPU+GPU verifiable reasoning mode can better play its advantages of multi-TA asynchronous collaborative computing. (2) When the speed of convolution reasoning and convolution weight verification (PC verification) does not match, the main thread often needs to wait for the PC verification step executed by the CPU in the TEE to complete before it can perform its subsequent convolution calculation verification (SC verification and EC verification). Since in the CPU verifiable reasoning process, convolution reasoning and convolution weight verification are both executed on the CPU core, and due to the complexity of convolution operations, the speed of convolution reasoning is often slower than that of convolution verification. In this way, the verification of convolution weights is completed before the convolution reasoning, and the main thread does not need to wait for the completion of the convolution verification step. On the contrary, during the CPU+GPU verifiable reasoning process, the convolution calculation is completed in parallel using OpenCL on a higher-performance GPU, which may complete the convolution verification step before the CPU. As a result, when only a single TA is used, the main thread needs to wait for the completion of the convolution weight verification step, which increases a certain amount of time overhead. The use of a multi-TA collaboration mechanism can effectively reduce the time overhead of the main thread waiting for the convolution verification to complete, thereby making the optimization effect of the multi-TA collaboration mechanism in the CPU+GPU verifiable reasoning mode more obvious.
[0095] When using a single TA for convolution check and verification in TEE, the acceleration ratio of CPU+GPU verifiable reasoning is 2.60-4.77 times that of CPU verifiable reasoning; after using the multi-TA coordination mechanism, the acceleration ratio increased to 4.56-5.57 times, which is 0.46-2.54 times higher than when using a single TA. It can be seen that after using the multi-TA coordination mechanism, the acceleration optimization effect of CPU+GPU verifiable reasoning is more significant. The reason is that the speed of GPU-accelerated verifiable model reasoning is mainly limited by the delay caused by the CPU executing convolution weight verification and convolution calculation verification in TEE. The use of multi-TA coordination mechanism can effectively reduce the delay of convolution weight verification and convolution calculation verification in TEE, thereby effectively improving the speed and acceleration ratio of CPU+GPU verifiable reasoning.
[0096] In summary, CPU+GPU verifiable reasoning can make full use of the GPU on the heterogeneous platform to accelerate the model reasoning process, and will further accelerate the convolution weight verification and convolution calculation verification executed on the CPU in the TEE through multi-TA collaboration, thereby effectively utilizing the CPU resources and GPU resources in the heterogeneous edge device to accelerate the speed of verifiable reasoning. On the contrary, the speed of CPU verifiable reasoning with multi-TA collaboration is limited by the model reasoning tasks performed by the CPU with weaker performance, and fails to utilize the higher performance GPU in the heterogeneous platform to accelerate model reasoning to reduce reasoning latency; the speed of GPU verifiable reasoning with a single TA is limited by the inability to utilize the multi-core CPU to perform convolution weight verification and convolution verification, and fails to effectively utilize the multi-core CPU to reduce the time overhead of convolution weight verification and convolution verification in the TEE. Therefore, the simultaneous use of multi-TA collaborative convolution weight verification and convolution calculation verification and GPU model reasoning acceleration mechanism can fully utilize the multi-core CPU and GPU computing resources on the CPU+GPU heterogeneous platform, so that the verifiable reasoning speed and acceleration ratio are maximized.
[0097] The above are preferred embodiments of the present invention. Any changes made according to the technical solution of the present invention, as long as the resulting functions do not exceed the scope of the technical solution of the present invention, belong to the protection scope of the present invention.
Claims
1. A verifiable edge learning reasoning method for CPU+GPU heterogeneous platform, characterized in that: DarkneTV implements verifiable reasoning and acceleration of deep learning models on edge devices through weight parameter verification and convolution calculation process verification performed in TEE, protecting the integrity of deep learning models and the correctness of reasoning results; the verifiable reasoning process is divided into a deployment phase and a reasoning phase; the deployment phase generates a hash signature of each layer of weights in the deep learning model in TEE, encrypts the model structure file, weight file and hash signature, and then saves them in REE as encrypted files; The reasoning stage verifies the integrity of the convolutional layer weights by comparing the hash signature in the TEE, and uses the designed IFA algorithm to verify the correctness of the convolution operation results in the REE to determine whether the reasoning process has been attacked.
2. According to the verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 1, it is characterized in that: The IFA algorithm specifically includes: The random vector elements in the Freivalds algorithm The value range of is extended from {0,1} to the floating point number between (0.00,1.00]; A and B are used to represent the two input matrices after the convolution calculation in the im2col convolution algorithm is converted into a matrix multiplication operation, and the sizes of A and B are m×k and k×n respectively, and C is used to represent the m×n feature matrix of the convolution calculation output; Defining vectors and vector Using the infinity norm To express the error between the calculation results on the left and right sides of the formula to be verified, the acceptable error upper limit ε is calculated according to the size of A, B and C. r , when the IFA algorithm calculates The value does not exceed the upper error limit ε r , it means that the convolution calculation result is correct, otherwise it means that the convolution calculation result has been attacked or a soft error has occurred in the calculation process.
3. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 2 is characterized in that: The upper error limit ε r The calculation formula is: r =λmk / 2 24 , where λ is an artificially set coefficient value.
4. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 1, characterized in that: The deployment phase is specifically as follows: DarkneTV first reads the model structure file and model weight file and builds a deep learning model instance; then it transfers the model instance to the TA of TEE, which encrypts each layer of the model through the secure storage function of OP-TEE, including encrypting the weight parameters of each layer of the model, and uses the SHA-256 algorithm to calculate the hash signature HA1 corresponding to the weight parameters of each layer; finally, the TEE secure storage service is used to generate encrypted files of the model operator and hash signature, and store them in the ordinary file system of REE.
5. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 1, characterized in that: The reasoning stage is specifically as follows: After DarkneTV finishes reading the encrypted file of the deep learning model, it creates a thread pool and establishes a session connection with TEE, and calls the corresponding TEEClient interface to start the security application TA1 running in TEE to decrypt the model structure data, the weight parameters of each layer, and the hash signature HA1, where the weight parameters of each layer of the network are recorded as matrix A; after decryption, the model structure and the weight parameters A of each layer are transferred to the memory of REE, but its hash signature HA1 is still retained in the secure memory of TA1; DarkneTV reads the input data of model reasoning from the external memory to the REE memory, where the input data is the image to be reasoned or the output feature map of the previous layer, and starts to use the GPU in the heterogeneous platform to reason about the deep learning model, where the input data is recorded as matrix B; during the reasoning process, the operator reasoning of each layer is first performed in the GPU. If the current layer is a convolution layer, its input weight parameter A, input data B, and the output feature map C of the convolution calculation are transferred to the TEE in a memory mapping manner, and the weight parameter A is hashed and the convolution operator reasoning process is verified in the TEE to verify the integrity of the convolution layer parameters and verify the correctness of the convolution calculation results; If the current layer is a non-convolutional layer, since the probability of it being attacked by error injection is very low, the operator inference is performed directly in the GPU, without the need to perform hash verification of the weight parameter A and correctness verification of the output feature map C in the TEE; each layer in the deep learning model is executed in sequence until the inference of all layers of the model is completed and the prediction results are output.
6. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 5, characterized in that: When the model inference reaches the convolution layer, DarkneTV uses the memory mapping method to map the memory data stored in the GPU to the shared memory area of the TEE. The memory data stored in the GPU includes the convolution layer weight parameter A and input data B. Then the DarkneTV main thread uploads the pointer address of the weight parameter A and the input data feature map B in the memory mapping area to TA1, and then TA1 reads A and B from the shared memory to the TEE secure memory. After the data is read, TA1 temporarily enters the waiting state; The main thread of DarkneTV submits a task to the thread pool to start the idle thread in the thread pool and execute TA1 to perform the PC verification step; At the same time, the main thread of DarkneTV continues to perform inference on the current convolutional layer; After the main thread completes the inference of the convolution layer, the main thread uploads the pointer of the output feature map C of the convolution calculation to TA2; TA2 reads the output feature map C and returns; the main thread submits a task to the thread pool and continues to execute the inference tasks of the subsequent layers. The idle thread in the thread pool starts TA2 asynchronously and executes the SC verification step and the EC verification step.
7. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 6 is characterized in that: The PC verification steps are specifically as follows: TA1 generates a random vector based on the dimension of the read weight parameter A and the designed IFA algorithm The vector It is composed of floating point numbers in the interval (0.0,1.0]. TA1 uses the SHA-256 algorithm to generate a new hash signature for the read convolution layer weight parameter, recorded as HA2, to determine whether it is the same as HA1 stored in TA1's secure memory. If they are different, it means that the weight parameter A of this layer in REE memory has been attacked, and an error warning is directly returned and output, and the current convolution layer reasoning of the DarkneTV main thread is terminated. If they are the same, it means that the convolution weight of this layer in REE memory has not been attacked, then TA1 generates a new hash signature based on the convolution weight parameter A, input data B and random vector. Generate vector in Then TA1 temporarily enters the waiting state, waiting for the main thread to complete the convolution calculation.
8. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 6, characterized in that: The SC verification step and the EC verification step are specifically as follows: SC check: TA2 obtains random vector And according to the read output feature map C and Generate vector ,in EC verification: Based on the IFA algorithm, TA2 calculates the upper limit of error ε according to the size of A, B and C r , where ε r =λmk / 2 24 ; TA2 obtains the vector generated in TA1 And calculate When the vector The infinite norm of Less than the upper limit of error ε r , it means that the result of the convolution calculation is correct, the verification step of the convolution layer is completed, and TA2 temporarily enters the waiting state; when the vector The infinite norm of Greater than ε r , it means that the output feature map C of the convolution calculation is attacked due to the convolution calculation process or the input data B, resulting in an error in the convolution reasoning result. At this time, the detection result is returned to REE, and an error warning prompt is displayed when the reasoning result of the input data is output.
9. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 6, characterized in that: In the PC verification, SC verification and EC verification steps, TAsync is used to store the intermediate results of the verification process and communicate securely with TA1 and TA2: TA1 generates random vectors After that, TA1 then performs the remaining steps of the PC check until vector Analogy vector It is also transferred to the secure memory of TAsync; TA2 obtains the data uploaded by TA1 from TAsync After that, read the output feature map C and generate vector At the same time, TA2 obtains the data uploaded by TA1 from TAsync. And perform the remaining tasks of EC verification.
10. The verifiable edge learning reasoning method for CPU+GPU heterogeneous platform according to claim 9, characterized in that: DarkneTV uses a synchronization mechanism to ensure that TAsync exists before EC verification. data.
Citation Information
Patent Citations
TEE resource orchestration method, system and device in NFV, and storage medium
CN116208501A
Edge end model protection method and system based on authorization verification mechanism
CN117313049A
Floating-point number matrix multiplication security outsourcing verification method based on TEE and GPU
CN118036064A
Vehicle-mounted video target detection method based on deep learning
WO2020181685A1
Cited By
Data encryption processing method and device, server and storage medium
CN121239475A
Neural network hardware reasoning fault tolerance method and system for BNCT radiation environment and medium
CN122309231A
