1 Introduction
Quantum information provides many of the most cutting-edge researches nowadays, including quantum simulations [
1–
3], quantum computing [
4–
8], quantum cryptology and quantum communication [
9–
18]. In the field of quantum information, information is encoded into quantum states. Many times we wish to obtain the full information of the states, in situations such as quantum device analysis [
19], which promotes the emergence of technologies like quantum state tomography (QST). Although we can determine the classical expression of unknown quantum states through QST, how to reproduce the states and how to design the corresponding quantum circuit are still problems that need further discussion. Therefore, it is valuable to find a quantum circuit that can directly reconstruct the unknown quantum states since finding the unitary operations to prepare states can help us get rid of the disadvantages that quantum states have a limited lifetime and are difficult to store, allowing us to manipulate them anytime and anywhere.
In 2018, an autonomous protocol based on quantum reinforcement learning (QRL) was put forward [
20], which assumes enough copies of the input state, and requires no structural information of the inputs beforehand. The protocol introduces a quantum register to interact with the environment — the unknown state ensemble, and takes measurement on it, the result of which is used to adjust the “agent” state. Once the algorithm converges, the “agent” will have fidelities around 90% with respect to the input unknown qubit state. On the other hand, parameterized quantum circuits (PQCs) with certain objective functions are believed to be good solutions to many quantum problems, from solving quantum algebraic systems [
21–
24] and finding the ground state energy of a chemical system [
25–
31] to performing image classification [
32,
33] and fitting unknown functions [
34] in the noisy intermediate-scale quantum (NISQ) era [
35]. In the field of quantum machine learning, PQCs are known as a type of quantum neural networks [
36–
39].
In this paper, we present a framework that can reconstruct unknown quantum states in an adaptive way. Different from the QRL method that keeps gate parameters adopted in previous iterations unchanged, we make the circuit parameterized, introduce classical gradient optimizers into our protocol to boost the final fidelities, and tune all parameters iteratively. We introduce the variational layerwise learning (LL) technique [
33] as a strategy to dynamically adjust the PQC structure, yielding a circuit of suitable depth automatically and avoiding the requirement of experienced pre-designs of parameterized circuits in other ordinary non-adaptive algorithms, which is especially significant when the system scale gets large. This not-over-large depth of the obtained circuit can also serve as an exact upper bound for the minimal depth of the circuit that can reconstruct the input state at the required fidelity with the same layered structure. We test the performance of the framework for random states containing up to six qubits numerically, which shows that our framework can achieve the goal of quantum states reconstruction with more than 96% fidelities. We perform hardware experiments on IBM Quantum processor to demonstrate the practicality of our framework. Moreover, comparisons with the QRL-based method and non-layerwise-learning strategy are made.
2 Method
We assume that we have enough copies of the unknown state as in [
20]. The schematic of the optimization process of this algorithm is shown in Fig. 1. For an unknown state |
ψunkn⟩ that contains
nq qubits, another
nq work qubits are required for state reconstructing, which will be manipulated by the PQC
U (
θ). The PQC is composed of several “blocks”, the
i-th block of which takes the form of
as shown in Fig. 2. Here Rj (·, ·, ·) is the general single-qubit rotation on the j-th qubit (X, Y, Z are the Pauli operators):
while W is the connection operator between qubits. In the diagram of Fig. 2, W is a series of two-qubit interactions having all-to-all connectivity, and it can be customized for different quantum systems.
Similar to classical machine learning algorithms, a hybrid classical-quantum algorithm requires a proper loss function to train parameters. Here we take the overlap (i.e., fidelity) between work state and unknown state as the loss function:
In order to evaluate its value from experimental results, we employ SWAP-Test to obtain the overlaps. Details of SWAP-Test are provided in Appendix A, and from Eq. (A8) we can derive that
Therefore, by introducing an auxiliary qubit and measuring its expectation value of Pauli Z operator, we can acquire the loss value experimentally. It is worth noticing that, ⟨Z⟩ must be non-negative analytically, but if we perform our algorithm on a real-world quantum machine, a classical sampling simulator where we can only have frequencies of samples rather than exact probabilities, or a classical numerical simulator with limited precision, the approximated value of ⟨Z⟩ may be negative when the exact value of ⟨Z⟩ is near-zero. Therefore, enough number of repetitions of sampling must be taken, and those negative ⟨Z⟩ values close to zero should be clipped to zeros.
In the framework of Fig. 1, we choose layerwise learning strategy to adjust our PQC. In classical machine learning, layerwise learning strategy is proven to have comparable performance as complete depth learning (CDL) that trains all parameters in the whole network simultaneously. Skolik et al. introduced layerwise learning method into PQC-based quantum machine learning tasks [
33]. They showed that when noiseless and analytic simulation is considered, LL and CDL display similar performance. But LL strategy works better on average when it comes to a real-world quantum device where noise is not negligible and measurements must be taken in order to evaluate the loss function and the gradients.
Another essential reason to use LL strategy is that it can gradually lengthen our PQC util convergence, which is adaptive as we wish. Compared with CDL strategy that requires us to determine the complete structure of PQC before running algorithms, LL strategy starts from a shallow PQC and can dynamically extend it on-demand, balancing the fidelity of our algorithm and quantum resources consumed by our PQC.
In general, our method adjusts not only the parameter values but also the structure of PQC by progressively increasing the number of blocks of the PQC and dividing all parameters into several groups which are trained iteratively. Before running our algorithm, several hyperparameters must be designated, whose meanings are listed in Table 1. As LL strategy in [
33], our algorithm consists of two phases, which are detailed in Algorithm 1. For the clarity of presentation, we call lines 5 ∼ 10 and line 18 a
training step in phase Ⅰ and phase Ⅱ respectively.
In classical QST,
elements of the state density matrix need to be stored so that the state can be completely represented. Meanwhile, since these elements must be obtained via measurements individually, the execution time of classical QST also scales exponentially with the system size. In contrast, the qubit resources required by Algorithm 1 is 2
nq =
O(
nq), and the state of the work qubits is directly the reconstructed state, without the need to convert classical density matrix data into quantum states. We use the number of queries to quantum gates through the entire process to estimate the upper bound of time complexity of Algorithm 1. If the final number of blocks in the PQC is
L and there are
O(
nq) gates in each connection operator
W, the gate complexity of the final PQC will be
LO(
nq) and the total query complexity will be
, where
g1,
g2 are the query complexities of gradient evaluation in each training step of phase Ⅰ and phase Ⅱ respectively. For example, if parameter-shift rule [
34,
40,
41] is employed in both phases, then
g1 =
O(
nq),
g2 =
O(
rnp) =
O(
Lrnq), and the total query complexity will be
, which also presents exponential improvement compared with classical QST. We owe this reduction of consumed resources to the hybrid quantum-classical framework, which combines the advantage of the intrinsic quantum representability of NISQ devices and well-developed optimization algorithms of classical computing.
3 Results
3.1 Numerical simulation
In order to run benchmarks on this quantum state reconstructing framework, we create random circuits and take them as unknown input states. The procedure is detailed in Appendix B.
We carry out 1000 numerical simulations for each nq in {1, 2, ···, 6}, and the configurations of our experiments are detailed in Appendix C. We record the losses at the end of each epoch and the evolution averaged over 1000 random input states during the complete training process is shown in Fig. 3(a). At the beginning of each training step, the loss value may have a sudden rise, which is the result of non-zero parameters in the newly appended block WU(i). Nevertheless, the overall performance can finally be improved by tuning these parameters and the model circuit will be brought away from local optima (and also barren plateaus) in the final parameter space. As a result, the entire curve exhibits a declining shape with fluctuations. For cases where nq = 1, the loss values decrease so fast that they have been less than the threshold in the first several epochs before any early-stopping checks are performed, while for other cases the early-stopping mechanism stops circuit training when the loss values gradually reach the threshold. This is the reason why the final value of the case nq = 1 is around 1/10 of those cases where nq > 1 in Fig. 3(a).
According to Eq. (4), we can evaluate the overlaps from loss values by . With this relationship, we calculate and plot the fidelities per 20 epochs in Fig. 3(b). For systems containing different number of qubits, the average final losses and final fidelities varies, as revealed in Fig. 4. Figures 3(a), (b) and Fig. 4 show that for systems with less than 5 qubits, the final losses are smaller than 10−4, meaning that our PQC can learn unknown states with fidelities higher than 99% theoretically for systems with dimensions up to 24 = 16. For larger systems like quantum states of 5 or 6 qubits, the fidelity of output state of our PQC is expected to be higher than 96%. Analyses on the convergence rate and training time are attached in Appendix D.
In order to study the effect of each circuit block on the reconstructed state, we conduct our algorithm to reconstruct the partially entangled state . We start from a 0-block PQC |ψ0⟩ = (H |0⟩)⊗6 according to the procedure of Algorithm 1. The evolution of von Neumann entropy of the 6 subsystems
is monitored during the training process, where ρi is the partially traced density matrix of the i-th qubit. It is direct to derive that the analytical values of |ϕ0⟩ are
which match the simulation results in Fig. 5(a). As the algorithm proceeds, the parameterized circuit will lengthen gradually. Once converged, the algorithm gives out a circuit containing 5 blocks. We simulate this final circuit and evaluate the values of fidelity and entropy after the state passes each block, as in Fig. 5(b). After the first block, von Neumann entropy of entangled qubits (0, 1, 2) is mostly recovered, while the entanglement-free qubits (3, 4, 5) obtain extra entropy inappropriately. Therefore, a new block is added, with its parameters well-trained so that it can de-entangle (3, 4, 5) qubits, raising the entropy of (0, 1, 2) qubits at the same time. The last 3 blocks fine tune the state, making the degree of entanglement of each qubit more accurate. As the circuit deepens, the fidelity of state is gradually increased. Hence, different blocks in the PQC of our framework can adjust global or local properties of the work state according to the difference between input state and work state.
3.2 Experimental results
We deploy our framework on the 5-qubit IBM Quantum processor
ibmq_belem [
42] to reconstruct unknown single qubit states
U(
α, β, γ)|0⟩ =
Rz(
α)
Ry(
β)
Rz(
γ)|0⟩, where
α, β, γ are randomized. The configurations are detailed in Appendix E. Due to hardware noise, the loss values evaluated from real measurement results will eventually be around 0.015 and not less than 0.010. As a result, the final fidelity is expected to be ∼ 83.5% according to Fig. 6(a), where the values represented by solid dots are averaged over 100 random cases.
Nevertheless, once the algorithm converges, the trained PQC can serve as a high precision noiseless approximation to
U (
α, β, γ) when acted on |0⟩, since the fidelity can reach ∼ 99.1% if we simulate the trained PQC analytically, as shown in Fig. 6(b). We owe this to the robustness of the parameter-shift rule adopted in gradient evaluation, since the gradient yielded still provides effective guidance to the optimization process even though the hardware is noisy [
43].
3.3 Comparisons with other methods
We implement the QRL algorithm in [
20], and do simulations on random input states generated with the same routine in Section 3.1 for systems containing 1 and 2 qubits. The QRL algorithm hyperparameter
ϵ ranges from 0.1 to 0.9, and we repeat the experiment 1000 times for each configuration. We compare the average final fidelities achieved by our method in Section 3.1 with the results of the QRL method in table 2, where the convergence rate stands for the proportion of converged cases in all 1000 experiments and the criterion for convergence differs in our algorithm and in the QRL algorithm, which is detailed in the first table annotation. For the simplest case — 1-qubit systems, the maximal value of average fidelity that can be achieved by our method is raised to be higher than 99%. All 1000 simulations converged, and the learning process can be accomplished in 3 epochs on average. For larger systems, our advantage in fidelity is more obvious: the average final fidelity can be raised from around 90% (QRL) to 99% for 2-qubit systems, and is expected to reach 98.7% for 5-qubit systems if our PQCs converge.
We can also apply our PQC onto the input unknown state directly as proposed in [
44], without need for SWAP-Test, the auxiliary qubit and the work qubits. In this construction, we need to optimize the PQC so that it can reset the state into |
0⟩ (all-zero state). To achieve this goal we should measure all qubits of the state and take the loss function to be
Once the loss function is reduced to near zero, we can invert the PQC and get
. Applying this inverted series to |
0⟩ will yield a state that is supposed to have high overlap with the input unknown state. This variant only consumes half of the quantum qubits of our framework, and avoids noisy executions of quantum circuits resulted from possibly erroneous controlled-SWAP gates, which involve interactions through the entire quantum system. However,
O(
nq) times more measurements are required in order to estimate the fidelities with the same order of precision. Furthermore, on NISQ devices with noteworthy shot noise, if the probability of performing an erroneous measurement on a qubit is
pe and we need to evaluate the fidelity based on
M circuit execution results, then
peM results are expected to be correctly sampled from the probability distribution of the quantum state in our algorithm, while the value is
for the cSWAP-free method since its fidelity relies on the measurement results of all qubits. As a consequence, the more qubits are to be measured, the less precise results we will obtain. Therefore, when we are working on a quantum device with significant multi-qubit interaction error, the cSWAP-free method in [
44] exhibits higher applicability, while our method is more robust and more suitable if the measurement noise is not negligible.
We conduct numerical experiments to compare the performances of our algorithm using layerwise learning strategy and non-layerwise learning strategy, i.e., complete depth learning. Figure 7(a) illustrates how the fidelities are raised in a specific example using LL-strategy, where readout noise with bit-flip probability being 20% is assumed. We run CDL to reconstruct the same state, with the circuit structure same as the final PQC of LL, and initial values of all parameters identical to those of LL. Optimization of CDL converges in only 10 epochs and early-stops, with the final fidelity being 86.36%, while LL gives out a fidelity up to 99.32%, from which we can see that our framework can avoid converging too early and being stranded in barren plateaus. According to [
33], LL-strategy takes more epochs than CDL-strategy, but less measurements are to be taken in each epoch due to fewer parameters to be updated, which leads to the same amount of calls to quantum devices.
However, LL may not surpass CDL regarding to the final fidelity under all circumstances, suggested by another example shown in Fig. 7(b). In this case LL method converges at fidelity 95.84%, while CDL method reaches 96.05%. We opine that given the block structure of the multi-layer (i.e., block) PQC, the significance of layerwise learning strategy is to help our algorithm find a relatively short circuit that can reconstruct the unknown state at high fidelity in an automatic and heuristic manner, avoiding fixing the structure of the complete PQC beforehand like in CDL, which may overuse quantum resources if the PQC contains too many blocks, especially when there is significant circuit noise, or may not able to achieve the fidelity goal if the PQC is too short. Our algorithm starts training with a low-depth circuit. If the PQC is too shallow to converge to the input state, which means the algorithm sticks in the barren plateau far away from the input state, LL-strategy will dynamically extend the circuit by appending a new block, trying to enlarge the reachable region in the state space of our PQC to cover the unknown state. Once phase Ⅰ accomplished, LL-strategy will stop extending and bring our PQC into phase Ⅱ, fine-tuning each parameter group. To sum up, LL can find the suitable circuit which is neither too short nor over-expressive, saving quantum computing resources with the final fidelities guaranteed.
Suppose that there exists a minimal circuit that can achieve the target fidelity threshold with the same layered structure, whose depth is denoted as Lmin. The depth of the trained circuit from layerwise learning can naturally be regarded as a limited upper bound of Lmin, which is found adaptively, even though we lack preliminary knowledge of the input state. Therefore, the parameterized circuit of LL provides a valuable reference if we wish to further find the exact value of Lmin.
Similar to the classical analogue, neural network algorithms, the performance of hybrid quantum-classical algorithms is greatly dependent on the form of ansatz, the optimization algorithm, and even the initialization method of trainable parameters. Hence we can improve CDL by handpicking more adequate instances of these training facilities, in which case they can also be applied to the training process of LL. For example, the structure of each block in a multi-layer CDL parameterized circuit and the corresponding classical optimizer can be adopted into LL training as well. The benefits of these facilities are also effective against the LL-strategy since each LL training step can be regarded as a CDL-training of the sub-PQC. Consequently, the adoption of better training techniques in CDL is expected to bring an equal boost to LL.
4 Discussion
As illustrated above, the algorithm of this paper can find a suitable PQC to reconstruct an unknown state with high fidelity in an adaptive way. We design the framework based on parameterized quantum circuits, and introduce classical gradient optimizers into the quantum machine learning protocol to raise the final fidelities. The adopted layerwise learning strategy lengthens PQCs and optimizes newly added parameters gradually, avoiding barren plateaus of short-depth PQCs while keeping the entire structure minimal and optimal. As a result, our method provides high practicality for state reconstructing in the NISQ-era, reducing the consumed computational resources and time complexity compared with classical state tomography, and can reach efficiently high fidelities for systems of different scales. The output state of PQC can have more than 96% fidelities for 1–6-qubit systems in theory. Real device experiments indicate the practicality of our framework, and comparisons with other methods reveal its advantage. Our method is helpful for gaining enough information about the structures of complex non-analytic quantum systems, or mitigating and eliminating noises on real quantum devices such as superconducting systems and ion-trap systems. Furthermore, it can serve as a general framework for hybrid variational quantum-classical algorithms that are based on fidelities and provide a boost for them.
It is worth noticing that given an ansatz of PQC in our quantum state reconstructing framework, its representation ability is fixed. The block structure employed in our experiment, as shown in Fig. 2, determines that our ansatz is sufficient for us to learn and reproduce quantum states of 1–4 qubits, while for larger systems the loss values may not be optimized to be less than the convergence threshold. There are many ways to increase the fidelity and the probability of convergence, one of which is adopting ansatz more suitable to the system to be considered, or heuristic ansatz like [
29]. Another important idea is to apply better initialization strategies and optimization algorithms. We will conduct further studies in our future works.