## 4 Quantum Exchange Lock Parallel Scheduler
### Quantum Circuit Hierarchical Strategy Based on Qelps
Output:

_Min_swap_ : The minimum total number of SWAP gates after optimization

1:Begin:

2: \(Min\_swap\leftarrow\infty\)

3: Initialize layers list \(L\leftarrow[]\)

4: For \(i=0\) to number of \(layers-1\)do

5: \(L[i]\leftarrow\) Analyze SWAP gate insertions to form layer \(i\)

6: End for

7: \(Min\_swap\ =\) Find Optimal SWAP Combination\((L[0])\)

8: For \(i=1\) to number of \(layers-2\)do

9: For each candidate scheme \(l\in L[i]\)do

10: Compute : \(\Delta S(i,l,e)=s(i,l,e)-S(i,l,e)\)

11: Compute : \(Cost(i,l,e)=\lambda\Delta S(i,l,e)/\Delta S_{max}+(1-\lambda)Q(i)^{l}/Q(i)_{max}\)

12: If \(Cost(i,l,e)<Min\_swap\)

13: Then \(Min\_swap\gets Cost(i,l,e)\)

14: End if

15: End for

16: End for

17: For \(j=1\) to number of \(layers-2\)do

18: If \(Cost(i,j+1,e)>0\)then

19: Perform Joint Optimization\((L[0],L[j])\)

20: \(Min\_swap\leftarrow\) Find Optimal SWAP Combination\((L[0])\)

21: End if

22: End For

23: Return \(min\_swap\)

24:End

**Algorithm 2** Full-level Joint Optimization SWAP Algorithm

### Example Analysis

As shown in Figure 4a, the original hardware architecture diagram illustrates the correlation between each quantum bit. Figure 4b presents the original logic circuit diagram, which must satisfy the quantum bit correlation shown in Figure 4a. The quantum gates enclosed by red dotted lines do not meet the physical constraints. The input circuits of the quantum circuit include \(\text{CNOT}q_{4},q_{5}\), \(\text{CNOT}q_{0},q_{1}\), \(\text{CNOT}q_{1},q_{4}\), \(\text{CNOT}q_{2},q_{3}\), \(\text{CNOT}q_{6},q_{7}\), \(\text{CNOT}q_{7},q_{8}\), and \(\text{H}q_{4}\), which are divided into four layers. In the FJOSA algorithm, the value of \(Cost(i,l,e)\) is calculated during the \(i^{th}\) optimization, and its positive or negative value determines whether to continue the optimization until the final layer is processed. The goal is to obtain the solution with the least number of inserted SWAP gates. When the number of optimizations is \(i=1\), the algorithm begins optimization from the initial layer (\(e=0\)), with the minimum number of optimized layers set to \(L=2\). For each layer \(l_{e}\) in the quantum circuit, \(n_{e}\) represents the number of SWAPgates required. All possible SWAP insertion solutions are evaluated, revealing two feasible solutions that satisfy the constraints of the \(l_{0}\) layer with a minimum of \(n_{0}=2\) SWAP gates. The first solution consists of SWAP \(q_{2},q_{4}\) and SWAP \(q_{3},q_{5}\), while the second includes SWAP \(q_{2},q_{4}\) and SWAP \(q_{3},q_{4}\). For each quantum mapping, the solution with the least number of SWAP gates in the \(l_{1}\) layer is determined. In the first solution, as shown in Figure 5, \(n_{1}=2\), meaning two additional SWAP gates must be inserted. In contrast, in the second solution, as illustrated in Figure 6, \(n_{1}=0\) means no SWAP gates are needed. This finding highlights that carefully selecting the SWAP insertion scheme can significantly reduce the total number of SWAP gates. Consequently, the FJOSA algorithm selects the second solution (\(S(i,l,e)=2\)), whereas the QELPS algorithm, which does not account for the impact of each solution on subsequent layer mappings, chooses the first solution (\(S(1,2,0)=4\)). Figure 4: Initial mapping quantum circuit diagram: (a) Original hardware architecture; (b) Original logic circuit diagram. Figure 5: Quantum circuit after optimization with \(n_{1}=2\): (a) Original hardware architecture with \(n_{1}=2\); (b) Original logic circuit diagram with \(n_{1}=2\). Formula (4) shows that \(\Delta S(1,2,0)=-2\), where Smax represents the number of SWAP gates along the longest path. The CNOT operations CNOT \(q_{4},q_{5}\), CNOT \(q_{1},q_{4}\), and CNOT \(q_{2},q_{3}\) correspond to paths \(q_{4}\to q_{2}\to q_{0}\to q_{1}\to q_{3}\to q_{5}\), \(q_{1}\to q_{3}\to q_{4}\), and \(q_{2}\to q_{0}\to q_{3}\), respectively. After computing \(\Delta S_{max}=6\), Formula (5) yields \(S_{norm}=-0.33\).