## 4 Joint Workload Partition Module
### Problem Formulation  
Under the paradigm of SEC, we assume that the distributed environment consists of \(M\) workers, which can be represented as \(\mathbb{W}=\{w_{1},w_{2},\ldots,w_{M}\}\). We use \(\mathbb{P}=\{p_{1},p_{2},\ldots,p_{M}\}\) to record the computing power of all workers, where the computing power of worker \(w_{i}\) is numerically represented as \(p_{i},i\in[1,M]\). The out-bandwidth of workers is represented by a set \(\mathbb{B}=\{b_{1},b_{2},\ldots,b_{M}\}\), where \(b_{i}\) represents the out-bandwidth of worker \(w_{i}\), \(i\in[1,M]\).  
We focus on a single sub-model that consists of \(N\) partial dependency layers, such as convolution layers and pooling layers. The network layers in the sub-model can be represented as \(\mathbb{L}=\{l_{1},l_{2},\ldots,l_{N}\}\). The set \(\mathbb{WL}=\{w_{1},w_{2},\ldots,w_{N}\}\) contains the computing workload of all the network layers, where \(w_{l}\) represents the computing workload of the layer \(l_{n}\). We obtain the \(\mathbb{WL}\) using the ptflops tool. As stipulated in Section 3.2, we use \(H\) to represent the original input feature height of each network layer, and \([trans_{s},trans_{e}]\) can describe the data transmission situation from \(w_{j}\) to \(w_{i}\).  
We use a data partition to split the output data of this sub-model. The data partitioning is represented by \(X=\{x_{1},x_{2},\ldots,x_{M}\}\); \(x_{m}\) is the proportion of the output data of worker \(w_{m}\) to the original output data of the sub-model. To ensure that \(X\) is an effective data partition, \(X\) must comply with the following constraints, Formulas (9) and (10), ensuring that the sub-model output can be concatenated into the original output by all workers.  
\[0\leq x_{i}\leq 1,\quad i=1,2,\ldots,M \tag{9}\]  
\[\sum_{i=1}^{M}x_{i}=1,\quad i=1,2,\ldots,M \tag{10}\]  
Figure 6: Data transmission situations. The sub-figures correspond to six relationships between the \(w_{j}\) output range and \(w_{i}\) input range. In sub-figures (**a**–**d**), \(w_{j}\) needs to transmit the output data between two dashed lines to \(w_{j}\); in sub-figures (**e**,**f**), \(w_{j}\) need not to transmit output data to \(w_{i}\).  
We note that the inference completion time for this sub-model on the worker \(w_{i}\) is \(T_{i}\), and \(T_{i}\) can be calculated using the following Equation (11).  
\[T_{i}=T_{trans(j,i)}+T_{comp}^{i}, \tag{11}\]  
where \(T_{trans(j,i)}\) represents the transmission time of input data from the requester \(w_{j}\) to worker \(w_{i}\), and \(T_{comp}^{i}\) represents the execution time at worker \(w_{i}\). The inference completion time of the sub-model on the worker is equal to the time it takes for the worker to obtain the required input data plus the worker's execution time.  
The transmission time from device \(j\) to device \(i\) can be computed as (12), where \(D_{j,i}\) is the volume of data transmitted from \(w_{j}\) to \(w_{i}\). In a 64-bit system, a float32 number occupies 4 Bytes. Assuming the input feature's width and number of channels are \(\alpha\) and \(\mu\), respectively, the calculation of \(D_{j,i}\) is shown in Equation (13).  
\[t_{trans(j,i)}=\frac{D_{j,i}}{\mathbb{B}_{j,i}}, \tag{12}\]  
\[D_{j,i}=(trans_{e}-trans_{s})*\alpha*\mu*4, \tag{13}\]  
The computation time of worker \(w_{i}\) for the sub-model is denoted by \(t_{comp}^{i}\); we obtain it using (14).  
\[t_{comp}^{i}=\frac{x_{i}\times\sum_{j=1}^{N}w_{j}}{p_{i}} \tag{14}\]  
Our goal is to minimize the sub-model's inference latency, which is equal to the latest time for all workers to complete the sub-model. Therefore, we build an optimization objective as (15).  
\[\begin{split}\min_{x}&\lambda\\ s.t.& T_{i}\leq\lambda,i=1,2,\ldots,M;\\ &\text{Constraints}\quad\eqref{eq:constraint}\quad\text{and}\quad \eqref{eq:constraint}.\end{split} \tag{15}\]  
The optimization problem (15) is a Linear Programming (LP) problem, and it is an NP-complete problem [49]. In this article, we use the Mosek tool to solve the linear programming problem in the Python environment.