A hierarchical approach for building distributed quantum systems

In this paper, a multi-layer hierarchical architecture is proposed for distributing quantum computation. In a distributed quantum computing (DQC), different units or subsystems communicate by teleportation in order to transfer quantum information. Quantum teleportation requires classical and quantum resources and hence, it is essential to minimize the number of communications among these subsystems. To this end, a two-level hierarchical optimization method is proposed to distribute the qubits among different parts. In Level I, an integer linear programming model is presented to distribute a monolithic quantum system into K balanced partitions which results in the minimum number of non-local gates. When a qubit is teleported to a destination part, it can be used optimally by other gates without being teleported back to the destination part. In Level II, a data structure is proposed for quantum circuit and a recursive function is applied to minimize the number of teleportations. Experimental results show that the proposed approach outperforms the previous ones.

In this paper, a multi-layer hierarchical architecture is proposed for distributing quantum computation. In a distributed quantum computing (DQC), different units or subsystems communicate by teleportation in order to transfer quantum information. Quantum teleportation requires classical and quantum resources and hence, it is essential to minimize the number of communications among these subsystems. To this end, a two-level hierarchical optimization method is proposed to distribute the qubits among different parts. In Level I, an integer linear programming model is presented to distribute a monolithic quantum system into K balanced partitions which results in the minimum number of non-local gates. When a qubit is teleported to a destination part, it can be used optimally by other gates without being teleported back to the destination part. In Level II, a data structure is proposed for quantum circuit and a recursive function is applied to minimize the number of teleportations. Experimental results show that the proposed approach outperforms the previous ones.
In the recent decade, the rapid growth of science and the engineering of quantum devices have led to the advancement of quantum computation from single isolated quantum devices toward multi-qubit processors 1 . As such, quantum computation has witnessed rapid growth with high performance in many areas. The standard approach in quantum computing is to design them as monolithic circuits.
Nowadays, quantum computing has many advantages over classical ones. One of them is that quantum computers can exponentially act better than classical ones for many computational problems 2 . Yet, due to implementation complexity, there are many challenges to design a large-scale quantum computer. The computing power of a quantum system increases exponentially with the number of embedded qubits 3 . A problem with greater qubits is more challenging for a quantum computer to solve.
Though advantageous, quantum computers have many shortcomings. One of these shortcomings is that the information of qubits may encounter errors before applying fault-tolerant approaches. This is due to the qubits, interconnected by the outside world which may lead to decoherence 4,5 and when the number of qubits increases, the quantum information becomes more fragile and more susceptible to errors 6 . The error could also be due to the application of an operation on a quantum state 7 which can be solved by separating qubits from their surroundings. As qubits establish the communication and some reading or writing operation, this solution is not reasonable. There are many solutions for these challenges. Physical implementations such as systems of trapped atomic ions can be accurately controlled and manipulated. A large variety of interactions and measurements of relevant observables can be engineered with high precision 8,9 . Also, superconducting qubit modality has been used to demonstrate prototype algorithms in the noisy quantum channel to have non-error-corrected qubits in quantum algorithms. Currently, this is one of the approaches for implementing medium and large-scale quantum devices and quantum coherent interactions with low noise and high controllability 10,11 . Another technology used to design a large-scale quantum system is photonic quantum computing. Quantum entanglement, teleportation, and quantum key distribution are derived from this technology because photons present a quantum system with low noise and high performance 12 .
One way to resolve these challenges is to divide quantum systems into some limited-capacity quantum systems, with qubits distributed on them, which is referred to as a Distributed Quantum System 13-15 . Distributed quantum circuit. Distributed quantum system consists of several independent quantum units with limited-capacity that appear as a single quantum system to the users. The units might be different from each other, in terms of hardware and software. For hardware limitations of each quantum unit, there is a connected graph called coupling map in each unit. The purpose of these limitations is to preserve and control qubits from decoherence and noise 7 .
Minimizing communications among quantum units of a distributed quantum system is very essential in reducing the cost of the whole system. On the other hand distribution of qubits among different subsystems leads to some non-local gates and to execute these non-local gates, it is essential to bring all qubits into a single subsystem. According to the no-cloning theorem, independent copies of qubits is not allowed in a quantum system. To this end, we can use teleportation protocol in order to move qubits between subsystems 16 . This protocol requires an entangled pair of qubits between two nodes in order to teleport the state of a qubit from one node to the other. This operation is expensive, and can lead to substantial latency due to the stochastic nature of underlying processes [17][18][19] . Therefore, minimizing communications among quantum units of a distributed quantum system is very essential in reducing the cost of the whole system. A proper distribution algorithm could decrease the communications between quantum units dramatically. With this in mind, this paper proposes the optimized distribution of quantum systems.
An abstraction of Distributed Quantum Computing is shown in Fig. 1 which is described through a set of (logical) layers, with the higher depending on the functionalities provided by the lower ones 7 . Starting from the top, there is the quantum algorithm in the form of quantum circuit. This algorithm is completely independent and unaware of logical and physical hardware constraints. In the second layer, there is a distribution algorithm. This algorithm implements the circuit of the previous layer in a distributed way. This layer consists of two parts called load balancer and optimizer, as follows: • The qubits must be distributed well-balanced in some the limited-capacity quantum units. Therefore, a load balancing problem must be performed at this level. • Non-local operations require qubits to communicate with qubits on other units. Hence, a teleportation protocol is needed for units to communicate. Minimizing the number of teleportations among these units is required at this level.
At the next level, quantum units communicate with each other via classical and quantum channels remotely. Both local and non-local operations can be executed at this level. The local operations execute on the qubits stored within the same quantum units and non-local operations execute on the qubits stored on different quantum units. As mention above, a quantum teleportation protocol is necessary for communication units with each other. This protocol consists of some phases such as, e.g. EPR pair generation, local operations, measurement and classical communications 15 . Each teleportation comprises two qubits stored on different units. These two qubits that are entangled together are called an entanglement pair. Each qubit of entanglement pairs is used to communicate a single qubit to another quantum device. Therefore, at the very bottom level, a hardware for generating entanglement pairs is required to communicate units with each other 20 . Each quantum device may have its own hardware to create an entanglement pair, or a separate device may generate this pair centrally 20 .
In this work, a two-level hierarchical optimization model is proposed to design a large-scale distributed quantum circuit. Hence, a monolithic quantum circuit is distributed to K quantum units. As such, minimizing communication between the K partitions is the objective. In Level I, an integer linear programming approach is proposed to distribute the qubits to K parts in a well-balanced manner. This minimizes the number of communications among these units. In this level, each non-local gate requires two teleportations because after a qubit is teleported to the destination, it is teleported back to its source. However, by teleporting one qubit of a non-local gate from the source to the destination, it may be used optimally in the destination by other non-local gates before being teleported back to its source. After the optimal utilization of the teleported-qubit, it can be returned to its source. Applying this concept can improve and minimize the number of teleportations. To this end, a recursive approach is proposed to consider for that in Level II. Therefore, through this hierarchical model, the required number of teleportations becomes fewer than the number of non-local gates.
The reminder of this paper is organized, as follows. "Related work" presents an overview of prior work. "The proposed algorithm" provides the proposed method in detail. Finally, "Experimental results" presents and discusses the experimental results.

Related work
Distributed Quantum Computing (DQC) has been studied for many years. Scaling small-sized quantum systems to large-scale ones has been the main goal of these studies. The first study on DQC was reported in [21][22][23] . In that study, the author proposed the some quantum systems have physically located far from each other and sent the required information to a base station. He showed that the overall computation time is faster, in proportion to the number of such distributed quantum systems. Moreover, DQC has been used in many applications. In 24 , the authors considered two black boxes as two quantum devices and they were prevented from communicating with others and designed trusted quantum cryptography to share a random key with security, based on quantum physics. A practical application for quantum machine learning (QML) was presented in 25 . In this application, a distributed secure quantum machine learning was considered for the classical client to delegate a remote quantum machine learning to the quantum server with data privacy. In 13 , two main approaches, i.e. teledata and telegate were discussed. In the telegate approach, teleporting gates enables them to be executed remotely without requiring qubits to be nearby. In teledat, qubits transfer their states to other systems without moving them physically.
Squash 26 proposed a gate partition method by using METIS 27 as the partitioning tool. Moghadam et al. 28 used the min-cut approach presented in 29 to divide the graph of the quantum circuit into smaller units. In 30 , the authors used the modified version of the graph partitioning algorithm of 31 to minimize interaction between qubits. The authors of 32 presented an architecture for DQC. They partitioned the quantum circuit by the multilevel k-way hypergraph algorithm presented in 33 .
Most recently, one strategy to scale up the number of qubits has been the quantum internet [34][35][36] . Quantum internet is a network of quantum systems which are able to interconnect with each other remotely via quantum and classical links. Distributed quantum computing is used in this network. In fact, the quantum internet is considered as a virtual machine consisting of several qubits and is scaled with the number of quantum devices in the network. This concept may indicate the possibility of an exponential speed-up quantum computing power 3,35 . In 3 , authors considered the challenges and open problems of Quantum internet design. They highlighted the differences between quantum and classical networks and discussed the critical research and challenges in designing quantum communication networks.
At first Yimsiriwattana et.al., in 37 showed, for any contiguous non-local CNOT gates in which have common control qubit, the control line needs to be distributed only once, because it can be reused. This idea allows the number of communications reduce.
An automated method for distributing quantum circuits to K balanced partitions was investigated in 20 . They reduced the problem to hypergraph partitioning. Their algorithm consisted of two steps: pre and post processing for improving circuit distribution. It implements any number of contiguous non-local CNOT gates that execute on the same control qubit with target qubits in the same partition. They noted the consecutive non-local CNOT with the mentioned character can be executed with one teleportation.
Zomorodi et.al., presented several works [38][39][40][41][42][43][44][45] for optimizing and partitioning of quantum circuits. Davarzani et.al. 38 presented a dynamic programming approach to distribute a quantum circuit to K parts to minimize the number of communications. Their approach consisted of two steps. In the first step, the quantum circuit was converted into a bipartite graph. And in the next step, the bipartite graph was distributed to K parts by a dynamic programming approach. In that study, they tried to minimize the number of non-local CNOTs by converting the problem into minimum K-cut problems.
In another study 39 , an algorithm was proposed for DQC, consisting of two separated and long-distance quantum systems. They examined different configurations for the execution of non-local gates. Also, they ran their proposed algorithm for each configuration to reach the number of required teleleportations. The minimum number of communications was found among all the configurations. But, their proposed method had an exponential complexity.
An approach based on genetic algorithm has been used in 40 to distribute a quantum circuit into two partitions. The main purpose of the algorithm was to determine which qubit of a non-local gate should be teleported to the other system and when the teleported qubit should be returned back to its home partition. Also, in our another work 41 , we presented a two-phase algorithm based on NSGA-II to bi-partition the qubits in the first phase and suggested two heuristics to optimize the number of non-local gates in the second phase. The authors in 42,44 also discussed the issue of reducing communication cost in a distributed quantum circuit composing of up to three-qubit gates and presented a new heuristic method to solve it.
An automated Windows-Based method was proposed in 46 . In that study, the gate and qubit teleportation concept were combined with each other to minimize communication cost efficiently.

The proposed algorithm
In this paper, we consider the problem of optimally distributing a given quantum circuit for evaluation over a set of subsystems and propose a two-level optimizer to reach a large-scale monolithic quantum circuit with the minimum number of required communications. The proposed method consists of two levels: • Level I: In this step, the number of subsystems and the quantum circuit are given as inputs and the labelling P : {q i |i ∈ {1, ..., N q }} → {1, 2, ..., K} of qubits to subsystems as output. Here, we partition the given circuit across distributed quantum circuits to reach near-balanced partitions of qubits. For this reason, an integer linear programming model is proposed to partition the quantum circuit into K parts. After distribution of qubits, some gates be non-local and each non-local gate requires two teleportation to the forward and backward qubits from source to destination units. Therefore, the number of communications is double equal to the number of non-local two-qubit gates obtained by this partitioning model. www.nature.com/scientificreports/ • Level II: At this level, the obtained partitioning of Level I is considered as input and the minimum number of required teleportations is reached as output. As mentioned above, in the previous level, for each non-local gate, two teleportations are needed for forwarding and backwarding communications. When one of the qubits of non-local gates is teleported to the destination partition, more gates are executed by teleporting this qubit without the need of teleporting it back immediately. In this turn, the number of teleportations reduces. In this level, this idea is considered to optimize the number of teleportations. The details of these levels are as follows. Also, we use the notation of Table 1 in this paper.
Level I: the partitioning of quantum circuit. In this section, a K-way partitioning method is proposed to distribute a quantum circuit to K balanced partitions. This problem is a NP-hard problem and defined as follows: Definition 1 Consider the undirected and weighted Graph G = (V , E) , where V denotes the set of n vertices and E the set of edges. The balanced graph partitioning problem takes the Graph G(V, E), Parameter K as the number of partitions and Parameter ω known as the load balance tolerance as inputs. We wish to partition the graph into K balanced disjoint parts or sub-graphs Two criteria must be satisfied as follows: • Minimum number of cuts: the number of cuts among all the different sub-graphs is minimized as Eq. (1): where C(v 1 , v 2 ) is the weight of edge (v 1 , v 2 ). • Load-balance: for all k = 1, 2, ..., K : As a combinational problem, many heuristic approaches are mostly used to the graph partitioning to the need acceptable computation time. We reduced the problem of balanced distribution of quantum circuit to the problem of balanced graph partitioning so that qubits and gates are the nodes and edges in graph respectively. We proposed an integer linear programming model for K − way partitioning of quantum circuits. Let the quantum circuit consist of two sets, i.e. Q = {q i |i ∈ 1, ..., N q } and G = {g j |j ∈ 1, ..., N 2qubit } where set G is the set of twoqubit gates. Each g j operates on two Qubits q i 1 and q i 2 and has been shown as g j (q i 1 , q i 2 ) . The binary variables of the proposed mathematical model are as Eqs. (3) and (4): The binary variable f j is set to one when a two-qubit Gate g j (i 1 , i 2 ) is a non-local gate and Qubits i 1 and i 2 have been located on the different parts and zero otherwise (local gate). Also the binary Variable p i,k is determined whether q i be located to the Part k or not. The proposed model is given in Eqs. (5) to (9): 1 if q i has been located on Part k 0 otherwise  (5) determines the objective function. In this problem, the number of non-local gates is considered as the objective function. Load balancing criteria is considered in Eq. (6). Equation (7) ensures that a qubit is assigned to exactly one unit. Equations (8) and (9) guarantee that non-local gates are correctly accounted.
The proposed model distributes the quantum circuit into K balanced units. This distribution involves mapping the qubits of circuit into K subsystems. The output should be a labelling f : Q → {1, ..., K} of qubits to satisfying two criteria given in Eqs. (1) and (2). This function maps the qubits to a set of labels P = {p 1 , p 2 , ..., p K } . These labels are as input of Level II. Level II: the optimization level. After partitioning of Level I, qubits are distributed into K units according to the obtained labeling of the previous level. As stated earlier, each non-local gate needs two teleportations for executing. It is clear that in many cases, teleporting a qubit from its source partition to the destination partition, known as the migrated qubit, makes it optimally available to use by other gates without the need to teleport it back to its own partition. After that, the migrated qubit is teleported back to its home partition. At this level, we propose a recursive approach to implement this issue and minimize the total number of teleportations.
In this level, we present a data structure for representing quantum circuits. This structure is a two-dimensional matrix called C N q ×N g with N q rows and N g columns and defined as follows: • Qubits are located on the rows and numbered from one to N q , where the ith row indicates Qubit q i . • Gates are located on the columns and are numbered in the order of their executions in the quantum circuit.
Element C i,j (1 ≤ i ≤ N q , 1 ≤ j ≤ N g ) consists of two components: (index, label). index is the qubit that communicates with ith qubit in jth gate and label is the type of this qubit in which is 'control' or 'target' in two-qubit gates or 'non' in one-qubit gates. These elements are constructed as follows: • For each two-qubit gate g i (q t , q c ) , C t,i = (q c ,'c') and C c,i = (q t ,'t').
• For each one-qubit gate g i (q j ) , C j,i = (q j , non).
• Other elements are quantified by zero.
For example, we consider a quantum circuit with 4 qubits and 7 gates in Fig. 2a so that its corresponding matrix is given in Fig. 2b. www.nature.com/scientificreports/ Algorithm I presents the main algorithm. In this algorithm, we used an array called run with Size N g in which run [i] indicates the status of the ith gate in which it has/has not been executed. The algorithm starts from the first gate or column of C (Index s). It may indicate one of the following three conditions: • Column s indicates a local two-qubit gate.
• Column s is a one-qubit gate.
• Column s indicates a non-local gate.
In the first two cases, no teleportation is required and these gates are executed and run[s] is set to one (Lines 5-6 of the main algorithm). Otherwise, Gate g s is a non-local gate and a teleportation is required for the executing of g s . Then the teleportation cost is increased by two (Line 10) in which one additional teleportation must be accounted for transferring the qubit back to its source part. Then Function Find_qubits(g s ) finds two qubits of Gate g s called Qubits index 1,s and index 2,s . One of these qubits called q_teleport which led to the minimum number of teleportations, is selected (Line 12). This qubit is teleported from its own part to the destination to execute gate g s . The algorithm tracks the whole circuit to find the gate that can be executed without returning q_teleport to its source. This means the teleported qubit is optimally used by the other gates which require q_teleport and can be executed.
Let Gate g d in Column d be the first local two-qubit gate called g d (index 1,d , index 2,d ) in whis has common Qubit q_teleport with Gate g s . This gate must be considered whether it can be executed or not. Function Execute(g s , g d , q_teleport, run) is a recursive function and considers by teleporting q_teleport , Gate g d can be executed or not. This function is shown in Algorithm II. Three states may occur in this function as follows: • The function returns False when there is at least a non-executed and non-local gate between g s and g d which has not been executed before g d and the execution of g d depends on it. Let Column k(s < k < d) as g k (index 1,k , index 2,k ) be the first non-executed and non-local gate before Column d in which has a common qubit with Gate g d . This column has two non-zero rows index 1,d and index 2,d . This function returns False ( Line 11 of Algorithm II) and stops due to the following condition:  (10) indicates one of the qubits of g k is the same as the qubits of g d with a different label or the same Label 't' and another qubit of g k and g d has been located on the different partitions. In this case, another teleportation is required to execute g k and the function returns False, as a result. Figure 3a shows this concept. In this example, q 1 is teleported from P 1 to P 3 to execute g s . By this teleporting, executing of Gate g d should be considered by Function Execute. This function finds non-executed and non-local Gate g k before Gate g d in which have common qubit q 1 with a different label. Since execution of Gate g d depends on execution of Gate g k and Gate g k is a non-local gate, Then Gate g d cannot execute and Function Execute returns False.
Sometimes Gate g k may be a non-local gate in which has a common qubit with Gate g d with Label 'c' . In this case, the execution of Gate g d is independent the execution of Gate g k . This in turn, non-execution Gate g k prevented to execution of Gate g d and the execution of other previous gates of g d are considered (Lines 7-9) . Equation (11) indicates this state.
This state is shown in Fig. 3b.
• There are no gates between Gate g s and Gate g d to prevent the execution of Gate g d . In this case, this function returns True (Lines 13-14). • If Gate g k does not meet any of the conditions of Eqs. (10) and (11), Function Execute(g s , g k , q_teleport, run) is called recursively to consider if g k is executed or not (Line 19).
• Step 2: g 7 (q 1 , q 4 ) is a non-local gate and q 1 is teleported to P 1 . g 10 is the first gate which has common qubit q 1 with g 7 . Since g 10 is dependent to g 9 and run [9] = 0 , g 10 could not be executed. Therefor g 7 is only executed and run[7] = 1 . Then q 1 is teleported back to P 3 ; • Step 3: g 8 (q 3 , q 4 ) is a non-local gate and q 3 is teleported to P 1 . g 9 is the first gate which has common qubit q 3 with g 8 . Then run[i] = 1, i = {8, 9} . Other gates could not be executed and q 3 is teleported back to its source partition ( P 2 ). • Step 4: g 10 (q 1 , q 4 ) is a non-local gate and q 1 is teleported to P 1 . Any gate has common qubit with g 10 . Then run[10] = 1 and q 1 is teleported back to P 3 . • Step 5: g 11 (q 1 , q 3 ) is a non-local gate and q 1 is teleported to P 2 . Any gate has common qubit with g 11 . Then run[11] = 1 and q 1 is teleported back to P 3 . • Step 6: g 12 (q 3 , q 4 ) is a non-local gate and q 4 is teleported to P 2 . g 13 is the first gate which has common qubit q 4 with g 12 . Therefor g 13 is only executed and run[i] = 1, i = {12, 13} . Then q 4 is teleported back to P 1 . • Step 7: g 14 (q 2 , q 3 ) is a non-local gate and q 2 is teleported to P 2 . g 18 and g 17 have common qubit q 2 with g 14 . These gates are dependent to g 15  As shown above, each of Steps 1, 2, 3, 4, 5, 6 and 9 require to two teleportations. Then the total number of teleportations is 14 for this circuit.

Experimental results
We implemented our method in MATLAB on a Core i7 CPU operating at 1.8 GHz with 8 GB of memory. We used many circuits to compare the performance of the proposed method with previous approaches: that of 39 , the dynamic programming approach of 38 , the evolutionary algorithm of 40 , the automated approach of 20 and the windows-based method of 46 . The benchmark circuits are given from 48 (the circuits from 1 to10), Revlib 47 (the circuits from 11 to 15 and 26 to 31), some quantum error-correction encoding circuits 49 (the circuits from 16 to 25) and n-qubit Quantum Fourier Transform circuits (QFT) 50 where n ∈ {16, 32, 64, 128, 256} . The benchmark circuits include some of the gates of the gate library synthesized following the method in 51 . In this paper CNOT, CZ and one qubit gates are considered as the gate library.
To put the quality of results into perspective, the standard deviation criterion is employed as Eq. (12): Where T best is the best number of teleportations obtained among all of approaches and T ap is the obtained number of teleportations of approach that we compare ours to. First, Table 3 shows the number of teleportations in comparison with the windows-based approach of 46 . In this table, the number of qubits, gates and partitions are given in Columns 3, 4 and 5. Also Columns 6, 7, 8 and 9 report the number of teleportations and Dev of the proposed method and method 46 , respectively. As shown in this table, except Circuits 2-4dec, Cycle17_3, Ham15-D3, Ham7_106 and Parity247, Dev for our approach have zero value and demonstrate the proposed method outperformed that of 46 to reach minimum number of teleportations in these circuits.
First, it is important to demonstrate how applying Level II to the partitioning of Level I improves the number of communication. As mentioned before in that section, in Level I of the proposed algorithm, two teleportations are needed to execute each non-local gate because after a qubit is teleported to the destination home, it is teleported back to its source. Also, the proposed algorithm on level II allowed to teleported qubit to used optimally in the destination home. Therefore, it can save many number of quantum teleportations. Figure 5a shows the effectiveness of applying Level II to Level I to decrease the number of teleportations for Circuits 1 to 15. As can be seen, the bottom bar (the blue bar) indicates the required number of communications after applying Level II to these benchmarks and the top bar (the orange bar) indicates extra teleportations without applying Level II. As shown in this figure, in all of cases, over 70% of non-local gates could be implemented locally and the Level II reduces the number of teleportations to less than half in all of the samples.
In another test, we considered the impact of the number of subsystems on the number of teleportations. A near-balanced distribution of qubits over more quantum circuits requires more communications.    [16][17][18][19][20][21][22][23][24][25] and compared with method of 46 . These results are demonstrated in Table 4. The best obtained results are marked in bold. Except of three circuits, our approach has outperformed in comparison to 46 .
Third, we ran our method on QFT circuit in comparison with the method of 20 . We distributed the quantum circuit across {4,6,8,...16} quantum devices. Also, the N q and N g are 201 and 19900, respectively. Figure 6 shows the proportion of the number of teleportations over the total number of two-qubit gates for our approach and approach of 20 . As shown in this figure, this ratio grows by increasing the number of partitions. Also our approach has acted better than method 20 in all cases in terms of the ratio between the number of teleportations and the number of two qubit gates. Since, the proposed approach considers all of the configurations to execute more non-local gates, it found the minimum number of communications in comparison with the approach of 20 in which they implemented a group of non-local gates with a common control qubit only. As shown in this figure, when QFT is distributed in K = {4, 6, 8} , the number of teleportations obtained by the proposed approach have many differences from the approach of 20 , but two methods acted almost identically for K = {10, 12, 14, 16}.
In another test, we demonstrate the effectiveness of load-balance tolerance ( ω ) on the number of non-local gates in Level I. Figure 7 shows the number of non-local gates for various ω = {0.1, ..., 0.9} on one sample circuit. As shown in this figure, N non is reduced by increasing the load-balance tolerance. According to Eq. (6), when Factor ω increases, the qubits that have many communications with each other, are located in the same partition. Therefore, the number of non-local gates is reduced.

Conclusion
In this paper, a two-level hierarchical architecture of distributed quantum computing was proposed to build large quantum systems in which the number of communications among quantum subsystems is minimized. In the first level, an integer linear programming model was proposed to distribute the qubits to K balanced subsystems.
In the second level, we presented a new data structure for representing quantum circuits. Also, according to the partitioning of the first level, when one of the qubits of a non-local gate is teleported from its source subsystem to the destination, it is used optimally by other gates in the destination subsystem before being teleported back to its own subsystem. Moreover, we proposed a recursive method to optimize the number of teleportations. Finally, we ran the proposed method on the different benchmarks and showed that it produces better results in comparison with the previous ones.