Abstract
The so-called Hamming distance measures the difference between two binary strings A and B. In simplified form, it measures the number of changes in A to get B. This type of distance is very useful in classical computing in applications such as error correction. It is also advantageous in quantum computing, being for example widely used in quantum machine learning. Since current quantum computers have limited resources, this type of distance is particularly attractive because it can be computed using fewer qubits and operations than other distances such as Euclidean or Manhattan distances. In this paper, two circuits for calculating Hamming distances using exclusively Clifford+T gates are presented. The aim of both circuits is to reduce the quantum cost and number of T gates needed to compute the Hamming distance. The T gate is more expensive than the other gates, so this reduction will have a significant impact on the total cost of the circuits. Furthermore, the proposed circuits are implemented using only Clifford+T gates. The circuits implemented exclusively with this group of gates are compatible with proven error detection and correction codes.




Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.Data availability
Not applicable.
References
Ladd TD, Jelezko F, Laflamme R, Nakamura Y, Monroe C, O’Brien JL (2010) Quantum computers. Nature 464(7285):45–53
Shor PW (1999) Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM Rev 41(2):303–332
Grover LK (1996) A fast quantum mechanical algorithm for database search. In: Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing, pp 212–219
Farhi E, Goldstone J, Gutmann S, Sipser M (2000) Quantum computation by adiabatic evolution. arXiv preprint quant-ph/0001106
Raussendorf R, Briegel HJ (2001) A one-way quantum computer. Phys Rev Lett 86(22):5188
Nielsen MA, Chuang IL (2010) Quantum computation and quantum information. Cambridge University Press, Cambridge, UK
Preskill J (2018) Quantum computing in the NISQ era and beyond. Quantum 2:79
Torlai G, Melko RG (2020) Machine-learning quantum states in the NISQ era. Ann Rev Condens Matter Phys 11:325–344
Roffe J (2019) Quantum error correction: an introductory guide. Contemp Phys 60(3):226–245
Gottesman D (1998) Theory of fault-tolerant quantum computation. Phys Rev A 57(1):127
Pérez-Salinas A, Cervera-Lierta A, Gil-Fuster E, Latorre JI (2020) Data re-uploading for a universal quantum classifier. Quantum 4:226
Orts F, Ortega G, Filatovas E, Garzón EM (2022) Implementation of three efficient 4-digit fault-tolerant quantum carry lookahead adders. J Supercomput 78(11):13323–41
Orts F, Ortega G, Cucura A, Filatovas E, Garzón EM (2021) Optimal fault-tolerant quantum comparators for image binarization. J Supercomput 77(8):8433–8444
Wiebe N, Kapoor A, Svore KM (2015) Quantum nearest-neighbor algorithms for machine learning. Quantum Inf Comput 15(3–4):318–358
Hamming RW (1986) Coding and information theory. Prentice-Hall Inc, New Jersey, US
Norouzi M, Fleet DJ, Salakhutdinov RR (2012) Hamming distance metric learning. Adv Neural Inform Process Syst, 25
Zhang L, Zhang Y, Tang J, Lu K, Tian Q (2013) Binary code ranking with weighted Hamming distance. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp 1586–1593
Taheri R, Ghahramani M, Javidan R, Shojafar M, Pooranian Z, Conti M (2020) Similarity-based android malware detection using Hamming distance of static binary features. Futur Gener Comput Syst 105:230–247
Raveendran N, Rengaswamy N, Rozpedek F, Raina A, Jiang L, Vasić B (2022) Finite rate QLDPC-GKP coding scheme that surpasses the CSS Hamming bound. Quantum 6:767
Kathuria K, Ratan A, McConnell M, Bekiranov S (2020) Implementation of a Hamming distance-like genomic quantum classifier using inner products on ibmqx2 and ibmq_16_melbourne. Quantum Mach Intell 2(1):7
Li J, Lin S, Yu K, Guo G (2022) Quantum K-nearest neighbor classification algorithm based on Hamming distance. Quantum Inf Process 21(1):18
Chomboon K, Chujai P, Teerarassamee P, Kerdprasop K, Kerdprasop N (2015) An empirical study of distance metrics for K-nearest neighbor algorithm. In: Proceedings of the 3rd International Conference on Industrial Application Engineering, Vol 2
Barenco A, Bennett CH, Cleve R, DiVincenzo DP, Margolus N, Shor P, Sleator T, Smolin JA, Weinfurter H (1995) Elementary gates for quantum computation. Phys Rev A 52(5):3457
Bernhardt C (2019) Quantum computing for everyone. Mit Press, Massachusetts, USA
Miller DM, Soeken M, Drechsler R (2014) Mapping NCV circuits to optimized Clifford+T circuits. In: International Conference on Reversible Computation, pp 163–175. Springer
Amy M, Maslov D, Mosca M, Roetteler M (2013) A meet-in-the-middle algorithm for fast synthesis of depth-optimal quantum circuits. IEEE Trans Comput Aided Des Integr Circuits Syst 32(6):818–830
Amy M, Maslov D, Mosca M (2014) Polynomial-time T-depth optimization of Clifford+ T circuits via matroid partitioning. IEEE Trans Comput Aided Des Integr Circuits Syst 33(10):1476–1489
Litinski D (2019) Magic state distillation: not as costly as you think. Quantum 3:205
Mohammadi M, Eshghi M (2009) On figures of merit in reversible and quantum logic designs. Quantum Inf Process 8:297–318
Thapliyal H, Muñoz-Coreas E (2019) Design of quantum computing circuits. IT Professional 21(6):22–26
Thapliyal H, Muñoz-Coreas E, Khalus V (2021) Quantum circuit designs of carry lookahead adder optimized for T-count, T-depth and qubits. Sustain Comput Inform Syst 29:100457
Patterson DA, Hennessy JL (2016) Computer organization and design arm edition: the hardware software interface. Morgan kaufmann, Massachusetts, USA
Maslov D, Dueck GW (2003) Improved quantum cost for N-bit Toffoli gates. Electron Lett 39(25):1790–1791
Muñoz-Coreas E, Thapliyal H (2018) Quantum circuit design of a T-count optimized integer multiplier. IEEE Trans Comput 68(5):729–739
Gosset D, Kliuchnikov V, Mosca M, Russo V (2013) An algorithm for the T-count. arXiv preprint arXiv:1308.4134
Li H-S, Fan P, Xia H, Long G-L (2022) The circuit design and optimization of quantum multiplier and divider. Sci China Phys Mech Astron 65(6):260311
Satoh T, Oomura S, Sugawara M, Yamamoto N (2022) Pulse-engineered controlled-v gate and its applications on superconducting quantum device. IEEE Trans Quantum Eng 3:1–10
Hung WN, Song X, Yang G, Yang J, Perkowski M (2006) Optimal synthesis of multiple output boolean functions using a set of quantum gates by symbolic reachability analysis. IEEE Trans Comput Aided Des Integr Circuits Syst 25(9):1652–1663
Gidney C (2018) Halving the cost of quantum addition. Quantum 2:74
Orts F, Ortega G, Garzón EM (2022) Studying the cost of N-qubit Toffoli gates. In: International Conference on Computational Science, pp 122–128. Springer
Thapliyal H (2016) Mapping of subtractor and adder-subtractor circuits on reversible quantum gates. In: Transactions on Computational Science XXVII, pp 10–34. Springer, New York, USA
Qiskit contributors (2023) Qiskit: An open-source framework for quantum computing. 10.5281/zenodo.2573505
Carrascal G, Del Barrio AA, Botella G (2021) First experiences of teaching quantum computing. J Supercomput 77:2770–2799
Funding
This work has been supported by the projects: S-MIP-21-53 (funded by the Research Council of Lithuania), PID2021-123278OB-I00 and PID2021-127836NB-I00 (funded by MCIN/AEI/10.13039/501100011033/ FEDER “A way to make Europe”); PID2020-119082RB-C22 (funded by MCIN/AEI/10.13039/501100011033); AYUD/2021/50994 and FC-GRUPIN-IDI/2018/000193 (funded by Gobierno del Principado de Asturias); Quantum Spain project funded by the Ministry of Economic Affairs and Digital Transformation of the Spanish Government and the European Union through the Recovery, Transformation and Resilience Plan - NextGenerationEU; and PID2021-123461NB-C22 (funded by MICIIN).
Author information
Authors and Affiliations
Contributions
FO involved in writing—original draft, provided software, and involved in execution of experiments; GO involved in writing—review and editing, done validation, and involved in visualization; EFC involved in orchestration, provided idea source, and involved in writing—original draft; IFR provided idea source, involved in formal analysis, and involved in writing—original draft; EMG involved in writing—review and editing, done validation, and involved in visualization.
Corresponding author
Ethics declarations
Conflict of interest
The authors declare that they have no competing interests.
Ethical approval
This article does not contain any studies with human participants or animals performed by any of the authors.
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Orts, F., Ortega, G., Combarro, E.F. et al. Quantum circuits for computing Hamming distance requiring fewer T gates. J Supercomput 80, 12527–12542 (2024). https://doi.org/10.1007/s11227-024-05916-1
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11227-024-05916-1