  Quantum algorithms for solving a wide range of practical problems have been
proposed in the last ten years, such as data search and analysis, product
recommendation, and credit scoring. The concern about privacy and other ethical
issues in quantum computing naturally rises up. In this paper, we define a
formal framework for detecting violations of differential privacy for quantum
algorithms. A detection algorithm is developed to verify whether a (noisy)
quantum algorithm is differentially private and automatically generate bugging
information when the violation of differential privacy is reported. The
information consists of a pair of quantum states that violate the privacy, to
illustrate the cause of the violation. Our algorithm is equipped with Tensor
Networks, a highly efficient data structure, and executed both on TensorFlow
Quantum and TorchQuantum which are the quantum extensions of famous machine
learning platforms -- TensorFlow and PyTorch, respectively. The effectiveness
and efficiency of our algorithm are confirmed by the experimental results of
almost all types of quantum algorithms already implemented on realistic quantum
computers, including quantum supremacy algorithms (beyond the capability of
classical algorithms), quantum machine learning models, quantum approximate
optimization algorithms, and variational quantum eigensolvers with up to 21
quantum bits.
