Human communication

A new language for quantum computing | MIT News

Time crystals. Microwave. Diamonds. What do these three disparate things have in common?

Quantum computing. Unlike traditional computers that use bits, quantum computers use qubits to encode information as zeros or ones, or both at the same time. Coupled with a cocktail of forces from quantum physics, these refrigerator-sized machines can process a lot of information, but they are far from perfect. Just like our regular computers, we need to have the right programming languages ​​to compute correctly on quantum computers.

Programming quantum computers requires an awareness of something called “entanglement,” a computational multiplier for kinds of qubits, which translates to a lot of power. When two qubits are entangled, actions on one qubit can change the value of the other, even when they are physically separated, giving rise to Einstein’s characterization of “frightening action at a distance”. But this power is in equal measure a source of weakness. When programming, abandoning a qubit without considering its entanglement with another qubit can destroy the data stored in the other, compromising the accuracy of the program.

Scientists in Computer Science and Artificial Intelligence (CSAIL) at MIT set out to get by by creating their own programming language for quantum computing called Twist. Twist can describe and verify what data is entangled in a quantum program, using a language that a typical programmer can understand. The language uses a concept called purity, which enforces the absence of tangles and results in more intuitive programs, ideally with fewer bugs. For example, a programmer can use Twist to say that temporary data generated as garbage by a program is not entangled with the program’s response, allowing it to be safely discarded.

While the nascent field may seem a bit flashy and futuristic, with images of gigantic threadlike gold machines springing to mind, quantum computers have the potential for computational breakthroughs in classically intractable tasks, like cryptographic protocols and communication, research and computational physics and chemistry. One of the main challenges in computer science is to manage the complexity of the problem and the amount of calculations required. While a classical digital computer would need an exponentially large number of bits to be able to process such a simulation, a quantum computer could do so, potentially, using a very small number of qubits – if the right programs are there.

“Our Twist language allows a developer to write safer quantum programs by explicitly indicating when one qubit should not be entangled with another,” says Charles Yuan, an MIT doctoral student in electrical and computer engineering and lead author of a new article on Twist. . “Because understanding quantum programs requires understanding entanglement, we hope Twist will pave the way for languages ​​that make the unique challenges of quantum computing more accessible to programmers.”

Yuan authored the paper alongside Chris McNally, a doctoral student in electrical engineering and computer science affiliated with MIT’s Electronics Research Laboratory, and MIT Assistant Professor Michael Carbin. They presented the research at the Programming Principles Symposium 2022 conference last week in Philadelphia.

Untangling Quantum Entanglement

Imagine a wooden box with a thousand cables sticking out from one side. You can pull any cable completely out of the box or push it all the way in.

After doing this for a while, the cables form a pattern of bits – zeros and ones – depending on whether they went in or out. This box represents the memory of a typical computer. A program for this computer is a sequence of instructions for when and how to pull the cables.

Now imagine a second identical-looking box. This time you pull on a cable and see that as it emerges a few more cables are pulled inside. Obviously, inside the box, these cables are somehow tangled with each other.

The second box is an analogy for a quantum computer, and understanding the meaning of a quantum program requires understanding the entanglement present in its data. But detecting entanglement is not straightforward. You can’t see into the wooden box, so the best you can do is try to pull the cables out and carefully determine which ones are tangled. In the same way, quantum programmers today must reason about entanglement by hand. This is where Twist’s design helps massage some of those intertwined parts.

Scientists designed Twist to be expressive enough to write programs for well-known quantum algorithms and identify bugs in their implementations. To evaluate Twist’s design, they modified programs to introduce some sort of bug that would be relatively subtle for a human programmer to detect, and showed that Twist could automatically identify bugs and reject programs.

They also measured the practical performance of the programs in terms of execution time, which had less than 4% overhead compared to existing quantum programming techniques.

For those wary of quantum’s “shabby” reputation for its potential to crack encryption systems, Yuan says it’s still unclear how well quantum computers will actually be able to deliver on their performance promises. In practice. “There’s a lot of research going on in post-quantum cryptography, which exists because even quantum computing isn’t all-powerful. So far, there is a very specific set of applications where people have developed algorithms and techniques where a quantum computer can outperform classical computers.

An important next step is to use Twist to create higher-level quantum programming languages. Today, most quantum programming languages ​​still resemble assembly language, stringing together low-level operations, with no attention to data types and functions, and is typical of classical software engineering.

“Quantum computers are error-prone and difficult to program. By introducing and reasoning about the “purity” of program code, Twist takes a big step forward in facilitating quantum programming by ensuring that quantum bits in a piece of pure code cannot be modified by bits that are not not in this code,” says Fred Chong, the Seymour Goodman Professor of Computer Science at the University of Chicago and chief scientist at

The work was supported, in part, by the MIT-IBM Watson AI Lab, the National Science Foundation, and the Office of Naval Research.