Edge calculation collaborative reasoning method for adaptive model segmentation, medium and equipment
Through the edge computing collaborative reasoning method of adaptive model segmentation, the model segmentation strategy is optimized using self-supervised agent tasks and asymmetric quantization technology, solving the problem of limited memory and computing power of terminal devices, and achieving efficient computing segmentation and storage optimization.
Patent Information
- Application Number
- CN202510464247.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-08-01
AI Technical Summary
The memory size and computing power of the terminal device are limited, making it difficult to efficiently deploy deep neural network models, and the existing methods have failed to effectively solve the computing delay and accuracy requirements between the terminal device and edge nodes.
Adaptive model segmentation method is adopted, and edge computing collaborative reasoning of adaptive model segmentation is used, self-supervised agent tasks and asymmetric quantization technology are used, combined with graph theory and deep reinforcement learning, model segmentation strategy is optimized, computational complexity is reduced and storage pressure is alleviated.
It realizes efficient computing segmentation between the terminal device and the edge node, reduces the computational complexity and storage pressure, and meets the delay and accuracy requirements of user inference tasks.
Smart Images

Figure CN120409669A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of collaborative inference research in resource-constrained edge computing environments, and particularly relates to an edge computing collaborative inference method, medium, and device for adaptive model segmentation. Background Art
[0002] With the advent of the 5G era, more and more intelligent devices have been put into the lives of the general public and play an increasingly indispensable role in assisting users' production and life. In different production and life scenarios, edge computing plays an important role, and the rise of artificial intelligence has also brought new challenges to edge computing. Deploying artificial intelligence services based on Deep Neural Networks (DNN) to the edge closer to users can more efficiently complete users' inference tasks. And with the development of technology, terminal devices also have a certain inference ability, which enables artificial intelligence (AI) inference tasks that require deep learning to be realized on terminal devices closer to the user side, providing more diverse implementation methods for edge computing.
[0003] However, since terminal devices have limitations in memory size and computing power compared to edge nodes and the cloud, and DNN models often have complex structures and certain requirements in computing power, there are certain challenges in deploying them on terminal devices. For the problem of limited memory size of terminal devices, methods such as model compression and streamlining are often adopted. For the problem of limited computing power of terminal devices, the optimization of model computing power can be achieved through methods such as end-edge collaboration and resource allocation. These methods can all meet the latency requirements and accuracy requirements of users' inference tasks. Therefore, deploying DNN on resource-constrained terminal devices has always been a hot issue in the field of edge intelligence. To solve this problem, not only the storage and computing power of terminal devices need to be considered, but also the real-time and accuracy requirements of task processing need to be considered. Current research on deploying DNN on terminal devices mainly focuses on how to use more efficient model compression methods and model segmentation methods. The model segmentation method is based on the hierarchical structure of the DNN model network, finds the most suitable segmentation position among all possible segmentation methods, divides the model into two parts, and deploys them to the edge side and terminal devices respectively. The cloud serves as the decision-making center, and a three-level collaborative framework of end-edge-cloud can be formed. After user data is collected by the terminal intelligent device, it is directly processed by a part of the DNN model locally, and then the processed features are transmitted to the edge side through wired or wireless networks. After the edge side obtains the features, it processes them in another part of the model, and after the processing is completed, it transmits the inference result to the terminal device. The cloud is responsible for the data analysis of segmentation decisions and the further processing of the DNN model. Summary of the Invention
[0004] An edge computing collaborative inference method, device, and storage medium based on adaptive model segmentation proposed by the present invention can at least solve one of the technical problems in the background art.
[0005] To achieve the above object, the present invention adopts the following technical solutions:
[0006] An edge computing collaborative inference method based on adaptive model segmentation includes the following steps
[0007] S1. Obtain the historical data collected by the terminal device and pre-train the deep neural network model DNN;
[0008] S2. Quantize the parameters of the pre-trained DNN model using an asymmetric quantization method and adjust the model accuracy through real data;
[0009] S3. Analyze the hierarchical characteristics of the quantized DNN model, calculate the computation delay and data output volume of each layer of the model, and construct a directed acyclic graph DAG of the quantized model based on the chain structure and multi-branch structure of the DNN model;
[0010] S4. Based on the DAG and combined with the way of the network flow graph in graph theory, obtain all the dividable strategies in the quantized DNN model by combining the iterative algorithm Ford-Fulkerson based on breadth-first search;
[0011] S5. Divide the quantized DNN model and construct a Markov decision process MDP, and solve the optimal division strategy through the DQN method in deep reinforcement learning.
[0012] Further, the pre-training method of the deep neural network model DNN in step S1 of the present invention includes:
[0013] S110. Collect unlabeled raw data related to the target domain;
[0014] Construct a large-scale heterogeneous data set through data cleaning, denoising, and standardization processing, and the data scale satisfies:
[0015] |D pretrain |≥N min
[0016] where D pretrain is the data scale for pre-training, and N min is the preset threshold of the domain data volume;
[0017] S120. Design a self-supervised proxy task for feature representation learning;
[0018] Apply random augmentation operations to the input data X to generate positive sample pairs Maximize the mutual information of positive sample pairs through feature similarity, and the loss function is:
[0019]
[0020] where is the contrastive loss; exp(·) is the exponential function used to convert the similarity score to a positive number and amplify the similarity difference; s(·) is the similarity metric function used to measure the similarity between two feature vectors; f θ is the feature encoder with parameter θ, and the image input is converted into a feature vector through f θ (·); τ is the temperature coefficient used to adjust the distribution of the similarity score and control the attention degree of the model to "hard samples";
[0021] S130. Update the model parameter θ using the stochastic gradient descent algorithm, and the optimization objective is:
[0022]
[0023] After the training is completed, save the parameters of the model encoder part and generate a pre-trained model
[0024] Furthermore, the model accuracy adjustment method in step S2 of the present invention includes:
[0025] S210. For the given original full-precision DNN model weight matrix: W ∈ R m×n , randomly select samples from the training set of the given N-layer DNN model as the calibration dataset D calib to statistically analyze the weight distribution of all network layers i ∈ {1, 2,..., N}, and obtain the global extreme values of the weights of each layer:
[0026]
[0027] where W i is the weight matrix of the i-th layer, and respectively represent the minimum and maximum values of the weights in the i-th layer;
[0028] S220. Use the asymmetric quantization method to quantize the weights of each layer by dynamically adjusting the quantization range to map floating-point values to the integer domain;
[0029] The scaling factor S i and zero point Z i of the i-th layer are:
[0030]
[0031] Then the quantization formula is:
[0032]
[0033] Among them, b is the quantized bit width. The present invention selects 8-bit quantization. round(·) is a rounding function. is the quantized weight;
[0034] S230: Select a part of the real data D from the collected data set adj to adjust the quantized model and ensure the accuracy of DNN model inference;
[0035] Calculate the weight quantization error of the i-th layer of the model
[0036]
[0037] Among them, W i (j, k) represents the element in the j-th row and k-th column of the original weight matrix. is the corresponding quantized value.
[0038] Furthermore, the method for constructing a directed acyclic graph DAG in step S3 of the present invention includes:
[0039] S310: Perform further inference on the complete DNN model through real input samples, and record the execution timestamps and data output amounts of each layer in the continuous calculation state during the inference process, and aggregate the multi-round inference data to obtain the average values of the hierarchical inference latency and data output amount;
[0040] S320: Through the quantized DNN model, the process of constructing the DAG of the model is as Figure 3 shown, and its structure is represented as G=(V, E), where:
[0041] V={v0, v1, v2,..., v n}
[0042] V represents the set of nodes in the DNN. v0 represents the input layer. Each node v i corresponds to a computing unit in the network; is the set of directed edges. The edge e ij =(v i , v j ) represents that the data flows from v i to v j . The weight of the directed edge e ij represents the data output amount of v i , and there is no loop in the DAG.
[0043] Further, all the divisible policy methods in step S4 of the present invention include:
[0044] S410: Search for all divisible edges in the DAG;
[0045] In graph theory, the definition of a cut point is: in a DAG, if the deletion of a certain node and all its associated edges destroys the connectivity of the original graph, then this node is called a cut point. From this, the definition of a cut edge can be extended: if the deletion of a certain directed edge in the DAG results in unreachable nodes or broken paths in the graph, then this edge is called a cut edge. Represent all the divisible edges as E div ;
[0046] S420: Construct a network flow graph based on the divisible edges;
[0047] For the multi-branch structure existing in the DNN model, this structure is called a multi-branch block, and a network flow graph is constructed;
[0048] Each edge has a capacity cap(v i , v j ) and a flow f(v i , v j ), satisfying: f(v i , v j ) ≤ cap(v i , v j ); In the network flow graph, define the residual network G f = (V, E f ):
[0049] E f = {(v i , v j ) | cap f (v i , v j ) = cap(v i , v j ) - f(v i , v j )}
[0050] where, E f represents the set of residual network edges. If cap f (v i , v j ) = 0, then
[0051] Further, the method for solving the optimal segmentation policy in step S5 of the present invention includes:
[0052] S510: Construct the model segmentation process as a Markov decision process;
[0053] Assume that a DNN model consists of H layers, and the data output volume of the i-th layer is represented by d i which is denoted as, and the inference latency on the user-side terminal device is represented by denoted as, and the inference latency on the edge server is represented by denoted as, where H ∈ Z + , 1 < i ≤ H; in the model splitting problem, the network bandwidth and computational load of the transmission link between the terminal device and the edge server are only determined by the current state and the splitting strategy; therefore, the model splitting problem is modeled as a five-tuple Markov decision process:
[0054] M = (S, A, P, R, γ)
[0055] where γ represents the discount factor, which is used to measure the importance of future rewards, indicating that more distant rewards will be attenuated at a ratio of γ; S represents the state space, and the state at time t is represented as:
[0056]
[0057] where b t represents the bandwidth in the environment where the current terminal device is located, and respectively represent the computing power of the current terminal and the computing power of the edge server; d t represents the data output volume at the current splitting point; A represents the action space, which is the set C of splittable strategies generated in step four, and the action a t at time t is represented as:
[0058]
[0059] P represents the state transition probability;
[0060] R represents the reward function, which is in the form of multi-objective optimization, mainly focusing on the computing latency in the terminal device and the edge server and the data transmission latency. The calculation formula is:
[0061]
[0062] where t local (k), t edge (k) and t trans (k) respectively represent the local computing delay, the edge-side computing delay, and the transmission delay of the data output volume d k after the model is split at the k-th layer; when the model is deployed, only the quantized model is deployed on the terminal device, then the quantization loss l q (k) at the terminal device is:
[0063]
[0064] The reward function R is expressed as:
[0065] R = -[(1 - ω(B))(t local (k) + t trans (k)) + ω(B)·l q (k) + t edge (k)]
[0066] Among them, the bandwidth function ω(B) with the bandwidth B as the independent variable represents the adaptive weight to achieve dynamic optimization. When the bandwidth is small, the optimization will pay more attention to reducing the time delay; when the bandwidth is large, the optimization will pay more attention to reducing the quantization loss to improve the precision of inference; ω(B) is expressed as:
[0067] ω(B) = 1 - e -αB
[0068] S520: The DQN algorithm is used to solve the Markov decision process (MDP) problem in the discrete action space, and the optimal segmentation strategy k at time t is obtained * .
[0069] On the other hand, the present invention also discloses a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor is caused to execute the steps of the above method.
[0070] On yet another aspect, the present invention also discloses a computer device including a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of the above method.
[0071] As can be seen from the above technical solutions, for the NP-hard problem of model segmentation strategy search, the present invention abstracts the DNN model structure into a directed acyclic graph (DAG), and generates a set of feasible segmentation strategies based on the network flow graph theory. By introducing the Edmonds-Karp algorithm to solve the minimum cut problem of the multi-branch structure, the search for the optimal segmentation point with exponential complexity is transformed into the maximum flow calculation within polynomial time, significantly reducing the computational complexity. At the same time, by pre-screening the set of feasible segmentation strategies as the action space of DQN, the problem of action space explosion in traditional reinforcement learning is effectively avoided. And in the Markov decision process (MDP) modeling process of the model segmentation problem, a bandwidth-sensitive reward function is designed to achieve dynamic adjustment of the segmentation strategy. And through the way of model compression, the storage pressure of the terminal device for running the DNN model is alleviated. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 It is a schematic flowchart of the method of the present invention;
[0073] Figure 2 DAG schematic diagram for constructing the DNN model of the present invention;
[0074] Figure 3 Schematic diagram for constructing a network flow graph based on the DAG;
[0075] Figure 4 Flowchart of the iterative algorithm Edmonds-Karp;
[0076] Figure 5 Flowchart of the DQN algorithm. Detailed implementation manners
[0077] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention.
[0078] As Figure 1 shown, the edge computing collaborative inference method based on adaptive model segmentation described in this embodiment includes the following steps:
[0079] S1. Obtain the historical data collected by the terminal device and pre-train the deep neural network model DNN;
[0080] S2. Quantize the parameters of the pre-trained DNN model by using the asymmetric quantization method, and adjust the model accuracy with a small amount of real data;
[0081] S3. Analyze the hierarchical characteristics of the DNN model, calculate the calculation delay and data output volume of each layer of the model, and construct a directed acyclic graph DAG of the quantized model based on the chain structure and multi-branch structure of the DNN model;
[0082] S4. Based on the DAG and in combination with the network flow graph in graph theory, obtain all the dividable strategies in the DNN model by using the iterative algorithm Ford-Fulkerson based on breadth-first search;
[0083] S5. Divide the DNN model and construct a Markov decision process MDP, and solve the optimal division strategy by using the DQN method in deep reinforcement learning.
[0084] The following elaborates on each step in detail:
[0085] S1. Obtain the historical data collected by the terminal device and pre-train the deep neural network model DNN;
[0086] The pre-training method of the deep neural network model DNN includes:
[0087] S110. Collect unlabeled raw data related to the target domain;
[0088] Construct a large-scale heterogeneous dataset through data cleaning, denoising, and normalization processes, requiring the data scale to satisfy: |D pretrain |≥N min
[0089] where D pretrain is the data scale for pre-training, and N min is the preset threshold for the amount of domain data, and ensure that the data distribution covers the diversity of actual application scenarios;
[0090] S120. Design a self-supervised proxy task for feature representation learning,
[0091] Apply random augmentation operations to the input data X (X ∈ D pretrain ) to generate positive sample pairs Maximize the mutual information of positive sample pairs through feature similarity, and the loss function is:
[0092]
[0093] where, is the contrastive loss. exp(·) is the exponential function used to convert the similarity score to a positive number and amplify the similarity difference. s(·) is the similarity metric function used to measure the similarity between two feature vectors. f θ is the feature encoder with parameter θ, and converts the image input into a feature vector through f θ (·). τ is the temperature coefficient used to adjust the distribution of similarity scores and control the model's attention to "hard samples";
[0094] S130. Update the model parameter θ using the stochastic gradient descent algorithm, and the optimization objective is:
[0095]
[0096] After training is completed, save the parameters of the model encoder part and generate a pre-trained model
[0097] S2. Quantize the parameters of the pre-trained DNN model using the asymmetric quantization method and adjust the model accuracy with a small amount of real data;
[0098] S210: For the given original full-precision DNN model weight matrix: W ∈ R m×n , randomly select a small number of samples from the training set of the given N-layer DNN model as the calibration dataset D calibTo count the weight distribution of all network layers \(i\in\{1, 2, \ldots, N\}\) and obtain the global extreme values of the weights for each layer:
[0099]
[0100] Among them, \(W\) i is the weight matrix of the \(i\)-th layer, and represent the minimum and maximum values of the weights in the \(i\)-th layer respectively.
[0101] S220: Adopt an asymmetric quantization method to map floating-point values to the integer domain by dynamically adjusting the quantization range, and quantize the weights of each layer;
[0102] The scaling factor \(S\) i and zero point \(Z\) i for the \(i\)-th layer are:
[0103]
[0104] Then the quantization formula is:
[0105]
[0106] Among them, \(b\) is the bit width after quantization, and the present invention selects 8-bit quantization. \(round(\cdot)\) is the rounding function, is the quantized weight.
[0107] S230: Select a part of the real data \(D\) adj from the collected dataset to adjust the quantized model and ensure the accuracy of DNN model inference;
[0108] Calculate the weight quantization error of the \(i\)-th layer of the model:
[0109]
[0110] Among them, \(W\) i \((j, k)\) represents the element in the \(j\)-th row and \(k\)-th column of the original weight matrix, is the corresponding value after quantization.
[0111] S3. Analyze the hierarchical characteristics of the DNN model, calculate the computational latency and data output volume of each layer of the model, and construct a directed acyclic graph DAG of the quantized model based on the chain structure and multi-branch structure of the DNN model;
[0112] The method for constructing the directed acyclic graph DAG includes:
[0113] S310: Perform forward inference on the complete DNN model using real input samples, and during the inference process, record the execution timestamps and data output volumes of each layer in the continuous calculation state based on the built-in performance analysis tool torch.autograd.profiler in Pytorch, and aggregate the inference data of multiple rounds to obtain the average layer-by-layer inference latency and data output volume.
[0114] S320: Construct the DAG process of the model through the quantized DNN model.
[0115] Its structure is represented as G=(V, E), where:
[0116] V={v0, v1, v2,..., v n}
[0117] V represents the set of nodes in the DNN, and v0 represents the input layer. Each node v i corresponds to a computational unit in the network. E is the set of directed edges. The edge e ij =(v i , v j ) indicates that data flows from v i to v j . The weight of the directed edge e ij represents the data output volume of v i , and there are no loops in the DAG.
[0118] S4. Based on the DAG and combined with the way of the network flow graph in graph theory, obtain all the partitionable strategies in the DNN model by combining the iterative algorithm Ford - Fulkersonn based on breadth - first search.
[0119] The method of obtaining all the partitionable strategies in the DNN model includes:
[0120] S410: Search for all the partitionable edges in the DAG.
[0121] In graph theory, the definition of a cut point is: in a DAG, if deleting a certain node and all its associated edges destroys the connectivity of the original graph, then this node is called a cut point. Then, by extension, a cut edge can be defined: if deleting a certain directed edge in the DAG results in unreachable nodes or broken paths in the graph, then this edge is called a cut edge. Represent all the partitionable edges as E div .
[0122] S420: Construct a network flow graph based on the partitionable edges.
[0123] As Figure 3 shown, for the multi - branch structure existing in the DNN model, this structure is called a multi - branch block, and construct a network flow graph.
[0124] Each edge has capacity cap(v i , v j ) and flow rate f(v i , v j ), satisfying: f(v i , v j )≤cap(v i , v j ). In the network flow graph, define the residual network G f =(V, E f ):
[0125] E f ={(v i ,v j )|cap f (v i ,v j )=cap(v i ,v j )-f(v i ,v j )}
[0126] Among them, E f Represents the set of residual network edges, if cap f (v i , v j )=0, then The cutting method shown in cut represents a feasible segmentation method in the network flow graph.
[0127] 1. Add source node o and sink node e to the original DAG, representing terminal node and edge node respectively. Define all edges e ij =(v i , v j ) has a capacity of cap(v i , v j ), representing node v i The inference delay of
[0128] 2. Define all nodes v connected to the source point s i Capacity The value of node v i The inference latency executed on the terminal device. Similarly, the capacity of all nodes connected to the sink e is Represents node v i The latency of inference executed on the edge server;
[0129] 3. When node v i When the out-degree of node v is not less than 1, iFor all edges connecting to nodes in subsequent nodes with v i the capacity of the edge is v i for the inference latency, then multiple edges will be repeatedly calculated when calculating its inference latency. Therefore, a virtual node v' is introduced i to replace v i , as shown in Figure 3 and connect v i to v' i , then v' i the connections between v' and subsequent nodes are represented by dashed lines, and the capacity cap(v' i , v j ) = +∞. The set of all virtual nodes in the multi-branch block is denoted as V V .
[0130] S430: Based on the maximum flow minimum cut theory, use the Ford-Fulkerson algorithm based on breadth-first search (BFS), that is, the Edmonds-Karp algorithm to solve the minimum cut problem of the network flow graph of the multi-branch block. The calculation flow chart is as shown in Figure 4 . By calculation, the optimal segmentation method in the multi-branch block is obtained, which is composed of the combination of edges in the multi-branch block and is denoted as E' div .
[0131] The set of feasible segmentation strategies of the DNN model can be expressed as:
[0132] C = {E div , E' div}
[0133] And C has the following form:
[0134] C = {(v2, v3), ((v3, v6), (v5, v7), (v4, v9)), (v9, v 10 )}
[0135] Among them, the calculation process of the iterative algorithm Ford-Fulkerson is as follows:
[0136] Step 1. Initialize the residual network: Convert the original network flow graph into a residual network. The initial residual capacity cap ij of each edge e f (v j , v i ) = cap(v i , v j ), and the initial residual of the reverse edge is set to cap f (v j , v i ) = 0;
[0137] Step 2. Use BFS to find an augmenting path: Starting from the source node o, use breadth-first search (BFS) to find a path from the source node to the sink node e in the residual network, ensuring that the residual capacity cap f (v i ,v j ) > 0 for all edges on the path. BFS ensures that the augmenting path found each time is the shortest path;
[0138] Step 3. If a path from the source node to the sink node can still be found in the residual network, execute:
[0139] (1) Calculate the minimum residual of the path: Find the minimum residual capacity of all edges on the current augmenting path:
[0140] Δf = min{c f (v i ,v j ) | (v i ,v j ) ∈ the current augmenting path}
[0141] This value determines the maximum flow that can be pushed to the sink node in this iteration;
[0142] (2) Accumulate the maximum flow: Add the Δf obtained in (1) to the total flow F:
[0143] F ← F + Δf
[0144] (3) Update the residual network: Forward pass update: Decrease the residual capacity of each edge on the path from o to e:
[0145] c f (v i ,v j ) ← c f (v i ,v j ) - Δf
[0146] Backward edge update: Increase the residual capacity of each edge on the corresponding path from e to o:
[0147] c f (v j ,v i ) ← c f (v j ,v i ) + Δf
[0148] Step 4, Output the split edge combination: If no path from o to e can be found in the residual network, in the final residual network, all nodes reachable from the source node o are marked using BFS to form a set O, and the remaining nodes automatically belong to set E. Then, the cut edges in the output multi-branch block are the directed edges between the boundary nodes of O and E.
[0149] S5. Split the DNN model and construct a Markov decision process MDP, and solve for the optimal splitting strategy using the DQN method in deep reinforcement learning
[0150] The method for solving the optimal splitting strategy includes:
[0151] S510: Construct the model splitting process as a Markov decision process. Assume a DNN model consists of layers. The data output volume of the i-th layer (1 < i ≤ N) is represented by d i and its inference latency on the user-side terminal device is represented by and its inference latency on the edge server is represented by In the model splitting problem, the network bandwidth and computing load of the transmission link between the terminal device and the edge server are only determined by the current state and splitting strategy. Therefore, the model splitting problem can be modeled as a five-tuple Markov decision process (MDP):
[0152] M = (S, A, P, R, γ)
[0153] where γ represents the discount factor, which is used to measure the importance of future rewards, indicating that more distant rewards will be attenuated at a rate of γ. S represents the state space, and the state at time t can be represented as:
[0154]
[0155] where b t represents the bandwidth in the environment where the current terminal device is located, and represent the computing power of the current terminal and the computing power of the edge server respectively. d t represents the data output volume at the current splitting point. A represents the action space, which is the set C of splittable strategies generated in Step 4, and the action a t at time t can be represented as:
[0156]
[0157] P represents the state transition probability, which can be automatically realized through environment interaction in the subsequent solution methods of the invention, without explicitly modeling the transition probability matrix.
[0158] Let \(R\) denote the reward function, which is designed in the form of multi-objective optimization, mainly focusing on the computational latency and data transmission latency in the terminal device and the edge server. The calculation formula is as follows:
[0159]
[0160] where \(t\) local (k), \(t\) edge (k) and \(t\) trans (k) respectively represent the local computational latency after the \(k\)-th layer segmentation of the model, the computational latency at the edge, and the transmission latency of the data volume \(d\) k at the \(k\)-th layer. When the model is deployed, since only the quantized model is deployed on the terminal device, the quantization loss \(l\) q (k) at the terminal device is:
[0161]
[0162] The reward function \(R\) can be expressed as:
[0163] \(R = -[(1 - \omega(B))(t\) local (k)+t\) trans (k))+\omega(B)\cdot l\) q (k)+t\) edge (k)]
[0164] where the bandwidth function \(\omega(B)\) with the bandwidth \(B\) as the independent variable represents the adaptive weight to achieve dynamic optimization. When the bandwidth is small, the optimization will focus more on reducing the latency; when the bandwidth is large, the optimization will focus more on reducing the quantization loss to improve the accuracy of inference. \(\omega(B)\) is expressed as:
[0165] \(\omega(B)=1 - e\) -αB
[0166] S520: Use the DQN algorithm to solve the Markov decision process (MDP) problem in the discrete action space and obtain the optimal segmentation strategy \(k\) at time \(t\) * .
[0167] As Figure 5 shown, the DQN algorithm process is as follows:
[0168] Step 1. Initialization: Initialize the evaluation network parameters \(\theta\) and set the target network parameters \(\theta'=\theta\); Initialize the capacity of the experience replay pool to \(M\) and the update step size to \(N\);
[0169] Step 2. Input the current state \(s\) t into the evaluation network to obtain the Q-values \(Q(s\) t , a, \(\theta)\) of all actions. Select the action \(a\) through the \(\epsilon\)-greedy strategy tRandomly select an action with probability ∈, and select the action with the maximum Q value with probability 1 - ∈. By executing action a t , obtain the new state s t+1 and the immediate reward r t , and store (s t , a t , r t , s t+1 ) in the experience replay pool;
[0170] Step 3: Randomly sample a batch of experiences (s t , a t , r t , s t+1 ) from the experience replay pool, break the data correlation, and use the target network to calculate the maximum Q value of s i+1 :
[0171] y i = r i + γ·maxQ(s i+1 , a'; θ′)
[0172] where γ is the discount factor. Use the evaluation network to predict the current Q value Q(s i , a i , θ), and use the mean square error between the predicted Q value and the target Q value as the loss:
[0173]
[0174] Update the evaluation network parameter θ by gradient descent:
[0175]
[0176] where α is the learning rate, is the gradient of the loss function.
[0177] Step 4: Copy the parameters of the evaluation network to the target network every N steps:
[0178] θ′← ξθ+(1 - ξ)θ′
[0179] where θ′ is the parameter of the target network, θ is the parameter of the evaluation network, and ξ is the soft update coefficient, usually taking a very small value;
[0180] Step 5: Repeat Steps 2 - 4 until the termination condition is met (reaching the maximum number of training steps or the Q value converges).
[0181] In summary, the present invention abstracts the DNN model structure into a directed acyclic graph (DAG), and generates a set of feasible segmentation strategies based on the network flow graph theory. By introducing the Edmonds-Karp algorithm to solve the minimum cut problem of multi-branch structures, the search for the optimal segmentation point with exponential complexity is transformed into the maximum flow calculation within polynomial time, significantly reducing the computational complexity. At the same time, by pre-screening the set of feasible segmentation strategies as the action space of the DQN, the problem of action space explosion in traditional reinforcement learning is effectively avoided. And in the process of Markov decision process (MDP) modeling of the model segmentation problem, a bandwidth-sensitive reward function is designed to achieve dynamic adjustment of the segmentation strategy. And through the method of model compression, the storage pressure of running the DNN model on the terminal device is alleviated.
[0182] In another aspect, the present invention also discloses a computer-readable storage medium storing a computer program, which when executed by a processor causes the processor to execute the steps of the above method.
[0183] In yet another aspect, the present invention also discloses a computer device including a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, it causes the processor to execute the steps of the above method.
[0184] In another embodiment provided by the present application, there is also provided a computer program product containing instructions, which when running on a computer causes the computer to execute any one of the edge computing collaborative inference methods based on adaptive model segmentation in the above embodiments.
[0185] It can be understood that the systems, devices, and storage media provided in the embodiments of the present invention correspond to the methods provided in the embodiments of the present invention. For the explanations, examples, and beneficial effects of related content, reference can be made to the corresponding parts in the above methods.
[0186] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0187] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0188] Each embodiment in this specification is described in a related manner. The same or similar parts among the embodiments can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
[0189] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements 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.
Claims
1. An edge computing collaborative inference method for adaptive model segmentation, characterized in that Including the following steps S1. Obtain the historical data collected by the terminal device and pre-train the deep neural network model DNN; S2. Quantize the parameters of the pre-trained DNN model using an asymmetric quantization method and adjust the model accuracy through real data; S3. Analyze the hierarchical characteristics of the quantized DNN model, calculate the computational delay and data output volume of each layer of the model, and construct a directed acyclic graph DAG of the quantized model based on the chain structure and multi-branch structure of the DNN model; S4. Based on the DAG and combined with the method of network flow graph in graph theory, obtain all the partition strategies in the quantized DNN model by using the iterative algorithm Ford-Fulkerson based on breadth-first search; S5. Partition the quantized DNN model and construct a Markov decision process MDP, and solve the optimal partition strategy by using the DQN method in deep reinforcement learning.
2. The edge computing collaborative inference method based on adaptive model segmentation according to claim 1, wherein The pre-training method of the deep neural network model DNN in step S1 includes: S110. Collect unlabeled raw data related to the target domain; Construct a large-scale heterogeneous data set through data cleaning, denoising and standardization processing, and the data scale meets: |D pretrain |≥N min Among them, D pretrain is the data scale of pre-training, N min is the threshold of the preset domain data volume; S120. Design a self-supervised proxy task for feature representation learning; Apply random augmentation operations to the input data X to generate positive sample pairs Maximize the mutual information of positive sample pairs through feature similarity. The loss function is as follows: Among them, is the contrastive loss; exp(·) is the exponential function, which is used to convert the similarity score into a positive number and amplify the similarity difference; s(·) is the similarity metric function, which is used to measure the similarity between two feature vectors; f θ is the feature encoder with parameter θ, and through f θ (·) converts the image input into a feature vector; τ is the temperature coefficient, which is used to adjust the distribution of the similarity score and control the degree of attention of the model to "hard samples"; S130. Update the model parameters θ using the stochastic gradient descent algorithm, and the optimization objective is: After training is completed, save the parameters of the model encoder part and generate a pre-trained model 3. The edge computing collaborative inference method based on adaptive model segmentation according to claim 1, characterized in that The model accuracy adjustment method in step S2 includes: S210: For the given original full-precision DNN model weight matrix: W ∈ R m×n , randomly select samples from the training set of the given N-layer DNN model as the calibration data set D calib to statistically analyze the weight distribution of all network layers i ∈ {1, 2,..., N}, and obtain the global extreme values of the weights of each layer: Among them, W i is the weight matrix of the i-th layer, and respectively represent the minimum and maximum values of the weights in the i-th layer; S220: Use the asymmetric quantization method to map floating-point values to the integer domain by dynamically adjusting the quantization range, and quantize the weights of each layer; The scaling factor S of the i-th layer i and the zero point Z i are as follows: The quantization formula is: Among them, b is the quantized bit width. The present invention selects 8-bit quantization. round(·) is a rounding function. is the quantized weight; S230: Adjust the quantized model by selecting a part of the real data D in the collected dataset to ensure the accuracy of DNN model inference; adj Weight quantization error of the i-th layer of the computational model Among them, W i (j, k) represents the element in the j-th row and k-th column of the original weight matrix, which is the corresponding value after quantization.
4. The edge computing collaborative inference method based on adaptive model segmentation according to claim 3, wherein The method for constructing the directed acyclic graph DAG in step S3 includes: S310: Perform further inference on the complete DNN model through real input samples, and record the execution timestamps and data output volumes of each layer in the continuous calculation state during the inference process, and aggregate the inference data of multiple rounds to obtain the average value of the hierarchical inference delay and data output volume; S320: Through the quantized DNN model, the process of constructing the DAG of the model is shown in Figure 3, and its structure is expressed as G=(V, E), where: V = {v0, v1, v2,..., v n} Let \(V\) denote the set of nodes in the DNN, \(v_0\) denote the input layer, and each node \(v\) i corresponds to a computing unit in the network; Let \(E\) be the set of directed edges. The edge \(e\) ij \(=(v\) i , \(v\) j ) indicates that data flows from \(v\) i to \(v\) j . The weight of the directed edge \(e\) ij represents the data output volume of \(v\) i , and there are no loops in the DAG.
5. The edge computing collaborative inference method based on adaptive model segmentation according to claim 1, wherein The method for obtaining all the partition strategies in the DNN model in step S4 includes: S410: Search for all the dividable edges in the DAG; In graph theory, the definition of a cut point is as follows: in a DAG, if the deletion of a certain node and all its associated edges destroys the connectivity of the original graph, then that node is called a cut point. From this, the definition of a cut edge can be extended: if the deletion of a certain directed edge in a DAG results in unreachable nodes or broken paths in the graph, then that edge is called a cut edge. All the dividable edges are represented as E div ; S420: Construct a network flow graph based on the dividable edges; For the multi-branch structure existing in the DNN model, this structure is called a multi-branch block, and a network flow graph is constructed; Each edge has a capacity cap(v i , v j ) and a flow f(v i , v j ), satisfying: f(v i , v j ) ≤ cap(v i , v j ); In the network flow graph, define the residual network G f = (V, E f ): E f = {(v i , v j ) | cap f (v i , v j ) = cap(v i , v j ) - f(v i , v j )} Among them, E f represents the set of edges of the residual network. If cap f (v i , v j ) = 0, then 6. The edge computing collaborative inference method based on adaptive model segmentation according to claim 5, characterized in that The method for solving the optimal partition strategy in step S5 includes: S510: Construct the model partitioning process as a Markov decision process; Suppose a DNN model consists of H layers, and the data output volume of the i-th layer is represented by d i The inference latency on the user-side terminal device is represented by The inference latency on the edge server is represented by where H ∈ Z + , 1 < i ≤ H; In the model splitting problem, the network bandwidth and computational load of the transmission link between the terminal device and the edge server are only determined by the current state and the splitting strategy; Therefore, the model splitting problem is modeled as a five-tuple Markov decision process: M=(S, A, P, R, γ) where γ represents the discount factor, which is used to measure the importance of future rewards, indicating that the farther rewards will be attenuated at a ratio of γ; S represents the state space, and the state at time t is represented as: Among them, b t represents the bandwidth in the environment where the current terminal device is located, and represent the computing power of the current terminal and the computing power of the edge server respectively; d t represents the data output volume at the current segmentation point; A represents the action space, which is the set of divisible policies C generated in step four, and the action a at time t t is expressed as: P represents the state transition probability; R represents the reward function, which is an optimization form of multiple objectives, mainly focusing on the computational delay and data transmission delay in the terminal device and the edge server, and the calculation formula is: where t local (k), t edge (k) and t trans (k) respectively represent the local computation latency of the model after the k-th layer segmentation, the computation latency at the edge, and the transmission latency of the data volume d k at the k-th layer; when the model is deployed, quantization is only deployed on the terminal device For the subsequent model, the quantization loss l q (k) at the terminal device is as follows: The reward function R is expressed as: R = -[(1 - ω(B))(t local (k) + t trans (k)) + ω(B)·l q (k) + t edge (k)] Among them, the bandwidth function ω(B) with the bandwidth B as the independent variable represents the adaptive weight to achieve dynamic optimization. When the bandwidth is small, the optimization will pay more attention to reducing the delay; when the bandwidth is large, the optimization will pay more attention to reducing the quantization loss to improve the precision of inference; ω(B) is expressed as: ω(B) = 1 - e -αB S520: The DQN algorithm is used to solve the Markov decision process (MDP) problem in the discrete action space, and the optimal segmentation strategy k at time t is obtained. * 。 7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the processor is caused to execute the method according to any one of claims 1 to 6.
8. A computer device, comprising a memory and a processor, characterized in that, The memory stores a computer program which, when executed by the processor, causes the processor to execute the method according to any one of claims 1 to 6.
Citation Information
Cited By
Model segmentation method and device, equipment, storage medium and product
CN121707001A