{'fraction_non_alphanumeric': 0.04889750918742344, 'fraction_numerical': 0.012198856676194365, 'mean_word_length': 4.389958734525447, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Universal compilation for quantum state preparation and tomography

Universal compilation is a training process that compiles a trainable unitary into a target unitary and it serves vast potential applications from quantum dynamic simulations to optimal circuits with deep-compressing, device benchmarking, quantum error mitigation, and so on. Here, we propose a universal compilation-based variational algorithm for the preparation and tomography of quantum states in low-depth quantum circuits. We apply the Fubini-Study distance to be a trainable cost function under various gradient-based optimizers, including the quantum natural gradient approach. We evaluate the performance of various unitary topologies and the trainability of different optimizers for getting high efficiency. In practice, we address different circuit ansatzes in quantum state preparation, including the linear and graph-based ansatzes for preparing different entanglement target states such as representative GHZ and W states. We also discuss the effect of the circuit depth, barren plateau, readout noise in the model, and the error mitigation solution. We next evaluate the reconstructing efficiency in quantum state tomography via various popular circuit ansatzes and reveal the crucial role of the circuit depth in the robust fidelity. The results are comparable with the shadow tomography method, a similar fashion in the field. Our work expresses the adequate capacity of the universal compilation-based variational algorithm to maximize the efficiency in the quantum state preparation and tomography. Further, it promises applications in quantum metrology and sensing and is applicable in the near-term quantum computers for verification of the circuits fidelity and various quantum computing tasks.


I. INTRODUCTION
Quantum computers promise an excellent computational capacity that is intractable for classical computers to solve challenging problems, including materials science [1][2][3], information science [4,5], computer science [6,7], mathematical science [8][9][10], and others. However, there are two major challenges to bringing quantum computers to materialize [2]: (i) it is difficult to access full information from entangled systems because of the state collapse upon measurements, and (ii) it is difficult to build, control, and measure quantum states with arbitrarily high accuracy. In this regard, even though the current state-of-the-art quantum computers rely on the noisy intermediate-scale (NISQ devices), which usually prevents high efficiency [11], various hybrid quantum-classical algorithms have been proposed and actively studied recently [12], and that could be promising for quantum speedup in the regime of NISQ devices. Massive applications include variational quantum eigensolvers [13][14][15][16][17], quantum approximate optimization algorithms [18], new frontiers in quantum foundations [19][20][21][22], and others, have been reported.
Beyond the actively studied VQAs, the universal compilation has drawn tremendous interest recently. Its core idea relies on a training process to transform a * Electronic address: binho@riec.tohoku.ac.jp trainable unitary into a target unitary [23,24]. It has demonstrated different applications in gate optimization [23], quantum-assisted itself compiling process [24], continuous-variable quantum learning [25], and robust quantum compilation [26]. (We highlight attention that does not be mistaken for the term "quantum compilation" which is used for compiling a high-level quantum language into a hardware description language [27].) The future of universal quantum compiling could be circuits depth-compression, black-box compiling, error mitigation, gate-fidelity benchmarking, and efficient gate synthesis.
In another aspect, recently, the preparation and tomography of quantum states in quantum circuits have attracted significant attention owing to the incredible advantages of the quantum device [28][29][30][31][32][33]. Quantum computers allow to efficiently prepare quantum states with high confidence, fully control the Hamiltonian for the state evolution, and directly access the measurement results. Early works on the quantum state preparation direction can be grouped into "with" and "without" ancillary qubits. Without ancillary qubits, however, a major obstacle is the invertible exponential growth of the circuits depth, ie., O[2 N ] [34][35][36][37], and O[2 N /N ] [38]. With ancillary qubits, the circuit depth significantly reduces to sub-exponential scaling [38][39][40][41], e.g. O[2 N/2 ], but those still require an exponential number of ancillary qubits in the worse cases.
Despite recent achievements on quantum state preparation and quantum state tomography, it is still challenging to implement them in the NISQ devices. In this work, we introduce a promising application of the universal compilation on quantum state preparation and quantum state tomography. Our main idea is to use a trainable unitary that acts upon a known fiducial state to prepare a target state or reconstruct an unknown state. The target state and unknown state are created using a suitable target unitary that acts upon the fiducial state. Then, the solution returns to the compilation from the trainable unitary to the target unitary. The advantage of this method is that it requires low-depth trainable unitaries and few measurements to realize the target unitaries that significantly reduce the complexity. Furthermore, the flexibility of the trainable unitaries is more elevated than that of the target unitaries, resulting in a better fault-tolerant capacity and thus allowing high efficiency for the trainable quantum circuits.
Concretely, we first introduce the general framework of the universal compilation-based quantum variational algorithm (UC-VQA) and then apply it to particular quantum state preparation (QSP) and quantum state tomography (QST). We also introduce several gradientbased optimizers, including the standard gradient descent (SGD), the Adam, and the quantum natural gradient descent (QNG).
We discuss the numerical experiment results for these two processes. For the QSP, we propose several structures for the trainable unitary such as linear, graph-based polygon, and graph-based star ansatzes for preparing different entanglement target states such as representative GHZ and W states. Here, we reduce the circuit depth from exponential to polynomial, i.e., O(N ), N the qubit numbers. We also discuss the accuracy under the effect of the circuit depth, barren plateau, readout noise, and the error mitigation solution. The result is applicable to any arbitrary target state. For the QST, we first examine the simple case of single-qubit tomography, and then evaluate the reconstructing efficiency of unknown Haar random states via various popular circuit ansatzes. We find that the circuit depth plays a crucial role in the robust fidelity, i.e., by choosing a proper circuit depth via the number of layers in the quantum circuit, we get high fidelity at any qubit numbers. We finally compare the results with the shadow tomography method [59,60], a similar fashion in the field.
The study reveals that the accuracy mainly relies on (i) the ansatz topologies with the optimal circuit depth and (ii) the significant impact of different optimizers such as the standard gradient descent, the Adam, and the quan-tum natural gradient descent. Our study can further promise applications in quantum metrology and sensing and is applicable in the near-term quantum computers for verification of the circuits fidelity and various quantum computing tasks.

II. FRAMEWORK
We introduce a variational quantum algorithm that bases on universal compilation [23][24][25][26] to translate a given state into another one, and apply it to quantum state preparation and quantum state tomography.

A. Universal compilation-based variational quantum algorithm
A universal compilation-based variational quantum algorithm (UC-VQA) consists of a quantum and a classical part, as shown in Fig. 1 (a). The quantum part is a circuit with parameterizable ansatzes. Let U (θ) and V † (θ ) are two unitary ansatzes (sets of quantum gates with some parameters θ, θ ) that act onto the circuit and transform an initial state |ψ 0 into a final state |ψ f as The transition probability yields Our task is to maximize the transition probability p max (ψ 0 → ψ f ), such that a state |ψ(θ) ≡ U (θ)|ψ 0 is compiled to |φ(θ ) ≡ V (θ )|ψ 0 . We thus name this method is "universal compilation-based variational quantum algorithm." Alternatively, we introduce a "quantum kernel" for the transition probability as such that The maximization of the transition probability, i.e., p(ψ 0 → ψ f ) = 1, implies |ψ(θ) = |φ(θ ) in the quantum kernel, which can be applied to the quantum state preparation and quantum state tomography as we will describe below.
In the classical part, we define a cost function that relates to the kernel K(θ, θ ) and use it to compute new parameters θ, θ via an appropriate optimizer (see Sec. II D). These new parameters are iteratively fed back to the quantum circuit until the convergence criteria are satisfied. . It consists of a quantum part and a classical part. In the quantum part, the final state |ψ f is created by applying a set of quantum gates U followed by V † onto the initial circuit and then be measured. In the classical part, we compute the appropriate cost function, use an optimizer to compute new parameters, and update the scheme until it converges. (b) Quantum state preparation. The unitary U is parameterized into U (θ) with several ansatzes, including the linear, graph-polygon, and graph-star ansatzes. The unitary V is fixed for generating entangled GHZ and W classes. (c) Quantum state tomography. The unitary U is a Haar random generator while V † is parameterized into V † (θ) and broken out into entangled gates W and local rotation gates V with several structures as shown in the figure. (d) A sketch of some quantum gates used in (b) and (c). Other notations: N the number of qubits, L the number of layers, Rj, j = {x, y, z} the rotation gate around the j-axis, CZ controlled-rotation-Z gate, H Hadamard gate, CF controlled-F gate [61].

B. Quantum state preparation
Quantum states preparation (QSP) performs a set of controllable evolutions on a quantum system to transform its initial state into a target state. This is an essential step in quantum computation and quantum information processing. Here, we present a UC-VQA scheme that transforms an initial quantum register into an arbitrary target state with high accuracy and well against the noise under mitigation aid.
Starting from an initial register |0 ≡ |0 ⊗N in the quantum circuit as shown in Fig. 1 (a), where N is the number of qubits, the task is to transform this state into a target quantum state, i.e., |τ . First, we transform the initial register into a variational state under a trainable unitary U (θ), where θ = {θ 1 , θ 2 , · · · , θ M } can be adaptively updated during a training process, M is the number of trainable parameters. The target state can be expressed in terms of a quantum circuit as with a target (known) unitary V . To qualify how closed the two states are, we consider the Fubini-Study distance as [62] d(υ(θ), τ ) = 1 − τ |υ(θ) where p 0 (θ) = | τ |υ(θ) | 2 = | 0|V † U (θ)|0 | 2 is the probability for getting the outcome |0 . In the quantum circuit, we apply a sequence of U (θ) followed by V † onto the initial state |0 to get the final state V † U (θ)|0 and then measure a projective operator P 0 = |0 0|, which yields the probability p 0 (θ). The variational state becomes the target state if their distance reaches zero. In the variational circuit, we thus use the Fubini-Study distance as a cost function that needs to minimize, i.e., C(θ) = d(υ(θ), τ ), such that By training the variational circuit until it converges, we obtain θ * , and the variational state |υ(θ * ) reaches the target state |τ . In Sec. III A, we show the results for preparing some representative target states, such as entangled GHZ and W classes. We use several ansatzes U (θ), including the linear ansatz, the graph-polygon ansatz, and the graphstar ansatz, while the structure of V is fixed so that it can generate the desired target states. The corresponding U (θ) and V structures are shown in Fig. 1 (b). As mentioned beforehand in general, it requires a circuit depth at exponential or sub-exponential to prepare an arbitrary quantum state. However, using those proposed ansatzes, we efficiently reduce the cir- for the linear, graph-polygon, and graph-star ansatzes, respectively, with N is the number of quits and L is the number of layers.

C. Quantum state tomography
Quantum state tomography (QST) is a measurement process performed on many identical copies of a system to extract its state's information [63]. In general, for a given unknown quantum state |µ in a complex Hilbert space of d-dimension, it requires a set of 2 d − 1 measurements on different bases to reproduce the state completely. Here, we introduce an alternative QST framework based on the UC-VQA, that would show high accuracy and comparable with the shadow tomography, a similar fashion for QST using few-measurement quantum circuits.
Starting from a random (unknown) quantum state where a Haar random unitary U [64] acting on the initial state |0 . To reconstruct this state, we apply a trainable unitary evolution V † (θ) that can learn the role of U , such that a reconstructed state resembles to the unknown state |µ . The efficiency of the tomography process is given by the Fubini-Study distance as Similar to the above, we also use the Fubini-Study distance as the cost function and train the model to get the reconstructed state |γ(θ * ) = V (θ * )|0 with an optimal θ * . For the training process, we generate the unknown state following the Haar random, while the ansatz V † (θ) is broken out into (12) and W l includes the chain, alternating, and all-to-all structures [65] as shown in Fig. 1(c). The training results are shown in Sec. III B.
We emphasize that both U (θ) in the QSP and the entangled gates W here consist of two-qubit controlled y-rotation gates, which differs from previous works [65]. We refer to these gates as "parameter-dependent entanglement gate." They are useful for preparing variational states metrology [21] and rapid entangled circuits [66], for testing of the expressibility and entangling capability [67], and so on.

D. Training
The training process is a hybrid protocol as illustrated in figure 1 (a): a set of unitary gates U followed by V † apply onto the circuit and measure the final state. The results are sent to the classical counterpart to compute the corresponding cost function and then update new parameters θ using a suitable optimizer protocol until it reaches convergence.
We use gradient-based optimizations to iteratively update the parameters θ and minimize the cost function. To do that, we need to calculate the derivative ∂C(θ)/∂θ j w.r.t θ j in the j th gate for every θ j ∈ θ. We compute two cases as follows. First, if the j th gate is a single-qubit rotation gate, i.e., exp(−iθ j σ k /2), k ∈ {x, y, z}, then using the standard (two-term) parameter-shift rule [68,69], we have where s denotes an arbitrary shift, and e j is the j th unit vector, or in other words, we only add s to θ j . Second, if the j th gate is a controlled rotation gate, i.e., CR y (θ j ), then using the four-term parameter-shift rule [70], we partially compute where d ± = ( ∂θj . To compute new parameters, we use several optimizers in all experiments: Standard gradient descent (SGD), Adam gradient descent [71], and Quantum natural gradient (QNG) [72]. The formula for SGD reads where M training parameters, and α is the learning rate that we fix at 0.2. In comparison, Adam is a non-local averaging optimizer that allows adapting the learning rate but requires more steps than the SGD , with the hyper-parameters are chosen as α = 0.2, β 1 = 0.8, β 2 = 0.999 and = 10 −8 . Finally, the QNG is defined by where g + is the pseudo-inverse of a Fubini-Study metric tensor g [73]. Assume that we can group θ into L layers, i.e., θ = θ (1) ⊕ θ (2) ⊕ · · · ⊕ θ (L) , so that in each layer Then, the metric tensor g gives [74] 0 g (2) . . .
where an element g where |ψ is the quantum state at the th layer. For unitary G See a detailed example of computing a tensor metric g in Appendix A. Each optimizer has its own pros and cons: (i) the SQD is simple but low coverage, one must choose a proper learning rate to achieve the best result, (ii) the Adam allows to automatically adapt the learning rate and fast coverage but it is noisy near the optimal point, and (iii) the QNG is better than other optimizers but also requires more computational cost regards to quantum circuits.
In terms of complexity, to execute the parameter-shift rule in Eq. (13), the quantum circuit executes 2M + 1 times, one M times to compute p 0 (θ + se i ), one M times to compute p 0 (θ − se i ), and one time to compute p 0 (θ). Furthermore, a single evaluation requires executing the circuit for a constant number of shots to reach a certain precision, and each execution involves around G gate operations. So, the complexity of each iteration is O[(2M + 1)G]. Similarly, the complexity for an iteration with four-term parameter-shift rule is O[(4M +1)G]. Ideally, after each step, the cost function will decrease with a linear or logarithmic speed regarding the number of iterations. However, the variational circuit always offers a lower bound of the loss value during the training process. In particular, this bound increases by the number of qubits N , which means the problem will be harder according to the size of the system This work implements the numerical experiments using various configurations described above to train the variational models and compare them together. The numerical results are executed by Qiskit open-source package, version 0.24.0, which is available to run on all platforms. For each experiment, to get the probability p 0 we execute 10 4 shots using the qasm simulator backend. The number of iterations for every training process is fixed at 400, except for others shown in the text. The experiments are then scaled up to 10 qubits for quantum state preparation and 6 qubits for quantum state tomography to demonstrate the scalability. The results are shown in Sec. III for both quantum state preparation and quantum state tomography.

A. Quantum state preparation
We apply the UC-VQA approach to prepare various quantum states. As mentioned aforehand, we aim to prepare a family of entangled GHZ and W states [75] using several variational anstazs as shown in Fig. 1 (b): the linear ansatz and graph-based ansatzes with polygon and star structures.
The linear ansatz contains a linear number of parameters w.r.t. the number of qubits that is sufficient for entanglement state preparation. A similar structure has been proposed for the variational state metrology [21]. Each layer contains a set of single-qubit rotation gates R x applied on each qubit, followed by an entangled gate CRY, a set of R z gates, an entangled gate CRY, and finally end up by a set of R z gates. The single-qubit rotation is R j ), j ∈ {x, y, z}, and σ (n) j is a Pauli matrix applied on the n th qubit. The structures of CRY and CRY are detailed in Fig. 1 (d). They are entanglement gates that consist of a set of controlled yrotation gates, which are parameter-dependent. In total, the number of parameters is M = 5N L.
Besides, we also propose a graph-based ansatz, wherein we parameterize a graph state using single-qubit rotation gates. A graph state is a multi-qubit state that consists of vertexes and edges that connect in a graph structure. Each vertex represents a qubit, and an edge links an interacting pair of qubits using a CZ gate. See Fig. 1 (d) for examples of graph states. To prepare a graph-based ansatz, we apply R y gates following the rule: each CZ gate is always surrounded by four R y gates. See Fig. 1  (b) for details. This structure is similar to the one in Ref. [76]. Here, we focus on two specific structures of the graph-based ansatz: polygon and star ansatzes, where In Fig. 2, we examine the cost function versus the number of iterations for different optimizers. It can be seen that for most of the ansatzes exhibited here (except the linear ansatz for the W state,) the QNG optimizer (green line) requires the smallest number of iterations among the three optimizers (SGD, Adam, QNG) to achieve the convergence. This is the natural feature of the QNG optimizer because its gradient points toward to the optimal direction [74,77]. Nevertheless, we emphasize that the Adam is not stable at the optimal point (as mentioned in the pros and cons section,) while the QNG is more stable. Both the Adam and QNG can achieve the minimum at a certain number of iterations; however, the SGD (blue line) is hard to get the optimal point in some cases (see    Figure 3 displays the results for the Funibi-Study distance between the target state (GHZ and W) and the variational prepared state. We discuss the accuracy and the stability of different ansatzes under various optimizers. In general, the Funibi-Study distance increases as the number of qubits increases, which reveals that the accuracy is low for larger system preparation.
Particularly, we first observe a strong dependence of the resulting linear ansatz (Fig. 3, •) on different optimizers for both GHZ and W classes. For the SGD and QNG optimizers, the Funibi-Study distance increases as N increases, while for the Adam optimizer, the distance remains small and stable up to N = 6 (for both GHZ and W.) This observation exhibits the instability of the linear ansatz under different optimizers, and its best optimizer is Adam (in agreement with the previous results in Fig. 2

.)
For the graph-star ansatz, the Funibi-Study distance remains small up to N = 6 at all optimizers for the target is the GHZ state ( Fig. 3 (a,b,c), ), which implies a high accuracy and well stability. Moreover, the resulting graph-polygon ansatz also achieves high accuracy under the Adam and QNG optimizers up to N = 6 and 5, respectively ( Fig. 3 (b,c), ), while its accuracy gradually decreases (larger distance) when increasing N under the SGD optimizer ( Fig. 3 (a), ).
So far, for the target state is the W state [ Fig. 3 (d,e,f)], all the ansatzes strongly depend on the optimizers as we can see the Fubini-Study distance gradually increases when increasing N . This observation can be explained when noting that W states belong to the multipartite entanglement class [78], and thus it is more challenging to prepare the W states in comparison to the GHZ states of entanglement.
It is reported that the number of layers L can significantly affect the accuracy [79][80][81]. In Fig. 4, we show the dependence of the Fubini-Study distance on the number of layers. Here, we fix N = 7 and apply the QNG optimizer. For the GHZ class target, the Fubini-Study distance reaches the minimum at L = 3 and then gradually increases when L > 3. Among the three ansatzes, the linear one (•) increases fastest while the graph-star ( ) slowly increases, and the graph-polygon ( ) nearly saturates (slightly increases). This observation is a hind for the barren plateaus, i.e., the accuracy of the training process reduces when increasing the parameters space, and it agrees with the barren plateaus analyses in Fig. 5 below. Furthermore, in the W class, the distance for the linear ansatz (•) reaches the minimum at L = 4, while the distances for graph-star ( ) and graph-polygon ( ) ansatzes continue to reduce up to L = 5. This result agrees with the previous observation about the entangled features of the GHZ and W classes, as the W class requires more computational cost to achieve the same accuracy as the GHZ class.
Those results in Figs. (3, 4) suggest a sign of the existence of the barren plateau effect (BP) in the training landscapes [82], which frequently appears in the Variational Quantum Algorithms and Quantum Neural Networks. When the BP appears, the cost function C(θ) derivative exponentially vanishes with the circuit size [82]. Primary sources for the BP effect include the random parameter initialization [82], shallow depth with global cost functions [76], highly expressive ansatzes [83], the entanglement-induced [84], and the noise-induced [85], among others. So far, it has been reported several promising strategies for avoiding the BP using local cost functions [76,86], correlated parameters [87], pretraining by the classical neural network [88], and layerby-layer training [89].
To examine the vanish of the derivative cost function C(θ), i.e., the existence of the BP, we derive the variance where we have shorthanded C(θ) to C, ∂ k C := ∂C/∂θ k , and the expectation value takes over the final state. Numerical results Var[∂ θ1 C] for a representative first parameter θ 1 are given in Fig. 5, where we observe exponential decays as functions of the number of qubits N with slopes of -1.52, -1.23, and -1.18, for the linear ansatz (•), graphstar ansatz (•), and graph-polygon ansatz (•) , respectively. Those are the evidence for the existence of the BP in the parameters spaces in our model and agrees with our prediction in Figs. (3, 4). The results are shown for the GHZ class and L = 2. Finally, we account for the effect of noise. In real hardware that belongs to the current era of noisy intermediate-scale quantum computers (NISQ), noisy qubits bias the results and thus limit the applications [90]. One of the important classes of the noisy qubits is the readout error, which typically arises from (i) the qubits decoherence, i.e., qubits decay, phase change,..., during the measurement time, and (ii) the incomplete of the measuring devices, i.e., overlap between the measured bases. Here, we model the noise channel by the readout error probability for each qubit in the circuit as where p 0 , p 1 are the true probabilities when measuring the bases |0 and |1 of the qubit, p ( ) 0 , p ( ) 1 are the readout error probabilities, respectively, is the error rate.
As shown in Fig. 6 (open circle, •), the Fubini-Study distance rapidly increases when gradually raising the error rate. In the inset Fig. 6, the dotted lines are the cost functions regarding different (the colors match To suppress the noise, we apply the measurement error mitigation [91][92][93][94]. The basic technique for the measurement-mitigation is using a (2 N × 2 N ) calibration matrix M, such that where p = (p 0 , p 1 , · · · , p 2 N −1 ) T a vector represents the true probabilities, and similar for p ( ) a vector represents the readout probabilities. The calibration matrix contains all the probabilities transitions M ij = Prob(p ( ) i → p j ). One direct approach for obtaining the mitigated probabilities is to invert the calibration matrix and get p mitigated = M −1 p ( ) . Other developed methods, such as the least square [95], truncated Neumann series [96], and unfolding methods, have been demonstrated [90]. Finally, we construct M by running 2 N circuits corresponding to 2 N elements in the computation basis {|00 · · · 0 , |00 · · · 1 , · · · , |11 · · · 1 }.
The mitigation results are shown in Fig. 6 (filled circle,  •). In this example, we can totally eliminate the effect of noise after the mitigation and thus the accuracy reaches the original value (without noise). Here, is the optimal number of layers for the SGD, † is the optimal number of layers for the Adam, and ‡ is the optimal number of layers for the QNG. We choose the appropriate ( , †, ‡) for each N and each W structure so that the fidelity gets its (possible) highest accuracy.

B. Quantum state tomography
This section applies the UC-VQA framework to quantum state tomography. We first consider reconstructing an abstract 1-qubit state encodes in a quantum circuit as shown in the inset Fig. 7. We randomly generate an unknown quantum state |µ = U 3 |0 , where where we have set random with Haar measure sin(θ)/2, φ, and λ. To reconstruct |µ , we set the unitary V † (θ) = R z (θ 3 )R x (θ 2 )R z (θ 1 ). We train the scheme with 100 iterations using various optimizers and show the cost function versus iteration in the main Fig. 7. Here, the QNG optimizer gives the best optimization. In the inset figure, we also show the trajectory in the Bloch sphere of the reconstructed state |γ(θ) under the update of θ for two cases of SGD and QNG optimizers. For the former one, it needs around 60 iterations for the reconstructed state to reach the true state, while it only requires around 6 iterations for the latter. Now, we focus on a general random Haar state, i.e., |µ = U Haar |0 , as shown in Fig. 1 (c). To reconstruct the state, we use several ansatzes for the entangled gate W in V † (θ), including the W chain , W alternating , and W all−to−all structures. Refer Fig. 1 (c) for details of these structures, where we have used the parameter-dependent controlled y-rotation gates to construct them. The trainable param-eters for these ansatzes are M = 4N L, N L/2 + 3N L, and N (N + 5)L/2, respectively.
The results are shown in Fig. 8. Let us consider the fidelity between the true Haar state and the reconstructed state as which is the overlap between these two states. In Fig. 8  (a,b,c), we show the fidelities for different structures of W. For each case, we fix L = 2 and examine the three optimizers SGD (•), Adam ( ), and QNG ( ). We first observe that the SGD optimizer is not good for all W structures and needs to choose an appropriate learning rate. The fidelities reduce with the increasing N and nearly vanish at N = 6. In contrast, the Adam optimizer exhibit high fidelities up to N = 4 for W chain (a), N = 5 for W all−to−all (c), and gradually reduces from N = 2 for W alternating (b). Even though it is not stable near the optimal point, the Adam is remarkable for achieving high accuracy in the QST. Furthermore, the QNG optimizer also allows for getting such high accuracy up to N = 4 for W chain (a) and even better than the Adam for W alternating (b), while it gradually reduces for W all−to−all (c). This observation can be explained by these own structures: the W all−to−all contains the most number of parameters via the controlled y-rotation gates compared to the others, which results in the low accuracy. It is apparent that the QNG optimizer is sensitive to the controlled y-rotation gates.
Next, to achieve high accuracy for any qubit number N , we increase the number of layers L while paying attention to the barren plateau. This is the pros and also the cons of the UC-VQA method. Figure 8 (d,e,f) plot the fidelities versus N , where for each N , the corresponding L is shown in the colored parenthesis ( , †, ‡), for the SGD, Adam, and QNG, respectively. The number of layers shown in the parenthesis is the smallest (optimal) L required for achieving such high accuracy before it goes down due to the barren plateau. As can be seen from the figure, the Adam method allows for reaching the maximum fidelity (results are shown up to N = 5 for all W structures) with a suitable L as shown in the middle position of the parenthesis. Similarly, we can reach high accuracy with the QNG optimizer up to N = 4 when choosing an appropriate L as shown in the last position of the parenthesis. For the SGD, it is intractable for achieving high accuracy. Even though the relation between N and the required L is not clear, interestingly, we can see from the results up to N = 5, the required L is also around 5 (more L is redundancy or may reduce the accuracy due to the barren plateau, see detailed in Appendix B.) Finally, we address the merit of our UC-VQA approach and the shadow tomography protocal [59,60], a recent promising method in this regime. A shadow tomography protocol is given as follows [60]: (i) initially prepare a random unknown quantum state ρ, and the task ahead is to predict a target function underlying the state from its shadow, (ii) randomly pick up a unitary U k in a T -tuple U, i.e., U = {U 1 , U 2 , · · · , U T } then apply it to the initial state to tranform ρ → U ρU † , (iii) measure the evolved state in the computational basis |b = {|0 , |1 } N . The procedure is repeated for a certain number of measurements. For each measurement, we get a random classical snapshot We then define an invertible channel matrix where E k is the average over U k , with a corresponding pick-up probability. Let M −1 exists, and let p k is the probability of picking up a unitary U k , then we can reconstruct a (non-normalized) state aš which is the classical shadow of the original unknown state ρ. For the transformation U belongs to a family of the global Clifford gates, i.e., U ∈ U C = {CNOT, Hadamard, S gate, T gate}, refer to Random Clifford measurements, the reconstructed state explicitly yields [60]ρ = (2 N + 1)U † |b b|U − I. For the transformation U belongs to the random Pauli gates, such as U ∈ U P = {X, Y , Z, · · · }, refer to Random Pauli measurements, it straightforwardly yields [60] For comparing the shadow tomography with the UC-VQA scheme, we consider the prediction of a linear function as a figure of merit for the accuracy. We apply the Random Pauli measurement. As a concrete representative, we measure a global observable, i.e., Z ≡ Z ⊗N , Z is a Pauli matrix, which gives the predicted (linear) expectation valuě z = Tr(Zρ), that obeys E[ž] = Tr(Zρ).
The fluctuation (distribution around the true expectation value) of the predicted expectation value is given by the variance Var[ž] as In Fig. 9 (a), we show the variance Var[ž] as a function of the number of measurements for the shadow tomography. The variance slightly decreases when increasing the number of measurements from 10 2 to 10 5 . See the inset figure for detailed zoom-in. The result is compared with the standard quantum limit (SQL), i.e., SQL = 1/ Number of measurements, and the Heisenberg limit (HL), i.e., HL = 1/ (Number of measurements) 2 . Here, the variance does not beat the SQL nor HL.
In Fig. 9 (b), we compare the variances obtained from the shadow tomography and the UC-VQA for the different number of qubits N . For the shadow tomography, we fix the number of measurements at 10 5 . For the UC-VQA, we consider the W chain structure with the Adam optimizer as an example. The number of shots (measurements) is fixed at 10 4 . It can be seen that the UC-VQA offers a better result over 100 times than the resulting shadow tomography.
We further discuss some features of these two approaches. The shadow tomography only allows for predicting target functions, such as expectation values, entanglement entropies, correlation functions, and so on [60], whereas the UC-VQA allows for reconstructing the entire quantum state up to a phase shift. Both schemes allow for predicting properties of quantum states or quantum states with fewer measurements compared to standard quantum tomography. Another remarkable feature is that the efficiency of the shadow tomography protocol depends on the random choice of the unitaries in an ensemble U, while the efficiency of the UC-VQA scheme relies on the choice of different ansatzes and optimizes. Finally, we emphasize that the comparison in this section only provides a very first glance about the two approaches. We need to further characterize these features in future works for more concrete evaluation.

IV. CONCLUSION
We have proposed a universal compilation-based variational quantum algorithm (UC-VQA) for compiling a given quantum state to another one and its applications to quantum state preparation (QSP) and quantum state tomography (QST). We have considered the compiling probability as a quantum kernel that needs to maximize, and thus, it serves as a cost function. We have conducted various numerical experiments using different ansatz structures and optimizers to analyze the algorithm's performance for the aforementioned subjects.
The key feature of the UC-VQA is that it provides lowdepth circuits and only requires fewer measurements than conventional methods to achieve high accuracy. We highlight the advantages of the proposed algorithm that are comparable to other similar approaches.
In the QSP, we showed that the entanglement class of the GHZ and W target states could be prepared with excellent efficiency and well against the noise, such as using an error mitigation protocol. This result is applicable to any arbitrary target state. We also addressed the effect of the barren plateau that is unavoidable due to the increase of the system's space. In the QST, we gain high fidelity for reconstructing an entire unknown random state by choosing a proper circuit depth via the number of lay-ers in the quantum circuit. Besides, our method can compare with a similar scheme based on classical shadow tomography and exhibit a better result.
The proposed UC-VQA can further promise applications to quantum metrology, quantum sensing, and new frontier foundation aspects. Moreover, it is possible to implement the algorithm on near-term quantum computers, and thus it could be a valuable technique for verifying the fidelity of quantum circuits and studying quantum computing.

ACKNOWLEDGMENTS
This work is supported by the Vietnam Academy of Science and Technology (VAST) under the grant number CSCL14.01/22-23, and the VNUHCM-University of Information Technology's Scientific Research Support Fund.
Code availability: The codes used for this study are available in https://github.com/vutuanhai237/UC-VQA.

Appendix A: Fubini-Study tensor metric
We provide a practical example of how to compute a Fubini-Study tensor metric. Let us consider a concrete circuit as shown in Fig. 10. It consists of R x = exp(−i θx 2 σ x ), R z = exp(−i θz 2 σ z ), and CR y = |0 0| ⊗ I 2 + |1 1| ⊗ exp(−i θy 2 σ y ). Since [R x , R z ] = 0 (because they act on different qubits), we can group them into one layer (layer 1), with θ (1) = {θ The elements g (1) ij is given through Eq. (20) as where K x = σx⊗I2 2 and K z = I2⊗σz 2 . Next, we calculate g (2) yy . Starting from Eq. (19) in the main text, we derive |∂ θy ψ 2 = −i|1 1| ⊗ σ y 2 e −i θy 2 σy |ψ 1 . where K y = |1 1| ⊗ σy 2 . To derive expectation values in Eq. (A.6), we prepare |ψ 1 as in Fig. 10, then measure ψ 1 |K 2 y |ψ 1 = 1 4 ψ 1 | |1 1| ⊗ I 2 |ψ 1 and ψ 1 |K y |ψ 1 = We discuss more data supporting the results in Fig. 8 (d,e,f) in the main text. As we discussed above, the accuracy can be improved when increasing the number of layers L. However, we cannot increase L arbitrarily large and need to stop at an optimal point. We define the optimal L as the smallest number of layers that, at the next layer, the accuracy saturates or starts to reduce. In Fig. 11 below, we discuss the optimal L for various cases, where we mark the optimal L with colored arrows. See also Table I below. From the results here, we trace out the optimal L as shown in Fig. 8 in the main text. Economou, and E. Barnes, npj Quantum Information 6, 10 (2020).