Manuscript Offprint
arXiv:2610.11537An Efficient Quantum Circuit for Flow Model Execution Using Quantum Neural Networks
Abstract
Flow models generate trajectories from an initial distribution to a target distribution by solving an ordinary differential equation defined by a velocity field. Flow matching learns this velocity field by modeling the transport dynamics between the two distributions. Wavefunction flow establishes a formal connection between flow models and quantum dynamics by introducing a continuity Hamiltonian, which drives the Schrödinger evolution of quantum states. In this paper, we investigate accurate and efficient quantum simulation of the wavefunction flow, thereby realizing the efficient implementation of flow models on quantum computers. We first leverage a quantum read-only memory (QROM)-based phase kickback framework for the wavefunction flow simulation, generating probability densities that closely match those produced by the corresponding conventional flow model. To address the high circuit-resource cost, we further incorporate a trained quantum neural network (QNN) into the phase kickback framework, replacing QROM for data encoding. Numerical experiments demonstrate that our proposed method implements flow models on quantum computers more efficiently, since it maintains the accuracy of wavefunction flow simulation compared with the QROM-based framework, and significantly reduces the circuit resources.
Keywords: Flow models, Wavefunction flow, Quantum read-only memory, Quantum neural networks
1 Introduction
Generative models (Bond-Taylor et al. 2021) are a class of machine learning algorithms that learn unknown data distributions and generate new samples accordingly. The most widely used generative models include Generative Adversarial Networks (GANs) (Goodfellow et al. 2014), Variational Autoencoders (VAEs) (Kingma and Welling 2013), Autoregressive models (Van Den Oord et al. 2016), and flow models (Gat et al. 2024; Lipman et al. 2022). Flow models aim at generating complex target distributions from simple source distributions by learning velocity fields. The learned velocity fields govern the transportation of distributions. Flow matching (Lipman et al. 2022) provides an efficient method of learning velocity fields by approximating trajectories between source and target distributions that have been predefined, which is an ordinary differential equation (ODE)-based model.
Recently, the connection between flow models and quantum dynamics has been developed (Layden et al. 2025). By introducing a continuity Hamiltonian , the implementation of flow models on quantum computers can be regarded as the Schrödinger evolution under this continuity Hamiltonian. The resulting quantum dynamics is defined as wavefunction flow. Wavefunction flow can be realized through the simulation of the Hamiltonian evolution operator . By discretizing the evolution time and using the Suzuki-Trotter formula, it can be expressed as a product of exponentiation operators corresponding to all Hamiltonian terms (Chen et al. 2022; Low et al. 2023). Here, denotes the discretized time step interval. Each operator can be regarded as a quantum oracle and is implemented sequentially in the quantum circuit (Kornell and Selinger 2023).
Phase kickback (Cleve et al. 1998) is a classical quantum technique for the implementation of the evolution operator . It encodes the eigenvalues of into ancilla qubits, then leverages rotation gates to generate the desired phase . Finally, the adjoint eigenvalue encoding oracle is employed to uncompute the ancilla qubits to the initial states. In the wavefunction flow framework, the continuity Hamiltonian is constructed by the time-dependent potential term and the kinetic term . These two terms can be transformed into diagonal operators and by selecting the appropriate basis (Layden et al. 2025). To implement such evolution operators and using phase kickback frameworks, one of the key steps is to encode all diagonal entries of and into the quantum register.
Quantum read-only memory (QROM) (Babbush et al. 2018; Lee et al. 2021) is a widely used quantum technique for encoding classical data in the quantum circuit, where each data item corresponds to an initial basis state. We utilize QROM-based phase kickback frameworks to implement the evolution operators and for the wavefunction flow simulation, and verify the correspondence between the flow model and the wavefunction flow simulation. However, the QROM circuit is constructed by a series of multi-controlled X gates (Zindorf and Bose 2025), and the decomposition of a multi-controlled X with n control qubits without ancilla qubits requires CNOT gates (Barenco et al. 1995). Here, denotes “of order exactly (Knuth 1976). Hence, QROM faces exponentially increasing computational complexity, which leads to a high circuit resource cost for the wavefunction flow simulation.
To solve this problem, we introduce a specialized quantum neural network (QNN) circuit to replace QROM in the phase kickback framework for the wavefunction flow simulation. The QNN is a type of parameterized quantum circuit (PQC)-based variational quantum algorithm (Abbas et al. 2021; Schuld et al. 2014). It combines features of neural networks and quantum circuits. The main areas of QNN application include classification problems (Mahmud et al. 2024), generative learning (Tian et al. 2023), optimization (Amosy et al. 2024), chemistry (Smaldone et al. 2025), and financial predictions (Paquet and Soleymani 2022). Through appropriate and sufficient training, our QNN-based phase kickback framework can maintain accuracy compared to that of the QROM-based framework. In addition, with this replacement, the number of required CNOT gates can be reduced to . QNN has been applied to Hamiltonian simulation using the variational quantum simulator (VQS) (Li and Benjamin 2017; Heya et al. 2023). The VQS trains the QNN to learn the target quantum state from the given initial quantum state. However, each such QNN is designed for a single initial quantum state, and can generate only the corresponding target quantum state. For a diagonal Hamiltonian operator in the wavefunction flow model, where each diagonal entry corresponds to a different initial state, VQS is unable to generate all the desired target states by training the QNN. Therefore, this approach is not capable of realizing the evolution generated by the entire Hamiltonian. In contrast, our QNN-based framework achieves the whole evolution efficiently.
In this paper, inspired by the theory of wavefunction flow (Layden et al. 2025), we investigate an efficient simulation framework for wavefunction flow, thereby realizing the implementation of flow models on quantum computers efficiently. Building on the QROM-based phase kickback framework, we develop a QNN circuit to replace the QROM for data encoding in the wavefunction flow simulation. The new approach significantly reduces the cost of circuit resources while maintaining accuracy compared with the QROM-based framework. The contributions of the paper are as follows.
• We leverage a QROM-based phase kickback technique to simulate wavefunction flow, thereby verifying the wavefunction flow theory and demonstrating the feasibility of implementing flow models on quantum computers.
-
We propose a QNN circuit to replace QROM in the phase kickback framework for data encoding in the wavefunction flow simulation. Instead of employing multi-controlled X gates to encode the exact binary bits in the ancilla qubits through QROM, our QNN circuit learns the mapping from the states of the address qubits to the corresponding probabilities of the ancilla qubits through training parameterized rotation gates and controlled rotation gates. This method avoids the use of high-level controlled gates and the high circuit resource cost. We also extend the model to encode time-dependent potential operators by utilizing a time oracle inside the QNN circuit. Compared with the QROM-based framework, our proposed QNN-based phase kickback framework maintains accuracy in wavefunction flow simulation while significantly reducing circuit resources, enabling the implementation of flow models on quantum computers more efficiently.
-
We combine flow matching with wavefunction flow simulation. The conventional flow model employs the velocity field learned from flow matching to generate the final distribution. In our work, we learn the potential using flow matching, and its gradient defines the conservative velocity field. Then we incorporate this velocity field into our wavefunction flow simulation. The final distribution generated by the wavefunction flow simulation successfully reconstructs the target distribution and matches the final distribution generated by the conventional flow model. This demonstrates the feasibility of employing wavefunction flow simulation for implementing flow models on quantum computers.
The remainder of this paper is organized as follows. Section 2 provides a review of the flow model and flow matching, wavefunction flow, Hamiltonian simulation, quantum data encoding via QROM, and QNN. Section 3 introduces the efficient wavefunction flow simulation through the QROM-based phase kickback framework and our proposed QNN-based phase kickback framework. Section 4 presents the experimental results and the discussion. Section 5 provides a brief conclusion.
2.1 Flow model and flow matching
The flow model is defined by a time-dependent -dimensional velocity field , which generates the flow of samples through the ODE
Given samples from the -dimensional initial distribution , new samples can be generated that follow the target -dimensional distribution by solving Equation (1).
Flow matching (Lipman et al. 2022) aims to learn a parameterized velocity field that approximates the exact velocity field , which generates a probability path from an initial distribution to a target distribution . This is done in two steps. First, a -dimensional probability path connecting and is defined. For samples and , the flow trajectory can be viewed as the interpolation over (Lipman et al. 2022; Liu et al. 2022)
The conditional probability path can be defined conditioned on a sample pair , resulting in the probability path that follows the expression (Lipman et al. 2022; Feng et al. 2025)
which describes the transport of probability from to .
In the second step, a parameterized velocity field that can generate is learned through neural networks. It has been demonstrated that there exists a target velocity field that is capable of generating the probability path (Lipman et al. 2022; Feng et al. 2025). This produces the flow matching objective
However, this objective is difficult to implement, as the velocity field is complicated and difficult to evaluate. Therefore, the conditional velocity field can be employed to simplify the training process (Lipman et al. 2022, 2024). For the interpolation trajectory in Equation (2), the conditional velocity field can be defined as the derivative of with respect to time t
Then, the conditional flow matching objective is defined as
A neural network with parameters is trained to learn by minimizing the objective. After training, the trajectory can be generated using the Euler update rule
or a higher-order Runge-Kutta method, such as RK45. (Dormand and Prince 1980).
2.2 Wavefunction flow
This section reviews the wavefunction flow theory proposed in (Layden et al. 2025), including the connection between flow models and quantum dynamics, the construction of the continuity Hamiltonian, and the definition of the wavefunction flow.
Define . For an infinitesimal time step , by defining the position transformation , and by employing the change of variable formula, one can describe the change of probability density through its Jacobian. This determines that the probability path in Equation (3), which is generated by the velocity field , satisfies the continuity equation
The connection between flow models and quantum dynamics has been established by the definition of an appropriate continuity Hamiltonian. Given the probability path
and its wavefunction , by derivation
and by applying the product rule, we obtain
(10)
Thus, if follows the continuity equation (8) under the velocity field , the wavefunction follows the Schrödinger equation
under time-dependent d-dimensional continuity Hamiltonian defined as
Here, denotes the d-dimensional momentum operator.
When the velocity field is conservative, i.e., , where is a potential function, the corresponding time-dependent continuity Hamiltonian can be written in commutator form
Here, , and denotes the kinetic energy operator. In addition, represents the potential function.
Therefore, the continuity Hamiltonians defined in Equations (12) and (13) establish the equivalence between the continuity equation and the corresponding Schrödinger equation. This equivalence formulates the close connection between flow models and quantum dynamics. Given the initial distribution and the corresponding wavefunction , define the entire evolution time as . The final distribution generated by the flow model under the velocity field has the following relationship with the final wavefunction evolved through the Schrödinger equation driven by the -based continuity Hamiltonian
By constructing the continuity Hamiltonian, the quantum dynamics it generates is defined as a wavefunction flow.
2.3 Hamiltonian simulation
To implement the evolution of the wavefunction flow on a quantum computer, the corresponding continuity Hamiltonian must be efficiently simulated. This can be achieved by Hamiltonian simulation, which implements quantum dynamics generated by the Schrödinger Equation (11). For the time-dependent continuity Hamiltonian , the solution of the Schrödinger equation (Childs et al. 2021) is
Here denotes the time-ordered operator (Childs et al. 2021), which preserves the Hamiltonians in the correct order according to the time evolution, since Hamiltonians at different times do not commute. This determines the quantum evolution from the initial state to the final state . Therefore, the central objective of the Hamiltonian simulation is to simulate the time evolution operator
The main methods for simulating the operator include the Trotter product formula (Low et al. 2023; Watson and Watkins 2025), the linear combination of unitaries (LCU) (Berry et al. 2015), and Qubitization (Low and Chuang 2019). Among all approaches, the Trotter product formula is the most straightforward to implement. Therefore, it is widely used in various scenarios.
To approximate the operator in Equation (16) using the Trotter product formula, the evolution time T is generally divided into r time steps with the interval . Then is expressed as
where . Each decomposition operator is defined as
and can be approximated by
Given the 4-step Trotter product formula for commutators (Chen et al. 2022)
(19) consider a Hamiltonian of the commutator form . By choosing , we can construct the corresponding approximation term , which generates
(20)
The 8-step product formula (Childs and Wiebe 2013) is a symmetric form of the 4-step Trotter product formula. By choosing , the formula is given by
(21)
2.4 Data encoding via QROM
The question of how to load classical data into quantum computers is a critical problem in quantum algorithms. In Hamiltonian simulation, encoding the data items corresponding to the Hamiltonian operator into the quantum register is the first step.
For example, consider a Hamiltonian that is a diagonal operator; all the diagonal entries must be encoded into the quantum register. Quantum read-only memory (QROM) is a prominent technique used to encode such classical data entries into the quantum register (Babbush et al. 2018); see also (Hann et al. 2021, Sec. VI). Specifically, for an n-qubit quantum circuit system, there are basis states in total. QROM is able to encode N classical data entries in the quantum register, and each data entry corresponds to a basis state.
In the QROM oracle, each data item is represented as an m-bit binary string. For the i-th data entry , the corresponding binary string is expressed as
where . Furthermore, ancilla qubits are used to encode these binary bits in the circuit.
For example, when and , Figure 1 illustrates the corresponding QROM circuit. The first two qubits serve as address qubits associated with the indices of the encoded data entries. The last two qubits are ancilla qubits initialized as , which play the role of the data register. For each address , a controlled operator is implemented through multi-controlled gates, whose control values correspond to the address state . The specific implementation form of depends on the binary string of the -th data entry . If , a multi-controlled will be implemented in the -th ancilla qubit, transforming its state from to . If , no gate is applied, and the state of -th ancilla qubit remains . Hence, each controlled oracle selects a state of the address qubits and encodes the binary representation of the data entry corresponding to the same address index into the quantum circuit.

Fig. 1 QROM circuit for and , where add denotes the address qubits, and anc denotes the ancilla qubits. Multi-controlled operators are implemented on ancilla qubits and controlled by address qubits by iterating over all address states. Black and white control nodes represent controls on and , respectively, which select the different address states. Therefore, the controlled states of four operators are , , and , respectively
Therefore, the operator performs the transformation
for all . This implies that all the classical data entries are encoded into the quantum circuit via QROM.
QROM enables data encoding without preparing them in superposition (Crum et al. 2025). It has been applied in quantum cryptography (Gidney and Ekerå 2021), chemistry (Lee et al. 2021), and some other fields to encode classical data into the quantum circuit.
2.5 Quantum neural networks
Quantum neural networks (QNNs) have been widely used in quantum machine learning. They combine the capabilities of both quantum computing and neural networks. QNNs are frameworks based on parameterized quantum circuits (PQCs) (Benedetti et al. 2019), also known as variational quantum circuits, and optimized by classical gradient-based methods (Abbas et al. 2021).
The workflow of a QNN is summarized as follows. First, for the n-qubit QNN circuit whose initial state is , the input data is encoded into the quantum circuit by preparing the corresponding quantum state . Then, the prepared state passes through several layers consisting of rotation gates parameterized with and CNOT gates (Nielsen and Chuang 2010). The latter generate entanglement between qubits. The evolved state is measured by an observable, such as Pauli-Z. Then, the output of the QNN is defined as the expectation value of the observable (Zhao and Wang 2021)
where M denotes the measurement observable, and represents the final quantum state generated by the QNN
The gradient of the output with respect to can be obtained by the parameter shift rule (Schuld et al. 2019). Once the gradients are obtained, we can construct a suitable loss function to measure the distance between the predicted output and the exact output. Then the learning objective is to minimize the loss function. This process can be completed outside the quantum circuit using classical gradient-based methods, such as the Adam optimizer (Kingma and Ba 2014).
Advanced architectures of QNN include quantum convolutional neural networks (Cong et al. 2019), quantum recurrent neural networks (Siemaszko et al. 2023), quantum graph neural networks (Verdon et al. 2019), and quantum autoencoders (Romero et al. 2017). Recently, the emergence of QNNs in a wide range of applications (Innan et al. 2024; Mahmud et al. 2024; Amosy et al. 2024) has helped quantum machine learning to develop rapidly in different fields.
3 Methodology
In this section, first, a phase kickback framework via QROM for wavefunction flow simulation is presented (see Section 3.1), followed by the proposed QNN-based phase kickback framework for more efficient simulation (see Section 3.2).
3.1 QROM-based phase kickback framework for wavefunction flow simulation
To implement the wavefunction flow simulation under the continuity Hamiltonian defined in Equation (13), both the spatial domain and the evolution time need to be discretized. In addition, we adopt a periodic spatial domain, which can be represented as a d-dimensional torus, to match the Fourier spatial discretization.
3.1.1 Spatial and temporal discretization
In this subsection, we adopt the spatial and temporal discretization methods proposed in (Layden et al. 2025).
Since the kinetic operator is discretized through the quantum Fourier transform (QFT) (Nielsen and Chuang 2010), to match the periodic characteristic of the Fourier basis, and to avoid the spatial boundary discontinuity, the spatial domain is chosen as a torus. Consider a -dimensional torus , where each spatial dimension is defined on the domain . Let be a positive integer power of 2, the domain is first discretized into an -point grid
Thus, the -dimensional grid consists of spatial grid points, and each grid point corresponds to a basis state by assigning an integer index to each coordinate
Here corresponds to the one-hot vector , i.e., , where the -th component is 1 and other components are 0. Therefore, the basis state corresponding to is given by
where denotes the tensor product of the vectors.
For the continuity Hamiltonian associated with the wavefunction flow, which is defined in Equation (13), a discrete continuity Hamiltonian is defined for simulation
Here, denotes the diagonal matrix containing discretized values of the potential function in Equation (13)
Each diagonal entry in corresponds to the value of at the associated spatial grid point , which is given by .
The matrix denotes the discretization of the kinetic operator in Equation (13). For one spatial dimension, . Since we have the second-order derivative of
thus,
Hence, is the eigenfunction of with eigenvalue . Therefore, the kinetic operator is diagonal in the Fourier basis. After spatial discretization, define
where represents the centered Fourier basis index. The diagonal representation of the discretized kinetic operator K in the Fourier basis for one spatial dimension can be defined as
Therefore, K can be expressed using via QFT across all d spatial dimensions, which is defined as
The operator F represents the QFT transformation
This enables us to encode a state by superposition of computational basis , with different relative phases and the same amplitude (Ruiz-Perez and Garcia-Escartin 2017)
The phase shift operator S is defined as
which employ a phase shift value to each basis state . The operator denotes the Kronecker sum, which transforms the one-dimensional matrix into a -dimensional operator
Each term involves applying M to one dimension and applying the identity operator to other dimensions.
The temporal discretization divides the entire evolution time into multiple time steps with the interval . For an interval with , the 8-step Trotter product formula in Equation (21) can be employed for the simulation of the operator to approximate defined in Equation (18). This yields
where
The parameters satisfy according to Equation (21), and N denotes the number of grids in each dimension after spatial discretization.
The corresponding temporal discretization error satisfies
where denotes the spectral norm (Yoshida and Miyato 2017). The spectral norm of a matrix A is defined as
(43) where is a non-zero vector that A can act on.
The 4-step Trotter product formula for commutators defined in Equation (20) can also be utilized for the approximation, which reduces the implementation of from 8 exponential terms to 4. This realizes a more efficient implementation, which generates
where and satisfy according to Equation (20). Thus, we can employ
The corresponding temporal discretization error satisfies
3.1.2 Phase kickback framework-based simulation
For the temporal discretization interval , each exponential term in the corresponding approximation operator defined in Equation (44) can be considered as an oracle. These oracles are implemented sequentially in the quantum circuit, as shown in Figure 2. Here, denote the number of qubits used to represent each spatial dimension, and all of these qubits are defined as address qubits. For the -th spatial dimension, basis states, i.e., address states, are provided, and each address state corresponds to a discretized spatial grid point as described in Equation (26). In addition, denotes the number of ancilla qubits used for data encoding.

Fig. 2 Quantum simulation of using the 4-step Trotter product formula, where denotes the address qubits corresponding to the j-th spatial dimension, and anc denotes the ancilla qubits
Each oracle is suggested to be executed using the phase kickback framework (Layden et al. 2025; Cleve et al. 1998). Since is diagonal, we incorporate QROM into the phase kickback framework to encode the diagonal entries of when implementing the oracle . Figure 3(a) presents the details of the phase kickback simulation of , where the QROM( ) oracle is used to encode all diagonal entries of using the structure shown in Figure 1.
For the diagonal matrix defined in Equation (30), the phase kickback framework is applied over all address qubits across all spatial dimensions. Each

(a) The simulation of
(b) The simulation of in the j-th dimension
Fig. 3 The QROM-based phase kickback framework for the simulation of , and the framework for the simulation of in the j-th spatial dimension, where denotes the address qubits corresponding to the j-th spatial dimension, denotes the i-th ancilla qubit, and
diagonal entry corresponds to a basis state , which is defined in Equation (28). For the -th min-max normalized diagonal entry in , we define its -bit approximation as . Let denote states , the QROM oracle encodes the approximation
into the ancilla qubits conditioned on the corresponding address state . This realizes the state transformation
Then, an gate is applied to each ancilla qubit (see Figure 3), jointly encoding the exponential , which realizes
Finally, the adjoint of the QROM oracle is employed to uncompute the ancilla qubits to the initial states, which is expressed as
Thus, the phase kickback framework realizes the transformation over all basis states
According to Equation (35), for the kinetic operator , to simulate the evolution operator , the phase kickback framework corresponding to is implemented independently to each spatial dimension. The implementation of corresponding to the -th spatial dimension is shown in Figure 3(b), where .
Therefore, the simulation among all spatial dimensions performs
3.2 QNN-based phase kickback framework for wavefunction flow simulation
Although QROM is widely used in data encoding applications, for address qubits, it requires CNOT gates (Barenco et al. 1995) for implementation, facing exponentially increasing computational complexity. To address this problem, we propose a QNN circuit for wavefunction flow simulation, which replaces QROM in the phase kickback framework with a trained QNN for data encoding. The proposed QNN mimics the structure of QROM by employing controlled rotation gates instead of multi-controlled gates, which reduces the number of CNOT gates to . The structure of the QNN-based phase kickback framework to implement the potential evolution operator is illustrated in Figure 4(a), and the framework for implementing the kinetic evolution operator in the -th spatial dimension is shown in Figure 4(b).

(a) The simulation of
(b) The simulation of in the j-th dimension
Fig. 4 The QNN-based phase kickback framework for the simulation of , and the framework for the simulation of corresponding to the j-th spatial dimension, where
We first propose a time-independent QNN circuit for the phase kickback framework of the kinetic evolution operator , which does not change over time. Then we introduce a QNN circuit for the phase kickback framework of the time-dependent potential evolution operator by integrating a time oracle into the time-independent QNN circuit.
3.2.1 Time-independent QNN circuit for kinetic evolution operators
Consider the simulation of the kinetic evolution operator corresponding to one spatial dimension; QROM encodes the -th diagonal entry of by loading its binary fractional representation into the ancilla qubits as basis states. For the -th ancilla qubit, the resulting state is after the implementation of the QROM oracle. To replace QROM, we propose a QNN circuit, which learns the map from the address state to the corresponding ancilla states
. The QNN circuit encodes into the ancilla qubits by loading the predicted probabilities through minimizing the approximation error. Specifically, the trained QNN performs the map
Here denotes the predicted probability of given the state generated by the trained QNN.
The training of the QNN can be viewed as a binary classification problem in machine learning for each ancilla qubit. Therefore, the loss function is defined using binary cross-entropy loss
where denotes the number of diagonal entries in the matrix . After training, the predicted state is employed to encode the approximation of into the ancilla qubits by the trained QNN circuit.
The time-independent QNN in each spatial dimension has repeated layers implemented in sequence, which is shown in Figure 5. Each layer contains Rot oracles and controlled-Rot oracles, which is illustrated in Figure 6.

Fig. 5 The QNN circuit in the phase kickback framework for the simulation of corresponding to the j-th spatial dimension

Fig. 6 The QNN layer circuit in the phase kickback framework for the simulation of corresponding to the j-th spatial dimension, where denotes the i-th address qubit corresponding to the j-th spatial dimension
Inside each layer, m Rot oracles are applied to the ancilla qubits in the beginning. Then, a controlled Rot oracle is applied between each address qubit and ancilla qubit. The address qubits are controls, and ancilla qubits serve as targets. Each Rot oracle consists of three rotation gates, and each controlled-Rot gate contains three controlled rotation gates, as shown in Figure 7.

(a) The structure of a Rot oracle

(b) The structure of a controlled-Rot oracle
Fig. 7 Circuits of Rot and controlled-Rot oracles, , and denote three angle parameters in each oracle
3.2.2 Time-dependent QNN circuit for potential evolution operators
QROM encodes diagonal entries of the diagonal matrix at each time , respectively, where denotes the number of address states provided by all address qubits of dimensions jointly. We propose a time-dependent QNN circuit that can encode the diagonal operator at time into the phase kickback framework by incorporating a time register oracle. For a time step and the corresponding time , given the -th diagonal entry and its binary fractional representation , the QNN learns the map from the address state to probabilities . This generates
Let denote the predicted probability of -th ancilla qubit measured in state for the state generated by the trained QNN. To learn the encoding of all diagonal entries over all time steps, the loss function for QNN training is defined as
where denotes the number of discretized time intervals. After training, the predicted state is employed to encode the approximation of into the ancilla qubits by the trained QNN circuit.
For the time step h, the time-dependent QNN circuit operates on the address qubits across all spatial dimensions together with the ancilla qubits. The repeated layers are applied in sequence between a time register oracle and its adjoint oracle, which is shown in Figure 8.

Fig. 8 The time-dependent QNN circuit in the phase kickback framework for the simulation of
In each layer, m Rot oracles operate on the m ancilla qubits. A controlled-Rot oracle is applied between each address qubit and the ancilla qubit. Figure 9 illustrates the structure of the layer.

Fig. 9 The QNN layer circuit in the phase kickback framework for the implementation of
The Time oracle contains X gates applied to selected ancilla qubits according to the binary representation of the time step . For example, when , the states of the ancilla qubits are set as . Hence, no X gate operates on the ancilla qubits. When , the ancilla qubits are prepared in the states . Thus, an X gate is applied to the last ancilla qubit in oracle Time(1). Examples of the Time oracle are shown in Figure 10.
3.2.3 Resource analysis of QROM and QNN circuits
To compare the circuit resources required for QROM and our proposed QNN simulation directly, we analyze the number of CNOT gates required in QROM and QNN circuits with the same number of address qubits and ancilla qubits.
For a QROM circuit with n address qubits and m ancilla qubits, whose structure is the same as shown in Figure 1, the number of data entries to be encoded in the

(a) The structure of Time(1)
(b) The structure of Time(3)
Fig. 10 Examples of the Time oracles
quantum register is , corresponding to all address states. In addition, each data entry corresponds to binary bits that are encoded in ancilla qubits. Therefore, the number of multi-controlled gates in the QROM circuit is .
According to the multi-controlled X decomposition method without ancilla qubits (Barenco et al. 1995), a multi-controlled X gate with n control qubits consists of CNOT gates. Thus, the number of CNOT gates required for the QROM circuit is . Therefore, for fixed m and l, the number of CNOT gates scales as
resulting in exponential growth with the increase of n.
For our QNN circuit containing l layers with the same number of address qubits and ancilla qubits, whose layer structure is shown in Figure 6, mn controlled-Rot oracles are required in each layer. Since each controlled-Rot oracle consists of 3 controlled rotation gates, and each controlled rotation gate requires 2 CNOT gates for decomposition (Barenco et al. 1995), the total number of CNOT gates in each QNN layer is 6mn. Thus, the number of CNOT gates required for the QNN circuit is 6mnl. Therefore, for fixed m and l, the number of CNOT gates scales as
This shows that the number of CNOT gates grows linearly as n increases in the QNN circuit.
From Equations (57) and (58), it is clear that our proposed QNN circuit requires significantly fewer circuit resources than the QROM circuit with a large value of n. This is also numerically evaluated in Subsection 4.4.2.
4 Results and discussion
4.1 Reference method
Given the initial distribution, to evaluate the performance of our approach, the final probability distributions generated by the wavefunction simulation are compared with the reference final distribution obtained from the corresponding conventional flow model, i.e., the solution of the continuity equation defined in Equation (8).
Given the initial distribution and the corresponding wavefunction , for the evolution time , the final wavefunction generated by the wavefunction flow simulation produces the final probability distribution through . Here, denotes a -dimensional grid point.
The reference final distribution is generated through the numerical solution of the continuity equation
where the velocity field is conservative and is generated by the potential function .
If the dimension of is 1, the continuity equation becomes
If is multi-dimensional, the continuity equation can be written as
Starting from the initial distribution , the spatial derivative terms in the continuity function are obtained using the Fourier spectral method, and the corresponding equation is then solved from to using the RK45 method. This generates the reference final distribution .
4.2 Experimental setup
4.2.1 Simulation environment and settings
All quantum simulation-based experiments were conducted using Python 3.12. The quantum software stack comprised Xanadu's Pennylane 0.45.1 and pennylane-lightning 0.45.0. Quantum circuits were executed using the lightning.gpu backend on an NVIDIA Tesla T4 GPU.
The RK45 solver used to generate reference solutions of the continuity equation in Equation (8) is provided by SciPy, and both relative and absolute tolerances are 1e-12.
The one-dimensional and two-dimensional wavefunction flow simulations were implemented in our experiments. For the one-dimensional wavefunction flow simulation circuit, we set the number of address qubits to 4, which is capable of representing discretized spatial points in total. In addition, 10 ancilla qubits were used to encode the data entries of potential and kinetic operators into the quantum circuit. We also employed 3 address qubits for each spatial dimension when implementing the two-dimensional wavefunction flow simulation, corresponding to discretized spatial grid points per dimension. The number of ancilla qubits is 12.
In our experiments, the uniform distribution and a periodic exponential distribution given by
(62) were chosen as the initial distribution for the wavefunction flow simulation and reference solutions. In the periodic exponential distribution, is a constant, and we set in our experiments. Both distributions are normalized so that their total probability is 1, and the corresponding initial density is represented as .
4.2.2 Evaluation metrics
Let denote the -th discretized spatial point in the wavefunction flow simulation, and let denote the -th discretized spatial point in the reference method. Let represent the final probability at generated by the wavefunction flow simulation, and let denote the reference final probability at . Denote
as the corresponding wavefunction flow simulation-generated final probability density, and denote
as the corresponding reference final probability density. Here, is the spatial discretization interval in each dimension for wavefunction flow simulation, and denotes the spatial discretization interval employed in the reference method. Let denote the number of discretized spatial grid points in the wavefunction flow simulation. To implement the evaluation, the reference final probability density is linearly interpolated onto the spatial grids of the wavefunction flow simulation. Let the interpolated reference final probability density at be represented by .
To evaluate the accuracy of the wavefunction flow simulation, we employ four error metrics: the root mean square error (RMSE), relative maximum error (RME), KL divergence ( ), and Wasserstein-1 distance ( )
• Root mean square error (RMSE)
- Relative maximum error (RME), which measures the maximum difference between probability densities and , normalized by the maximum value of the reference final probability density
- Kullback-Leibler (KL) divergence, which measures the distance between the normalized final density and the normalized reference final probability density
(65) where
• Wasserstein-1 distance, which measures the minimum cost of transporting the normalized final density to
Here
and denotes the amount of probability density moving from to .
Smaller values of these error metrics indicate higher consistency between the final probability densities generated by the wavefunction flow simulation and the reference final probability densities, and demonstrate higher accuracy of the wavefunction flow simulation.
4.3 Training analysis of the QNN circuit
To implement the wavefunction flow simulation using a trained QNN-based phase kickback framework, the QNN circuits shown in Figures 5 and 8 must be trained first. The values of parameters in QNN circuits were initialized from a normal distribution . The evolution time was set to 0.02 s, which was divided into 200 time steps. We chose a one-dimensional potential function
We analyzed the convergence of the training process and compared the performance of different numbers of QNN layers and different loss functions.
4.3.1 Depth analysis
We conducted an experiment for the convergence analysis of the QNN training process with different numbers of QNN layers. For the simulation of the potential evolution operator , the QNN circuit shown in Figure 8 was employed for each time step. To simulate the kinetic evolution operator , the QNN circuit shown in Figure 5 was implemented independently to each spatial dimension.
For the training of QNN circuits associated with the potential and kinetic evolution, the loss functions defined in Equations (54) and (56) were used, respectively. The Adam optimizer with a learning rate of 0.3 was employed in the training process. We recorded the training losses for the QNN circuits of both potential and kinetic evolution with different numbers of layers. The loss convergence curves are shown in

Fig. 11 The training losses for the potential and kinetic evolution QNN circuits with different numbers of layers
Table 1 Final training loss values under different depths of QNN circuits
| Number of layers | QNN circuit for potential evolution | QNN circuit for kinetic evolution |
|---|---|---|
| 1 | 0.1712 | 0.1499 |
| 2 | 0.0421 | 0.0279 |
| 3 | 0.0039 | 0.0073 |
| 4 | 0.0001 | 0.0001 |
Figure 11. The final loss values for potential and kinetic evolution QNN circuits with different depths are shown in Table 1.
Figure 11 shows that the training losses for both the QNN circuits for potential and kinetic evolution decrease as the training step increases, demonstrating the stable training process and the convergence behavior. For both QNN circuits, as the number of layers increases, the convergence of loss becomes faster, and the final training loss becomes lower. These results indicate that a deeper QNN circuit is able to improve the performance of approximating QROM in the phase kickback frameworks.
In addition, as shown in Table 1, the final training losses of two QNN circuits for are 0.1712 and 0.1499, respectively. When increases to 4, the final training losses are both 0.0001. This indicates that the training loss becomes very small when the QNN depth reaches 4. In addition, as increases, the final training loss decreases rapidly, demonstrating a rapid convergence of the loss with respect to .
4.3.2 Loss function comparison
To explore the influence of different loss functions for QNN training, we compared three loss functions in the training process
-
Loss function 1: Binary cross-entropy loss defined in Equations (54) and (56).
-
Loss function 2: Mean squared error between the exact values of diagonal entries and the values generated by predicted probabilities obtained from the QNN circuit
- Loss function 3: Fidelity-based loss between the normalized vectors based on exact potential and kinetic diagonal entries and those predicted by the QNN circuit
where and denote the normalized vectors consisting of the exact diagonal entries of and , respectively. And and denote the normalized vectors consisting of the predicted diagonal entries of and generated by the QNN circuit.
For the simulation of potential and kinetic operators, the Adam optimizer with a learning rate of 0.3 is adopted, and the number of QNN layers is 2.
(a) The training loss for the potential evolution QNN circuit

(b) The training loss for the kinetic evolution QNN circuit
Fig. 12 The training losses for the potential and kinetic evolution QNN circuits with different loss functions
Figure 12 shows the training loss curves for both QNN circuits using three loss functions. For both QNN circuits of potential and kinetic evolution, the training losses of all three loss functions converge steadily, and their final values reach approximately 0. Meanwhile, the convergence speed of Loss function 1 is lower than those of Loss functions 2 and 3. This indicates that Loss functions 2 and 3 outperform Loss function 1 for the training process of both QNN circuits according to the training speed.
However, when comparing the binary representations of the exact potential diagonal entries of with the corresponding probabilities learned by QNN under different loss functions, different performances are exhibited. The results are shown in Figure 13. The mean distances and standard deviations across all probabilities associated with all diagonal entries of under different loss functions are summarized in Table 2.

Fig. 13 The comparison between the binary representations of the exact potential diagonal entries of and the corresponding probabilities learned by the QNN circuit under different loss functions. The -axis represents the states of the input, where each state corresponds to a diagonal entry. The -axis represents the ancilla qubit indices, where the -th qubit index corresponds to the -th binary bit of the diagonal entry
Table 2 The mean distances and standard deviations across all probabilities under different loss functions
| Loss function | Mean distance | Standard deviation |
|---|---|---|
| Loss function 1 | 0.0001 | 0.0001 |
| Loss function 2 | 0.3726 | 0.3645 |
| Loss function 3 | 0.4027 | 0.3286 |
It is observed from the results that the predicted probabilities generated by the QNN circuit using Loss function 1 successfully approximate the exact binary bits of the diagonal entries, which are 0 and 1. However, the predicted probabilities generated by the QNN circuit using Loss functions 2 and 3 cannot match the corresponding binary representation, since massive probabilities stay far from 0 and 1. These indicate that, compared with the other two loss functions, the output states of the QNN circuits using the binary cross-entropy loss are precise and pure, which reduce entanglement significantly. In addition, as shown in Table 2, the mean distance and standard deviation under Loss function 1 are both 0.0001, which are significantly lower than those obtained under Loss functions 2 and 3. These results demonstrate that the binary cross-entropy loss outperforms the other two loss functions in the training of potential and kinetic evolution QNN circuits according to the binary bit approximation.
4.4 Comparison between QNN and QROM-based phase kickback frameworks for wavefunction flow simulation
To evaluate the performance of wavefunction flow simulation through our QNN-based phase kickback framework, we first compared its final probability densities with those obtained by the QROM-based phase kickback framework. Then we compared the CNOT gate cost of QROM and QNN circuits, as well as the corresponding phase kickback frameworks with different address qubits. The decomposition tools in PennyLane are used for counting the number of CNOT gates.
4.4.1 Accuracy comparison
We first conducted a comprehensive study of the accuracy performance of the wave-function flow simulation using our trained QNN-based and QROM-based phase kickback frameworks under fixed potentials. To this end, given the same initial distribution, we evaluated the final probability densities generated by the two frameworks compared to the reference final densities, i.e., the results generated by the corresponding conventional flow model.
We set , and the domain of each spatial dimension is . We chose four periodic time-dependent potentials, two of which are one-dimensional,
The other two potentials are two-dimensional,
All these potentials are normalized to using the min-max normalization.
The QROM-based phase kickback frameworks for the simulation of potential and kinetic evolution operators are shown in Figures 3(a) and 3(b), respectively. The evolution time T was set to 0.02 s and discretized into time steps. Thus, each time interval is . We recorded the final probability densities generated by the wavefunction flow simulation using two frameworks. Then we compared them with the corresponding reference final probability densities, which were obtained by solving Equations (60) and (61) using the RK45 method with the same values of T and as those used in the wavefunction flow simulation. For the one-dimensional case, the number of discretized spatial grid points in the reference method is twice that employed in the wavefunction flow simulation. For the two-dimensional case, the number of grid points for each dimension in the reference method is the same as that in the wavefunction flow simulation. The comparison results with different potentials and initial distributions are shown in Figures 14, 15, 16, and 17. Tables 3 and 4 summarize the different error metrics between the final probability densities generated
(a) Uniform initial distribution
(b) Periodic exponential initial distribution

Fig. 14 Comparison of final probability densities generated by wavefunction flow simulation using QNN- and QROM-based phase kickback frameworks, and reference final densities under
(a) Uniform initial distribution
(b) Periodic exponential initial distribution

Fig. 15 Comparison of final probability densities generated by wavefunction flow simulation using QNN and QROM-based phase kickback frameworks, and reference final densities under
by the wavefunction flow simulation using QNN and QROM-based phase kickback frameworks, and the corresponding reference final probability densities.
We first evaluate the performance of the wavefunction flow simulation by comparing its results with those obtained from the flow model. As shown in Figures 14 and 15, the final probability densities produced by the wavefunction flow simulation using both QNN and QROM-based phase kickback frameworks under one-dimensional potentials closely match the corresponding reference final densities under uniform and periodic exponential initial distributions. This is because their curves almost overlap and the values at each discrete spatial point nearly coincide. In addition, Figures 16 and 17 exhibit consistent densities generated by wavefunction flow simulation using two frameworks and the reference method under two-dimensional potentials.

(a) Uniform initial distribution

(b) Periodic exponential initial distribution
Fig. 16 Comparison of final probability densities generated by wavefunction flow simulation using QNN- and QROM-based phase kickback frameworks, and reference final densities under
Table 3 Errors between final probability densities generated by wavefunction flow simulation using QNN- and QROM-based phase kickback frameworks, and reference final probability densities under the uniform initial distribution
| V | QNN-based phase kickback | QROM-based phase kickback | ||||||
|---|---|---|---|---|---|---|---|---|
| RMSE | RME | RMSE | RME | |||||
| 5.965e-3 | 0.011 | 6.475e-5 | 1.119e-3 | 6.141e-3 | 0.012 | 6.677e-5 | 9.107e-4 | |
| 6.424e-3 | 0.014 | 6.443e-5 | 9.353e-4 | 6.381e-3 | 0.014 | 6.386e-5 | 9.191e-4 | |
| 1.580e-4 | 0.013 | 6.028e-5 | 7.397e-3 | 1.550e-4 | 0.011 | 5.306e-5 | 7.202e-3 | |
| 1.572e-4 | 0.011 | 5.548e-5 | 6.819e-3 | 1.568e-4 | 0.011 | 5.499e-5 | 6.818e-3 | |
According to Tables 3 and 4, the RMSE values corresponding to the one-dimensional potentials are on the order of , while those for the two-dimensional potentials are on the order of . These results indicate very small density errors between the wavefunction flow simulation and the reference method. The RME measures the maximum difference of all discretized spatial points between the wavefunction flow simulation and the reference method. All RME values are not greater than 0.022, which shows that local density errors at all spatial points are well controlled.
We take small KL divergence values to indicate reliable density matching, and all the values in the two tables are below . In addition, all the values of in the two tables are below 0.02. These also indicate the close agreement between the densities. All these results demonstrate that the phase kickback framework-based wavefunction flow simulation generates the expected evolution of the wavefunction

(a) Uniform initial distribution

(b) Periodic exponential initial distribution
Fig. 17 Comparison of final probability densities generated by wavefunction flow simulation using QNN- and QROM-based phase kickback frameworks, and reference final densities under
Table 4 Errors between final probability densities generated by wavefunction flow simulation using QNN- and QROM-based phase kickback frameworks, and reference final densities under the periodic exponential initial distribution
| V | QNN-based phase kickback | QROM-based phase kickback | ||||||
|---|---|---|---|---|---|---|---|---|
| RMSE | RME | RMSE | RME | |||||
| 6.339e-3 | 0.012 | 7.010e-5 | 8.843e-4 | 6.234e-3 | 0.013 | 6.724e-5 | 7.669e-4 | |
| 7.154e-3 | 0.013 | 5.382e-5 | 1.444e-3 | 7.852e-3 | 0.013 | 6.704e-5 | 1.382e-3 | |
| 2.344e-4 | 0.013 | 9.852e-5 | 7.870e-3 | 2.346e-4 | 0.013 | 9.826e-5 | 7.870e-3 | |
| 3.465e-4 | 0.021 | 1.691e-4 | 1.051e-2 | 3.525e-4 | 0.022 | 1.720e-4 | 1.036e-2 | |
flow theory and matches the results of the flow model, which is obtained by solving the corresponding continuity equation.
Then we compare the accuracy of wavefunction flow using QNN- and QROM-based wavefunction flow simulation. According to Figures 14, 15, 16, and 17, for all four potentials, the final probability densities produced by the wavefunction flow simulation through the QNN-based phase kickback framework closely match those obtained using the QROM-based phase kickback framework. In Table 3, for , the RMSE, RME, KL divergence, and Wasserstein-1 distance between the final probability density generated by the QNN-based phase kickback framework and the reference final probability density under uniform initial distribution are 5.965e-3, 0.011, 6.475e-5, and 1.119e-3, respectively. These values are very close to those generated by the QROM-based phase kickback framework, which are 6.141e-3, 0.012, 6.677e-5, and 9.107e-4. Similar behaviors are observed for , , and under both initial distributions. All error metrics corresponding to wavefunction flow simulation using the QNN-based phase kickback framework and the QROM-based phase kickback framework show only slight differences. These results demonstrate that the wavefunction flow simulation through the QNN-based phase kickback framework achieves accuracy comparable to that of the simulation using the QROM-based phase kickback framework.
4.4.2 Circuit resource comparison
We measured the number of CNOT gates used in (i) QNN and QROM circuits, (ii) QNN-based phase kickback and QROM-based phase kickback frameworks for the simulation of corresponding to the potential function with different numbers of address qubits. The number of ancilla qubits was set to 6. Figure 18 presents the trends of the CNOT gate counts with different numbers of address qubits. Detailed statistics for QNN and QROM circuits, as well as the corresponding phase kickback frameworks, are shown in Table 5.

Fig. 18 The number of CNOT gates in QNN and QROM circuits obtained from decomposition tools in PennyLane for the simulation of corresponding to
Table 5 The number of CNOT gates in QNN and QROM circuits, and the corresponding phase kickback frameworks from decomposition tools in PennyLane
| n | QNN | QROM | ||
|---|---|---|---|---|
| QNN circuit | Phase kickback framework | QROM circuit | Phase kickback framework | |
| 2 | 192 | 384 | 24 | 48 |
| 3 | 432 | 864 | 576 | 1152 |
| 4 | 960 | 1920 | 6080 | 12160 |
| 5 | 1680 | 3360 | 39424 | 78848 |
As shown in Figure 18 and Table 5, when , the numbers of CNOT gates in the QNN and QROM circuits to simulate are 192 and 24, respectively. As increases from 2 to 5, the number of CNOT gates in the QNN circuit increases to 1680. However, the number of CNOT gates in the QROM circuit increases exponentially to 39424, which is significantly higher than that of the QNN circuit.
In addition, the number of CNOT gates required for the QNN-based phase kickback framework is twice that of the single QNN circuit. The same applies to the QROM-based phase kickback framework, since the phase kickback framework includes a QROM or QNN circuit together with its adjoint.
Overall, these results demonstrate that as we introduce more address qubits to improve the precision of the wavefunction flow simulation, the QROM-based framework requires more circuit resources than the QNN-based framework. Therefore, our QNN-based framework provides a more efficient method for the implementation of flow models on quantum computers.
4.5 Error analysis
We investigate the errors in the phase kickback framework-based wavefunction flow simulation. The primary sources of quantum simulation errors include the approximation errors of the values encoded in the phase kickback framework, spatial discretization errors, and temporal discretization errors.
4.5.1 Phase kickback encoding error
To simulate the potential evolution operator using the phase kickback framework, each diagonal entry in must first be encoded in the ancilla register. For a phase kickback framework with ancilla qubits, the corresponding approximation value is encoded in the quantum circuit
where denotes the binary fractional representation of .
Similarly, to simulate the kinetic evolution operator , for any diagonal entry in the operator , whose binary fractional representation is , the approximation value is encoded in the circuit
When changes, the approximation errors and are expected to follow
We set the evolution time T to 0.1 s, and the number of time steps to 100. The potential function was chosen to be
which is normalized to using the min-max normalization. The uniform distribution was chosen as the initial distribution. We evaluated the errors between the final densities generated by the wavefunction flow simulation and the reference final densities with different values of m. The results are shown in Figure 19.

Fig. 19 Errors between the final probability densities generated by wavefunction flow simulation and the reference final probability densities with different numbers of ancilla qubits m
Increasing the number of ancilla qubits m leads to an increase in the number of binary fractional representation bits of the diagonal entries. According to Equation (70), the corresponding approximation error is expected to decrease. As shown in Figure 19, when the number of ancilla qubits increases from 6 to 14, the final density error decreases from 4.7e-02 to a converged value of 4.4e-03. This indicates that increasing the number of ancilla qubits improves the approximation precision of the phase kickback data encoding and enhances the accuracy of the wavefunction flow simulation.
4.5.2 Spatial discretization error
To perform the wavefunction flow simulation corresponding to the continuous Hamiltonian defined in the spatial domain , the method described in Subsection 3.1.1 was employed for spatial discretization. The domain of each spatial dimension was first discretized into points . The kinetic operator corresponding to each spatial dimension was then discretized into diagonal entries, and the potential operator was discretized into diagonal entries across all dimensions. These diagonal entries are encoded in the phase kickback framework. In the wavefunction flow simulation circuit, spatial discretization depends on the number of address qubits. When the number of address qubits for each spatial dimension is , the number of discretized points for each dimension is . Each discretized point corresponds to a basis state, into which the associated discretized potential and kinetic entries are encoded.
We set the evolution time to 0.02 s, and the number of time steps to 200. The one-dimensional potential function was given by Equation (71), and the initial distribution was the uniform distribution. The number of address qubits changed from 2 to 8, corresponding to discretized spatial points and discretization intervals .

Fig. 20 Errors between the final probability densities generated by wavefunction flow simulation and reference final probability densities with different
Figure 20 shows the RMSE between the final probability densities generated by the wavefunction flow simulation and the reference final probability densities with different discretization intervals. When the number of address qubits increases from 2 to 5, the spatial discretization interval decreases from 0.5 to 0.0625, while the RMSE decreases approximately exponentially from 4.670e-03 to 4.093e-05. This is consistent with the expected rapid decrease of the error, since we adopt Fourier spatial discretization and a smooth periodic initial distribution. As continues to increase from 5 to 8, corresponding to a decrease in from 0.0625 to 0.0078125, the RMSE converges to a value of 1.075e-05. A further decrease of the spatial discretization interval will not lead to a lower error, since the temporal discretization error becomes dominant. These results demonstrate that finer discretized spatial intervals improve the accuracy of the wavefunction flow simulation.
4.5.3 Temporal discretization error
For the evolution time in the wavefunction flow simulation, the method described in Subsection 3.1.1 was employed for temporal discretization. The total time was divided into time intervals , where denotes the length of each interval. At each discrete time point, the diagonal operator varies, leading to a different quantum simulation of using the Trotter product formula. The diagonal operator remains unchanged with time, making the simulation of identical at different time steps.
We set the evolution time to 0.1 s, and the number of time steps varied in , leading to different values of the discretized temporal interval . The initial distribution was chosen to be the uniform distribution, and the potential function was defined as
which is normalized to using the min-max normalization.

Fig. 21 Errors between the final probability densities generated by the wavefunction flow simulation and reference final probability densities with different under different numbers of address qubits
Figure 21 exhibits the RMSE between the final probability densities generated by the wavefunction flow simulation and the reference final probability densities with different discretized temporal intervals under different discretized spatial points. We chose the number of address qubits to be 4, 5 and 6 for comparison, corresponding to the number of discretized spatial points 16, 32 and 64, respectively, leading to a decrease in . As increases and the corresponding decreases, the final density errors under all three values of decrease. This shows that smaller temporal discretization intervals improve the precision of the wavefunction flow simulation.
However, for , corresponding to , the temporal discretization error converges to about 1.0e-03. For , whose corresponding is 0.0625, the temporal discretization error converges to about 1.5e-04. This value is much lower than that of . This is more significant when , where decreases further to 0.03125, the temporal discretization error decreases linearly with increasing and does not show convergence until . This is consistent with a straight line scaling as . These results indicate that smaller influence the temporal discretization errors less significantly. However, we observe that the decreasing trend does not match the expected temporal discretization error with a scaling as analyzed in Equation (46), this is because the influence of a combination of other sources of error.
4.6 Evaluation of wavefunction flow simulation combined with flow matching
In Subsection 4.4, the potentials employed in the wavefunction flow simulation are fixed. We now consider the potential learned through the flow matching process.
Given the initial and target distributions, the flow matching learns a velocity field that governs the transport of particles from the initial distribution to the target distribution. We adopted a two-dimensional distribution transport experiment. The initial distribution is uniform in the domain , and the target distribution consists of four Gaussian balls centered at , , and , each with standard deviation 0.2. The left part of Figure 22 shows the initial and target particle plots.
Instead of directly learning the velocity field, we used neural networks to learn the potential using flow matching. The gradient of defines the velocity field that transports particles from to . The total evolution time was set to 2 s, and the number of time steps for particle transport was 2000. Then was learned using a fully connected neural network with layer widths of 5-128-64-32-16-1, and the Tanh activation function was employed in each hidden layer. To satisfy the periodic requirement of the spatial domain, each spatial variable was encoded using sine and cosine functions. Then they were combined with the time variable , resulting in a 5-dimensional input. The velocity field generated by the learned was then employed to guide particle transportation starting from in the flow model. The right part of Figure 22 presents the final particle plot transported by the velocity field produced by the learned , together with the target particle plot.
Initial and Target Particles plots

Particle plots transported by learned , T=0.2
Fig. 22 The left figure shows the initial and the target particle plots. The right figure shows the final particle plot obtained by the flow model, in which the particles are transported under the velocity field generated by the learned potential through flow matching, together with the exact target particle plot
As shown in Figure 22, the flow model successfully transports particles from the initial distribution to the target distribution consisting of four Gaussian balls using the learned potential through flow matching. Although there are a few scattered particles outside each Gaussian ball, they can be regarded as the error generated by flow matching learning.
The learned by flow matching was then incorporated into the wavefunction flow simulation as the potential operator in the evolution of . The total time was set to 2 s, and the number of time steps was 200. The number of address qubits for each spatial dimension was set to 3, generating 8 spatial points in each dimension. The evolution was implemented following the process of Figure 2 with the uniform initial distribution.

Fig. 23 Comparison of the final probability density obtained by wavefunction flow simulation and the target distribution. The first figure represents the initial probability density, the second figure denotes the final probability density obtained by the wavefunction flow simulation, the third figure shows the corresponding reference final density, and the last figure shows the target probability density consisting of four Gaussian balls
Figure 23 shows the initial density, the final probability density obtained by the wavefunction flow simulation, the reference final density generated by the flow model, and the target probability density. Both the final density obtained by the wavefunction flow simulation and the reference final density have four peak regions, which match the target distribution consisting of four Gaussian balls. This indicates that the wavefunction flow simulation, driven by the velocity field generated by learned from the flow matching, successfully generates the target density, and produces results consistent with those obtained from the flow model. Although the probability density value of each peak in the final probability density is lower than those of the reference final density and the target probability density, the similarity between the probability densities demonstrates that flow matching can be successfully integrated with the wavefunction flow simulation.
Table 6 Comparison of final probability density errors between wavefunction flow simulation and the reference method
| Method | RMSE | Wasserstein-1 distance | KL divergence |
|---|---|---|---|
| Wavefunction flow simulation | 2.248e-2 | 8.338e-2 | 2.935e-1 |
| Reference method | 3.291e-2 | 9.213e-2 | 2.492e+0 |
Table 6 summarizes the RMSE, Wasserstein-1 distance, and KL divergence between the final probability density generated by the wavefunction flow simulation and the target probability density, as well as those between the corresponding reference final probability density and the target probability density. As shown in Table 6, these values for the wavefunction flow simulation are 2.248e-2, 8.338e-2, and 2.935e-1, which are close to those generated by the reference method. These results demonstrate that the wavefunction flow simulation is comparable to the reference method, i.e. the conventional flow model, in generating the target probability density driven by the velocity field learned from flow matching.
5 Conclusion
We employed a QROM-based phase kickback framework for wavefunction flow simulation to verify the wavefunction flow theory, thereby realizing the implementation of flow models on quantum computers. The experimental results show that this framework generates final distributions that are highly consistent with those obtained from the corresponding conventional flow model. We also proposed a QNN circuit to replace QROM for more efficient wavefunction flow simulation. Experiments show that our QNN-based phase kickback framework maintains the accuracy of the wavefunction flow simulation compared with the QROM-based phase kickback framework while reducing the circuit resources significantly. These results demonstrate that our approach provides a more efficient framework for implementing flow models on quantum computers. Additionally, we incorporate the potential function, which is learned by flow matching, into the wavefunction flow simulation. The results reveal that the final distribution generated by the wavefunction flow simulation successfully reproduces the target distribution and matches those obtained from conventional flow models.
Despite promising results, one major constraint of our model is that for a time-dependent potential function, the values of all discretized time steps should be included in the training process of the time-dependent QNN circuit, resulting in considerable training time. Additionally, to encode multi-dimensional potential and kinetic operators in the circuit using QNN frameworks, more than eight QNN layers are required to maintain high precision. This leads to high circuit resources. Further research could explore a more efficient QNN circuit for replacing QROM and encoding data in quantum circuits. Furthermore, we aim to develop better strategies for training the QNN circuits, which could lead to a more efficient and accurate implementation of the wavefunction flow.
Acknowledgements. We would like to express sincere gratitude to Masood Aryapoor from Mälardalen University for his help in formulating the theoretical framework, insightful discussions, and guidance in preparing the manuscript.
Statements and Declarations
• Funding This research was partially funded by the initiative AI@MDU.
• Competing interests The authors declare no competing interests.
• Ethics approval and consent to participate Not applicable.
• Consent for publication Not applicable.
• Data availability No datasets were generated or analyzed during the current study.
• Materials availability Not applicable.
• Code availability The code used in this study will be made available upon reasonable request.
• Author contribution All authors conceived the research idea. Rui Che conducted the experiments and wrote the main manuscript text. Ludvig af Klinteberg provided guidance and feedback during the research process and manuscript preparation. All authors reviewed the manuscript.
References
Amosy, O., Danzig, T., Lev, O., Porat, E., Chechik, G., Makmal, A.: Iteration-free quantum approximate optimization algorithm using neural networks. Quantum Machine Intelligence 6(2), 38 (2024) https://doi.org/10.1007/s42484-024-00159-y
Abbas, A., Sutter, D., Zoufal, C., Lucchi, A., Figalli, A., Woerner, S.: The power of quantum neural networks. Nature computational science 1(6), 403–409 (2021) https://doi.org/10.1038/s43588-021-00084-1
Barenco, A., Bennett, C.H., Cleve, R., DiVincenzo, D.P., Margolus, N., Shor, P., Sleator, T., Smolin, J.A., Weinfurter, H.: Elementary gates for quantum computation. Physical review A 52(5), 3457 (1995) https://doi.org/10.1103/PhysRevA.52.3457
Berry, D.W., Childs, A.M., Cleve, R., Kothari, R., Somma, R.D.: Simulating hamiltonian dynamics with a truncated taylor series. Physical review letters 114(9), 090502 (2015) https://doi.org/10.1103/PhysRevLett.114.090502
Babbush, R., Gidney, C., Berry, D.W., Wiebe, N., McClean, J., Paler, A., Fowler, A., Neven, H.: Encoding electronic spectra in quantum circuits with linear t complexity. Physical Review X 8(4), 041015 (2018) https://doi.org/10.1103/PhysRevX.8.041015
Benedetti, M., Lloyd, E., Sack, S., Fiorentini, M.: Parameterized quantum circuits as machine learning models. Quantum science and technology 4(4), 043001 (2019) https://doi.org/10.1088/2058-9565/ab4eb5
Bond-Taylor, S., Leach, A., Long, Y., Willcocks, C.G.: Deep generative modelling: A comparative review of vaes, gans, normalizing flows, energy-based and autoregressive models. IEEE transactions on pattern analysis and machine intelligence 44(11), 7327–7347 (2021) https://doi.org/10.1109/TPAMI.2021.3116668
Chen, Y.-A., Childs, A.M., Hafezi, M., Jiang, Z., Kim, H., Xu, Y.: Efficient product formulas for commutators and applications to quantum simulation. Physical Review Research 4(1), 013191 (2022) https://doi.org/10.1103/PhysRevResearch.4.013191
Cong, I., Choi, S., Lukin, M.D.: Quantum convolutional neural networks. Nature Physics 15(12), 1273–1278 (2019) https://doi.org/10.1038/s41567-019-0648-8
Cleve, R., Ekert, A., Macchiavello, C., Mosca, M.: Quantum algorithms revisited. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences 454(1969), 339–354 (1998) https://doi.org/10.1098/rspa.1998.0164
Crum, N.A., Sunny, L., Ronagh, P., Laflamme, R., Balu, R., Siopsis, G.: Stochastic security as a performance metric for quantum-enhanced generative ai. Quantum Machine Intelligence 7(1), 25 (2025) https://doi.org/10.1007/s42484-025-00256-6
Childs, A.M., Su, Y., Tran, M.C., Wiebe, N., Zhu, S.: Theory of trotter error with commutator scaling. Physical Review X 11(1), 011020 (2021) https://doi.org/10.1103/PhysRevX.11.011020
Childs, A.M., Wiebe, N.: Product formulas for exponentials of commutators. Journal of Mathematical Physics 54(6) (2013) https://doi.org/10.1063/1.4811386
Dormand, J.R., Prince, P.J.: A family of embedded runge-kutta formulae. Journal of computational and applied mathematics 6(1), 19–26 (1980) https://doi.org/10.1016/0771-050X(80)90013-3
Feng, R., Yu, C., Deng, W., Hu, P., Wu, T.: On the guidance of flow matching. arXiv preprint arXiv:2502.02150 (2025) https://doi.org/10.48550/arXiv.2502.02150
Gidney, C., Ekerå, M.: How to factor 2048 bit rsa integers in 8 hours using 20 million noisy qubits. Quantum 5, 433 (2021) https://doi.org/10.22331/q-2021-04-15-433
Goodfellow, I.J., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., Bengio, Y.: Generative adversarial nets. Advances in neural information processing systems 27 (2014)
Gat, I., Remez, T., Shaul, N., Kreuk, F., Chen, R.T., Synnaeve, G., Adi, Y., Lipman, Y.: Discrete flow matching. Advances in Neural Information Processing Systems 37, 133345–133385 (2024) https://doi.org/10.48550/arXiv.2407.15595
Hann, C.T., Lee, G., Girvin, S., Jiang, L.: Resilience of quantum random access memory to generic noise. Prx Quantum 2(2), 020311 (2021) https://doi.org/10.1103/PRXQuantum.2.020311
Heya, K., Nakanishi, K.M., Mitarai, K., Yan, Z., Zuo, K., Suzuki, Y., Sugiyama, T., Tamate, S., Tabuchi, Y., Fujii, K., et al.: Subspace variational quantum simulator. Physical Review Research 5(2), 023078 (2023) https://doi.org/10.1103/PhysRevResearch.5.023078
Innan, N., Sawaika, A., Dhor, A., Dutta, S., Thota, S., Gokal, H., Patel, N., Khan,
M.A.-Z., Theodonis, I., Bennai, M.: Financial fraud detection using quantum graph neural networks. Quantum Machine Intelligence 6(1), 7 (2024) https://doi.org/10.1007/s42484-024-00143-6
Kingma, D.P., Ba, J.: Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980 (2014) https://doi.org/10.48550/arXiv.1412.6980
Knuth, D.E.: Big omicron and big omega and big theta. ACM Sigact News 8(2), 18–24 (1976) https://doi.org/10.1145/1008328.1008329
Kornell, A., Selinger, P.: Some improvements to product formula circuits for hamiltonian simulation. arXiv preprint arXiv:2310.12256 (2023) https://doi.org/10.48550/arXiv.2310.12256
Kingma, D.P., Welling, M.: Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114 (2013)
Li, Y., Benjamin, S.C.: Efficient variational quantum simulator incorporating active error minimization. Physical Review X 7(2), 021050 (2017) https://doi.org/10.1103/PhysRevX.7.021050
Lee, J., Berry, D.W., Gidney, C., Huggins, W.J., McClean, J.R., Wiebe, N., Babbush, R.: Even more efficient quantum computations of chemistry through tensor hypercontraction. PRX quantum 2(3), 030305 (2021) https://doi.org/10.1103/PRXQuantum.2.030305
Low, G.H., Chuang, I.L.: Hamiltonian simulation by qubitization. Quantum 3, 163 (2019) https://doi.org/10.22331/q-2019-07-12-163
Lipman, Y., Chen, R.T., Ben-Hamu, H., Nickel, M., Le, M.: Flow matching for generative modeling. arXiv preprint arXiv:2210.02747 (2022) https://doi.org/10.48550/arXiv.2210.02747
Liu, X., Gong, C., Liu, Q.: Flow straight and fast: Learning to generate and transfer data with rectified flow. arXiv preprint arXiv:2209.03003 (2022) https://doi.org/10.48550/arXiv.2209.03003
Lipman, Y., Havasi, M., Holderrieth, P., Shaul, N., Le, M., Karrer, B., Chen, R.T., Lopez-Paz, D., Ben-Hamu, H., Gat, I.: Flow matching guide and code. arXiv preprint arXiv:2412.06264 (2024) https://doi.org/10.48550/arXiv.2412.06264
Layden, D., Sweke, R., Havlíček, V., Chowdhury, A., Neklyudov, K.: Wavefunction flows: Efficient quantum simulation of continuous flow models. arXiv preprint arXiv:2510.08462 (2025) https://doi.org/10.48550/arXiv.2510.08462
Low, G.H., Su, Y., Tong, Y., Tran, M.C.: Complexity of implementing trotter steps. PRX Quantum 4(2), 020323 (2023) https://doi.org/10.1103/PRXQuantum.4.020323
Mahmud, J., Mashtura, R., Fattah, S.A., Saquib, M.: Quantum convolutional neural networks with interaction layers for classification of classical data. Quantum Machine Intelligence 6(1), 11 (2024) https://doi.org/10.1007/s42484-024-00145-4
Nielsen, M.A., Chuang, I.L.: Quantum Computation and Quantum Information. Cambridge university press, Cambridge, UK (2010)
Paquet, E., Soleymani, F.: Quantumleap: Hybrid quantum neural network for financial predictions. Expert Systems with Applications 195, 116583 (2022) https://doi.org/10.1016/j.eswa.2022.116583
Romero, J., Olson, J.P., Aspuru-Guzik, A.: Quantum autoencoders for efficient compression of quantum data. Quantum Science and Technology 2(4), 045001 (2017) https://doi.org/10.1088/2058-9565/aa8072
Ruiz-Perez, L., Garcia-Escartin, J.C.: Quantum arithmetic with the quantum fourier transform. Quantum Information Processing 16(6), 152 (2017) https://doi.org/10.1007/s11128-017-1603-1
Schuld, M., Bergholm, V., Gogolin, C., Izaac, J., Killoran, N.: Evaluating analytic gradients on quantum hardware. Physical Review A 99(3), 032331 (2019) https://doi.org/10.1103/PhysRevA.99.032331
Siemaszko, M., Buraczewski, A., Le Saux, B., Stobińska, M.: Rapid training of quantum recurrent neural networks. Quantum Machine Intelligence 5(2), 31 (2023) https://doi.org/10.1007/s42484-023-00117-0
Smaldone, A.M., Shee, Y., Kyro, G.W., Xu, C., Vu, N.P., Dutta, R., Farag, M.H., Galda, A., Kumar, S., Kyoseva, E., et al.: Quantum machine learning in drug discovery: Applications in academia and pharmaceutical industries. Chemical Reviews 125(12), 5436–5460 (2025) https://doi.org/10.48550/arXiv.2409.15645
Schuld, M., Sinayskiy, I., Petruccione, F.: The quest for a quantum neural network. Quantum Information Processing 13(11), 2567–2586 (2014) https://doi.org/10.1007/s11128-014-0809-8
Tian, J., Sun, X., Du, Y., Zhao, S., Liu, Q., Zhang, K., Yi, W., Huang, W., Wang, C., Wu, X., et al.: Recent advances for quantum neural networks in generative learning. IEEE Transactions on Pattern Analysis and Machine Intelligence 45(10), 12321–12340 (2023) https://doi.org/10.1109/TPAMI.2023.3272029
Van Den Oord, A., Kalchbrenner, N., Kavukcuoglu, K.: Pixel recurrent neural networks. In: International Conference on Machine Learning, pp. 1747–1756 (2016). https://doi.org/10.48550/arXiv.1601.06759. PMLR
Verdon, G., McCourt, T., Luzhnica, E., Singh, V., Leichenauer, S., Hidary, J.: Quantum graph neural networks. arXiv preprint arXiv:1909.12264 (2019) https://doi.
org/10.48550/arXiv.1909.12264
Watson, J.D., Watkins, J.: Exponentially reduced circuit depths using trotter error mitigation. PRX Quantum 6(3), 030325 (2025) https://doi.org/10.1103/kw39-yxq5
Yoshida, Y., Miyato, T.: Spectral norm regularization for improving the generalizability of deep learning. arXiv preprint arXiv:1705.10941 (2017) https://doi.org/10.48550/arXiv.1705.10941
Zindorf, B., Bose, S.: Efficient implementation of multicontrolled quantum gates. Physical Review Applied 24(4), 044030 (2025) https://doi.org/10.1103/8blx-nfcr
Zhao, R., Wang, S.: A review of quantum neural networks: methods, models, dilemma. arXiv preprint arXiv:2109.01840 (2021) https://doi.org/10.48550/arXiv.2109.01840