## 3 Performance Evaluation Model  
In this section, we will define the cost model and build the complete performance evaluation model (denoted as the MDPE model) \(R\) based on three key factors that affect the efficiency of the parallel execution of the model: computation cost, communication cost, and memory cost (see Definitions 3-5).  
**Definition 3** (Compute Cost): _Define the runtime required for the submodel tensors to complete the computation on device \(d_{i}\) as \(E_{i}\):_  
\[E_{i}=\sum_{k=1}^{K}\frac{\mathbb{C}(\mathcal{L}_{k})}{c_{i}}=\sum_{n=1}^{N} \frac{\mathbb{C}(\mathbf{T}_{n,1},\mathbf{T}_{n,2},\ldots,\mathbf{T}_{n,k})}{ c_{i}}. \tag{5}\]  
where \(K\) represents the number of submodels computed at device \(d_{i}\). \(N\) is the total number of tensors involved in the calculation. \(\mathbf{T}_{n,1},\mathbf{T}_{n,2},\ldots,\mathbf{T}_{n,k}\) represent the k-dimensional size of the current tensor. \(\mathbb{C}\) is the floating-point operands. \(c_{i}\) is the computing density of device \(d_{i}\).  
**Definition 4** (Communication Cost): _Define the communication and synchronization time for intermediate results of the submodel as \(\mathbb{C}_{i,j}\):_\[C_{i,j}=\sum_{k=1}^{K}\frac{\text{Out}_{k}+Err_{k}}{b_{i,j}}=\sum_{n=1}^{N}\frac{ \mathbb{A}(\mathbf{T}_{n})}{b_{i,j}}\quad s.t.C_{i,j}\leq\hat{C}_{i,j}. \tag{6}\]  
where \(N\) represents the total number of tensors participating in the communication. \(\mathbf{T}_{n}\) represents the tensors transmitted between devices \(d_{i}\) and \(d_{j}\). \(\mathbb{A}\) is the function of the calculating the size of the tensor. \(b_{i,j}\) represents the communication bandwidth between devices \(d_{i}\) and \(d_{j}\). \(\hat{C}_{i,j}\) is the upper limit of communication that the user can tolerate.  
**Definition 5** (Memory Cost): _Define the memory cost of the device after the loading of the submodel as \(M_{i}\):_  
\[M_{i}=\sum_{k=1}^{K}Mem_{k}^{0}=\sum_{n=1}^{N}\mathbb{A}(\mathbf{T}_{n})\quad s.t.M_{i}\leq\hat{M}_{i,j}. \tag{7}\]  
where \(N\) represents the total number of tensors stored on the current device \(d_{i}\), \(\mathbf{T}_{i}\) represents the current tensor, and \(\mathbb{A}\) is the calculation tensor size scale function. \(\hat{M}_{i}\) is the upper limit of memory that the user can tolerate.  
The above three definitions characterize the parallel performance in terms of three dimensions. We then linearly superimpose the three dimensions to obtain a multidimensional performance evaluation model to obtain an MDPE model that guides the iterative optimization of reinforcement learning. In particular, we adaptively find the optimal model parallel strategy by maximizing \(R(\pi_{g},\pi_{s})\):  
\[R\big{(}\pi_{g},\pi_{s}\big{)}=-\log\big{[}\alpha f\big{(}E_{i},C_{i,j},d_{i} \big{)}+\beta q\big{(}C_{i,j},M_{i},d_{i}\big{)}\big{]}\quad s.t.\;d_{i},d_{j} \in\mathcal{D}. \tag{8}\]  
Here, \(\alpha\) and \(\beta\) denote the weight hyperparameters. \(f(\cdot)\) represents the linear fitting function for predicting the runtime. It was calculated according to the execution simulator. \(q(\cdot)\) represents the communication and memory penalty functions, which implements penalties for the strategy that exceed the upper limit of communication and memory overhead to ensure that the communication and memory costs meet user constraints.  
Thus far, we established the MDPE model including the runtime, communication costs, and memory usage based on theoretical analysis. In the next section, we will introduce the overall architecture of Trinity and use the MDPE model to guide reinforcement learning optimization.