Princeton University researchers developed debugging tools based on statistical tests for helping programmers in building correct quantum programs for near-term quantum computers. Both classical computing and quantum computing involve debugging programs as the most tedious task in software development.

The computing world has current limitations which could be answered by quantum computing. Quantum algorithms offer to provide more capabilities. These are sets of instructions that command a quantum computer on the processes needed to obtain some results. There are various applications with these algorithms. Scientists have the potential to calculate properties of chemical compounds directly from quantum mechanics' governing equations via quantum chemistry algorithms. Hastening the speed of searching inside databases and securing resistant communications to eavesdropping are some of the goals of other algorithms.

The existence of quantum algorithms for twenty years was only possible as abstract equations and specifications. These were never run on real quantum computers. Previous studies in the past few years have realized the first prototype quantum computer that could run quantum programs. Small-scale quantum computers were made available to the public to run code and see results by IBM. The boom in the field of quantum computing experimentation has created an urgent challenge in assisting programmers in translating those abstract algorithms into correctly functioning quantum program code.

"We were finding that even researchers who specialize in quantum computing are making subtle mistakes in the quantum program code, preventing the programs from giving correct results," Yipeng Huang, a postdoc at Princeton University and an author of the paper, said. "If it is so tricky for experienced quantum programmers, how can students new to quantum computing write correct programs, without the aid of tools such as debuggers?"

The lead authors Huang and Margaret Martonosi, a Princeton University professor of Computer Science, identified three key challenges in debugging quantum programs and assessing solutions in addressing those challenges.

Programmers find it difficult to easily examine the values of variables of a quantum program. This further complicates the debugging process as there is a need to inspect the values of variables step-by-step. Unlike classical programming, debugging quantum programming requires reading quantum variables that would measure and collapse the delicate quantum states inside quantum computers. The problem is that a collapsed quantum state would not permit any observations to have a complete description of the state of the program.

Their study used only the information about the collapsed quantum States to address this challenge. There are two different kinds of settings in debugging programs. The first is setting the quantum programs run in simulation on a classical computer. The second is setting the quantum programs run on real prototype quantum computers. Multiple runs of the quantum program are used in both settings to discover the distribution of the states inside the quantum program, according to Phys.

Even with the availability of observations or simulations, there exists a difficulty in interpreting quantum states.

The researchers utilized statistical tests on measurement results to validate if there are consistent results with the three kinds of states. The chi-square statistical test was used to check if the observed states are categorised into classical, superposition, or entangled states. "We focus our attention on these three types of states because they occur throughout a quantum program, and are easier for programmers to identify," Huang said. "If the states don't match what the programmer expects, the statistical tests help the programmer zoom in and find mistakes in the program code."

There are no existing guidelines when it comes to checking or debugging programs. This makes it difficult for researchers to debug programs. Previous studies showed that the quantum algorithms exist as equations or sometimes in the form of quantum circuit diagrams.

The state-of-the-art in quantum programming is akin to programming classical computers 50 years ago," Huang said. "For the time being, researchers are writing quantum programs operation-by-operation, on very low-level bits of information. One contribution of our paper is to discuss how the patterns and structures inside quantum algorithms guide programmers to know what to check."