A Differentially Private Quantum Neural Network for Probabilistic Optimal Power Flow
Abstract
The stochastic nature of renewable energy and load demand requires efficient and accurate solutions for probabilistic optimal power flow (OPF). Quantum neural networks (QNNs), which combine quantum computing and machine learning, offer computational advantages in approximating OPF by effectively handling high-dimensional data. However, adversaries with access to non-private OPF solutions can potentially infer sensitive load demand patterns, raising significant privacy concerns. To address this issue, we propose a privacy-preserving QNN model for probabilistic OPF approximation. By incorporating Gaussian noise into the training process, the learning algorithm achieves ()-differential privacy with theoretical guarantees. Moreover, we develop a strongly entangled quantum state to enhance the nonlinearity expressiveness of the QNN. Experimental results demonstrate that the proposed method successfully prevents privacy leakage without compromising the statistical properties of probabilistic OPF. Moreover, compared to classical private neural networks, the QNN reduces the number of parameters by 90% while achieving significantly higher accuracy and greater stability.
-
Keywords: Probabilistic Optimal Power Flow; Quantum Neural Network; Variational Quantum Circuit; Differential Privacy.
1 Introduction
The integration of renewable energy sources into power systems introduces significant variability and uncertainty in power generation and demand. Probabilistic optimal power flow (OPF) is essential for managing these uncertainties by determining optimal operating points that account for the stochastic nature of renewables and loads [1]. However, solving probabilistic OPF problems is computationally intensive, calling for methods to provide fast and accurate solutions for real-time applications.
Learning-based methods have emerged as effective tools for accurately approximating OPF solutions due to their ability to capture complex nonlinear relationships from the data [2]. As power system complexities continue to grow, there is a pressing need for more advanced computational approaches. Building on the exponential speedup provided by quantum computing, the rapid advancements in quantum machine learning (QML) offer promising prospects for developing scalable and efficient power system computations [3, 4]. Indeed, quantum computing uses superposition and entanglement to achieve efficient data representation and parallel computation. Hence, it holds great potential to facilitate large-scale computation in next-generation power systems. Moreover, the inherent speed advantages of quantum computing allow QML methods to perform computations more quickly, thereby supporting real-time optimization and decision-making.
Despite their computational efficiency, learning directly from the non-private OPF solutions can lead to privacy breaches, as the non-private voltage and power flow information may reveal sensitive load patterns [5]. By introducing calibrated noise into the learning process, differential privacy has recently become a promising tool for privacy protection [6]. Mathematically, differential privacy provides a theoretical framework to quantify and control privacy losses, based on which one can design an expected trade-off between model utility and privacy preservation.
Differentially private OPF problems have been extensively investigated. To the best of our knowledge, most existing works are based on optimization methods [7, 8], while learning-based methods are seldom explored. These two approaches differ greatly in the noise injection mechanisms. In learning-based methods, noise is incorporated in gradient sampling, rather than in the coordination variables exchanged during distributed optimization. Therefore, there is a research gap in investigating noise effects on the learning accuracy. Furthermore, unlike classical neural networks, quantum circuits process data and learn nonlinear mappings in a fundamentally different way. The effects of noises on quantum circuits require further examination. While simple classification tasks have been studied in [9], complex nonlinear problems such as OPF remain unexplored.
In this paper, we address the research gaps above by proposing a privacy-preserving quantum neural network (QNN) for the probabilistic OPF problem. It leverages the power of quantum computing to accelerate the OPF calculation process. To prevent privacy leakage from the OPF solutions, we develop a ()-differentially private algorithm for QNN learning with proofs of privacy guarantees. Our main contributions are as follows:
-
•
A QNN-based method for probabilistic OPF problem: We propose a QNN-based method for fast probabilistic OPF calculation. To enhance the expressive power, we introduce a strongly entangled variational layer within the variational quantum circuit. Compared to classical NNs, the QNN demonstrates superior approximation accuracy while reducing the number of parameters by 90%.
-
•
A differentially private QNN learning algorithm: To train the proposed QNN for solving OPF while preserving privacy, we develop a ()-differentially private algorithm with theoretical guarantees. By injecting controlled Gaussian noise into the quantum gradient update process, the proposed algorithm prevents adversaries from inferring the power usage patterns of customers. Moreover, the proposed QNN is noise-resilient, i.e., when adding noise at a large scale, the model updates steadily without issues such as gradient exploding in classical NNs.
Paper Organization: Section 2 introduces the preliminaries of the probabilistic OPF problem and quantum computing. Section 3 presents the proposed QNN following the discussion of the probabilistic OPF problem. To prevent sensitive information from being revealed by the QNN, Section 4 proposes the private learning algorithm with an -differential privacy guarantee. Case studies are conducted in Section 5, and the conclusion is provided in Section 6.
2 Preliminaries
2.1 Probabilistic Optimal Power Flow
We consider a radial distribution grid with controllable distributed energy resources (DERs). A distribution system operator (DSO) is responsible for managing the DERs and controlling the power supply from the main grid, ensuring that grid security constraints are satisfied. The grid is represented as a graph , where is the set of buses and is the set of lines. Each bus in is indexed by and each line in is denoted as . Suppose each controllable DER sited at bus is with cost coefficient , then the deterministic OPF problem is formulated as:
(1) | ||||
s.t. | (2) | |||
(3) | ||||
(4) | ||||
(5) | ||||
(6) | ||||
(7) | ||||
(8) |
where the objective is to minimize the total operation cost subject to branch flow equations (2)-(5) adopted in [10]. denotes the generation power of controllable DER sited in bus . The power / represents the active/reactive power at bus , / is the active/reactive power flow on line , / denotes the resistance/reactance of line , is the squared current magnitude of line , is the squared voltage magnitude at bus , and and represent the lower and upper bounds of the respective variables.
Suppose there are wind and solar generation in the distribution grid. To account for the uncertainties inherent in wind and solar generation, as well as load demand variability in the distribution grid, we extend the deterministic OPF into a probabilistic OPF formulation as follows:
(9) | ||||
s.t. | (10) | |||
(11) |
where represents the set of random variables capturing system uncertainties (i.e., solar generation, wind generation, and load demand), while denotes the same set of decision variables as in the deterministic OPF. The objective function represents the expected minimum operational cost, where the operational cost is minimized for each uncertain scenario, and the expectation is taken over the distribution of these optimal operational costs. Constraint (10) represents the branch flow equations, and constraint (11) enforces the security limits on .
A classical method to solve the above probabilistic OPF problem is by the Monte Carlo simulation [11]. It draws samples of uncertain variables from the distributions, solves the deterministic OPF, and then aggregates the results. Despite the accuracy, Monte Carlo methods are computationally intensive. To accelerate the calculation of each sample, we leverage the computational power from quantum computing.
2.2 Basic Concepts of Quantum Computing
Quantum computing processes the information with qubit, i.e., the quantum bit. Unlike classical bits, which can only exist in a distinct state of either 0 or 1, qubits can exist in both states simultaneously due to the property of quantum superposition. Mathematically, the state of a single qubit can be represented as:
(12) |
where and are the basis states in Hilbert space and , are complex amplitudes satisfying the normalization condition .

When solving practical problems, we use multiple qubits together by creating correlations between them. Such correlations are called entanglement. When qubits are entangled with each other, operations on any one of the qubits perform corresponding parallel operations on the other qubits. Therefore, this entanglement contributes to the potential exponential speedup that quantum computers may possess over classical computers for certain algorithms.
The quantum operations are performed by quantum gates. Quantum gates are unitary matrices in Hilbert space. For example, an elementary quantum gate, Pauli-X gate is denoted by , which flips the state of a qubit. When applying quantum gates on the qubits, the quantum states unitarily change from initial state to a new state , which is the unitary evolution of qubits. By designing appropriate quantum gates, qubits evolve toward the expected state, which can then be measured to collect the final result.
3 Quantum Neural Network-Based OPF Approximation
To accelerate OPF problem-solving, we propose a quantum neural network-based method for OPF approximation.
Variational quantum circuit (VQC) is the “neural network” in quantum ML. It is a parameterized quantum circuit where multiple qubits evolve to perform a task. Unlike standard quantum circuits, VQCs include quantum gates with learnable parameters, which can be optimized iteratively based on a predefined loss function.
Consider the uncertainties in the distribution grid, such as wind generation , solar generation , and customer load demand at various nodes. Given the input , the VQC aims to approximate the OPF solution . To learn the mapping , classical NNs use a feed-forward approach: for each sample , the NN predicts , calculates the loss between and the true output , and updates the parameters using the gradients from . Similarly, the VQC follows the same paradigm but requires additional conversions between quantum and classical information.
We illustrate the proposed QNN-based OPF learning method in Figure 1. The first step is to encode the classical input into the quantum system, i.e., the state preparation. Here, we use the angle encoding to encode the input values into the relative phase in the quantum states:
(13) |
After encoding, repeated variational layers (also called ansatz) evolve the prepared quantum system into the target system . This process is analogous to the hidden layers in classical NNs, where the uncertain variables in are mapped to the OPF solution . The quantum gates include parameterized rotation gates and controlled-NOT (CNOT) gates: the learnable parameters control the evolution and are optimized during the learning process; the controlled gates entangle qubits, enabling nonlinear transformations and thus increasing the expressive power. Moreover, the number of layers can also be tuned: the more layers, the larger the expressive power. To further improve this capability, we incorporate a strongly entangled layer [12]. This layer consists of qubit rotations followed by adjacent pairwise CNOT gates, thereby generating states that strongly entangle each qubit and provide significant non-linear expressiveness.
To obtain the predicted OPF solution from the final quantum system , we need to convert the quantum information into the classical information. This is achieved by the measurement operation. Before the measurement, the quantum system is in the superposition of multiple states, with each state representing one possible output of OPF solution . For example, a quantum state with qubits and represents components of a OPF solution with possible combinations. However, during the general measurement process, each qubit can only collapse onto 0 or 1, which cannot represent the continuous value of an OPF solution, e.g., the power flow or the voltage magnitude. Therefore, here we calculate the expectation of eigenvalues in each qubit, i.e., the expectation value of each component in OPF solution . Mathematically, this process can be expressed by
(14) |
where is the observable operator (i.e., a Hermitian matrix with real eigenvalues).
After measurement, we obtain the predicted OPF solution . By evaluating the loss between the predicted value and true value , we calculate the gradient of learnable parameters . Then, we update the parameters with a classical optimizer iteratively to approximate the true OPF solution .
4 Differentially Private Learning for Optimal Power Flow
In the previous section, the VQC learns from the OPF solution from (1) and produces a solution that is as accurate as possible. However, if is exposed, an attacker could potentially decode power consumption patterns of consumers using methods like non-intrusive load monitoring (NILM) [5]. To be specific, voltage and power flow measurements in , can potentially reveal residential customer activities (such as electric vehicle charging) and industrial customer production schedules, creating significant privacy risks.
To address this privacy concern, in this section, we develop a privacy-preserving learning algorithm for VQC. The algorithm is proved to be ()-differential privacy for given load datasets.
4.1 Differential Privacy
To quantify and control the privacy risks of the customer loads, we adopt the framework of differential privacy [13]. It protects privacy by ensuring the outputs from two similar inputs are in-distinguishable. Before introducing the mechanism of differential privacy, we briefly introduce the meaning of “similarity”.
Suppose a load dataset is represented by with -th element describing the active load of node . For two load datasets and that differ only in one element, they hold the following adjacency relation :
(15) |
where is the scalar measuring the distance between two adjacent datasets.
For a non-private OPF algorithm, the corresponding outputs given two adjacent load datasets, and , are distinguishable, leaving exploitable information for an adversary to reverse-engineer the original load dataset. Differential privacy defines the degree of privacy leakage in a probabilistic sense.
Definition 1 (-differential privacy [13]).
A randomized OPF algorithm from the domain to domain is -differentially private if, for all and for any adjacent pair , the following condition holds:
(16) |
Here, the domain in OPF problem (1) includes feasible load datasets, solar and wind generation, and the domain denotes the feasible region. The level of privacy protection is defined by parameters (). controls the maximum distance between the outputs of two adjacent datasets, and denotes the probability of privacy leakage in the worst case. Therefore, the smaller () provides stronger privacy protection.
4.2 Differentially Private Learning for Variational Quantum Circuit
To integrate differential privacy into the learning process of VQC, we add Gaussian noise into gradients of parameterized quantum gates and clip the gradient of each sample by a pre-defined norm .
Algorithm 1 outlines the differentially private VQC learning process. For each OPF sample, it encodes the input data into a quantum state, evolves it through the VQC, and measures the final quantum system to obtain the predicted OPF solution. After that, a gradient is calculated based on the prediction loss and then is clipped based on a norm . By clipping, the influence of each individual sample on the gradient is bounded to protect privacy. Then, the Gaussian noises controlled by scale are added to the clipped gradients before updating the VQC parameters . This process is repeated for multiple epochs, leading to a privacy-preserving VQC that can approximate OPF solutions while protecting individual load data.
4.3 Proof of Privacy Guarantees
The privacy guarantee of Algorithm 1 is described as the following theorem.
Theorem 1 (Privacy Guarantees).
For any adjacent pairs of load demand datasets , if , , and , then, Algorithm 1 is -differentially private, where
(17) |
Proof: In each step of Algorithm 1, the noise following are added on the average gradient of each batch. For each batch, we compute the per-sample gradients and clip them to differ at most , which bounds the sensitivity of gradient within . By Gaussian Mechanism [13], if we choose , the algorithm is ()-differentially private. Since in each step, we sample one batch of size from data samples with the sampling rate . From the theorem of privacy amplification by uniform subsampling [14], the resulting algorithm achieves ()-differentially privacy. Since there are epochs, we apply the privacy-preserving algorithm for times. From the advanced composition theorem [13], i.e., if the algorithm is composed of algorithms with each providing (-differential privacy, the composed algorithm is -differential private for any with .
Hence, the Algorithm 1, which composes steps with each providing ()-differentially privacy, achieves -differentially privacy. This completes the proof.
5 Case Study
Numerical experiments are conducted on the modified IEEE 33-bus power distribution system. As illustrated in Figure 2, the system integrates 2 distributed generators (DGs), 2 Photovoltaic (PVs), and 2 wind turbines (WTs). The active and reactive power limits are set as follows: MW, MW, MVar, and MVar. The relaxed AC-OPF problem (1) is coded in MATLAB using the YALMIP interface and solved with GUROBI software. The QNN is implemented using the Pennylane library and JAX library. All experiments are conducted on a MacBook with the M3 Max Apple Silicon chip. The test hyperparameters are presented in Table 1.


The input features of the QNN include uncertain variables of 2 WTs, 2 PVs, and load demand from 1 customer. The output is the voltage magnitude at node due to the qubit limitation in the Noisy Intermediate-Scale Quantum (NISQ) era [15].
Hyperparameters | Value | Hyperparameters | Value |
---|---|---|---|
learning rate () | 0.05 | clipping norm () | 1 |
batch size | 32 | number of variational layers | 10 |
qubits | 5 | optimizer | Adam |
5.1 Privacy Guarantees
We first provide an illustrative example to demonstrate how an adversary detects the load pattern if the voltage measurements are exposed. Assume a customer at node 30 has an atypical load pattern representing the production technology. Its pattern under different timestep is formulated with the following three periodic components [7]:
The non-private OPF solution leaks the sensitive load information through the voltage readings, as displayed in Figure 3. The left figure presents the load pattern of the customer and the remaining figures show the voltage magnitudes at the same node. From left to right, in the second figure, we can see that the non-private OPF and non-private QNN demonstrate an informative “reverse” pattern of the load demand, disclosing the power consumption pattern of the customer. When the Gaussian noises are added to the training process, i.e., , the solution from private QNN deviates from the non-private one and fluctuates more mildly to protect the load pattern. When noise with a larger scale is introduced, the fluctuation is smaller, leading to stronger privacy protection.
5.2 Probabilistic OPF Solutions
To assess the accuracy of the probabilistic OPF solution generated by the private QNN, we computed the mean and standard deviation based on 1,000 samples. These samples were obtained by sampling the WT generation from a Weibull distribution , PV generation from a Beta distribution , and load demand from a normal distribution . These samples were then solved deterministically to collect the aggregate statistics.
Table 2 presents a comparison of the voltage magnitude at Node 30 across various perturbation levels (, , , and ). The reference values, i.e., the mean value of 12.6592 kV and standard deviation value of 0.0009 kV, were obtained via the Monte Carlo method. In the absence of noise (), the calculated statistics closely align with the reference values. As the noise scale increases, representing a greater level of privacy protection, the statistical results deviate more significantly from the reference mean. Specifically, the error percentage for the mean voltage remains within 0.0019%, indicating that the introduction of noise by the private QNN causes only minimal alterations to the voltage magnitudes, thereby allowing for accurate estimation of aggregate statistics. However, the standard deviation exhibits larger deviations as the noise restricts the model’s sensitivity to minor variations. Nonetheless, by selecting an appropriate noise scale, e.g. from to , a balanced trade-off can be achieved between the accuracy in estimating the uncertainties and the privacy protection of the sensitive load patterns.
Voltage Magnitude (kV) Results at Node 30 () | |||||
---|---|---|---|---|---|
Quantities | Reference | ||||
Mean | 12.6592 | 12.6592 | 12.6592 | 12.6592 | 12.6594 |
\ | 0.0002 | 0.0008 | 0.0019 | ||
STD | 0.0009 | 0.0009 | 0.0007 | 0.0006 | 0.0005 |
\ | 1.3087 | 18.8674 | 36.6288 | 37.9414 |
5.3 Comparison with Classical ML
To demonstrate the advantage of quantum ML over classical ML, we implement a multilayer perceptron (MLP) and compare the accuracy between the proposed QNN and a classical MLP network. The MLP is developed using the PyTorch library and consists of two hidden layers, each containing 32 units. Both models are trained for 1,000 epochs. When noise is introduced, both models utilize Algorithm 1 to preserve the privacy of load demands. The evaluation metric is the coefficient of determination, i.e., , which quantifies the degree to which a model’s predictions align with observed data, with values closer to 1 indicating a better fit.
Due to the limited availability of real quantum hardware, we adopt the formula proposed by Guerreschi et al. [16] to calculate the quantum computational time, including the execution time and the measurement time:
where denotes the time for state preparation, represents the average duration of a single quantum gate, is the maximal circuit depth (number of sequential quantum gates), and is the measurement time. The time scales are set as and , following the parameters in literature [17].
Voltage Magnitude (kV) Results at Node 30 () | ||||||
Model | Calculation Time | #Parameters | ||||
MLP | 1281 | 0.971 | -0.065 | -0.095 | -22291.787 | |
QNN | 165 | 0.977 | 0.739 | 0.291 | 0.113 |
Table 3 presents a comparison of the accuracy in predicting the voltage magnitude at Node 30 across 1,000 samples. Under various noise scales, the QNN consistently outperforms the MLP. In the absence of noise, the obtained scores are comparable, with the QNN achieving 0.977 and the MLP achieving 0.971. However, when Gaussian noise is incorporated into the training process, the QNN demonstrates a clear advantage over the MLP. Specifically, at noise levels of and , the MLP yields negative scores, whereas the QNN maintains positive values, indicating the MLP’s inability to effectively forecast the voltage magnitude under noisy conditions. This degradation is attributed to the accumulated noises, which hinder the MLP’s forecasting capability. Notably, at a noise scale of , the MLP exhibits a large negative value of -22,291.787, while the QNN still maintains a positive of 0.113. Furthermore, the QNN has shorter computation times and utilizes significantly fewer parameters, i.e., 165 versus 1,281, as shown in the second and third columns of Table 3, further highlighting the advantages of quantum ML over classical approaches.

To investigate the underlying reasons for the distinct performance between the QNN and MLP, we analyze the loss values during the training process. Figure 4 illustrates the case when . The graph reveals that the training loss of the MLP is highly unstable; although most loss values are around zero, some instances exhibit very large loss values. A potential reason is that the accumulated noises on gradients dominate the learning process and thus destroy the subsequent learning performance. In contrast, the QNN maintains stable training and is resilient to noise, highlighting the advantage of the QNN when incorporating differential privacy into the training process.
6 Conclusion
Volatile and stochastic renewables and loads call for efficient and accurate calculation of probabilistic optimal power flow (OPF). Quantum computing presents promising speedup for approximating OPF efficiently by leveraging the quantum superposition and entanglement. However, the exposure of non-private OPF can potentially reveal the sensitive load demand pattern, raising privacy concerns. To this end, we propose a differentially private quantum neural network (QNN)-based method for the probabilistic OPF problem. By introducing carefully calibrated Gaussian noises into the training process, it is proven to achieve ()-differential privacy, leading to strong privacy protection. Moreover, a strongly entangled layer is employed to further improve the expressive power of variational quantum circuits. The case study validates that the proposed method preserves private load information while still maintaining an accurate estimation of the statistics in probabilistic OPF. Moreover, compared to the private classical neural network, the proposed private QNN achieves significantly higher accuracy and is more noise-resilient.
7 Acknowledgments
This work is supported by the CUHK Strategic Partnership Award for Research Collaboration under Grant No. 4750467, the CUHK Direct Grant for Research under Grant No. 4055228, and the CUHK startup fund.
References
- [1] X. Li, Y. Li, and S. Zhang, “Analysis of probabilistic optimal power flow taking account of the variation of load power,” IEEE Transactions on Power Systems, vol. 23, no. 3, pp. 992–999, 2008.
- [2] W. Huang, X. Pan, M. Chen, and S. H. Low, “Deepopf-v: Solving ac-opf problems efficiently,” IEEE Transactions on Power Systems, vol. 37, no. 1, pp. 800–803, 2021.
- [3] A. Ajagekar, T. Humble, and F. You, “Quantum computing based hybrid solution strategies for large-scale discrete-continuous optimization problems,” Computers & Chemical Engineering, vol. 132, p. 106630, 2020.
- [4] J. Liu, M. Liu, J.-P. Liu, Z. Ye, Y. Wang, Y. Alexeev, J. Eisert, and L. Jiang, “Towards provably efficient quantum algorithms for large-scale machine-learning models,” Nature Communications, vol. 15, no. 1, p. 434, 2024.
- [5] H. Wang, J. Zhang, C. Lu, and C. Wu, “Privacy preserving in non-intrusive load monitoring: A differential privacy perspective,” IEEE Transactions on Smart Grid, vol. 12, no. 3, pp. 2529–2543, 2020.
- [6] C. Dwork, “Differential privacy,” in International colloquium on automata, languages, and programming. Springer, 2006, pp. 1–12.
- [7] V. Dvorkin, F. Fioretto, P. Van Hentenryck, P. Pinson, and J. Kazempour, “Differentially private optimal power flow for distribution grids,” IEEE Transactions on Power Systems, vol. 36, no. 3, pp. 2186–2196, 2020.
- [8] C. Lei, S. Bu, Q. Chen, Q. Wang, Q. Wang, and D. Srinivasan, “Decentralized optimal power flow for multi-agent active distribution networks: A differentially private consensus admm algorithm,” IEEE Transactions on Smart Grid, 2024.
- [9] W. M. Watkins, S. Y.-C. Chen, and S. Yoo, “Quantum machine learning with differential privacy,” Scientific Reports, vol. 13, no. 1, p. 2453, 2023.
- [10] M. Farivar and S. H. Low, “Branch flow model: Relaxations and convexification—part i,” IEEE Transactions on Power Systems, vol. 28, no. 3, pp. 2554–2564, 2013.
- [11] C. Z. Mooney, Monte carlo simulation. Sage, 1997, no. 116.
- [12] M. Schuld, A. Bocharov, K. M. Svore, and N. Wiebe, “Circuit-centric quantum classifiers,” Physical Review A, vol. 101, no. 3, p. 032308, 2020.
- [13] C. Dwork, A. Roth et al., “The algorithmic foundations of differential privacy,” Foundations and Trends® in Theoretical Computer Science, vol. 9, no. 3–4, pp. 211–407, 2014.
- [14] B. Balle, G. Barthe, and M. Gaboardi, “Privacy amplification by subsampling: Tight analyses via couplings and divergences,” Advances in neural information processing systems, vol. 31, 2018.
- [15] J. Preskill, “Quantum computing in the nisq era and beyond,” Quantum, vol. 2, p. 79, 2018.
- [16] G. G. Guerreschi and A. Y. Matsuura, “Qaoa for max-cut requires hundreds of qubits for quantum speed-up,” Scientific reports, vol. 9, no. 1, p. 6903, 2019.
- [17] X. Zhou, H. Zhao, Y. Cao, X. Fei, G. Liang, and J. Zhao, “Carbon market risk estimation using quantum conditional generative adversarial network and amplitude estimation,” Energy Conversion and Economics, 2024.