https://spectrum.ieee.org/quantum-programming-language-twist [ ] IEEE.orgIEEE Xplore Digital LibraryIEEE StandardsMore Sites Sign InJoin IEEE Meet Twist: MIT's Quantum Programming Language Share FOR THE TECHNOLOGY INSIDER Search: [ ] Explore by topic AerospaceArtificial IntelligenceBiomedicalComputingConsumer ElectronicsEnergyHistory of TechnologyRoboticsSemiconductorsSensors TelecommunicationsTransportation IEEE Spectrum FOR THE TECHNOLOGY INSIDER Topics AerospaceArtificial IntelligenceBiomedicalComputingConsumer ElectronicsEnergyHistory of TechnologyRoboticsSemiconductorsSensors TelecommunicationsTransportation Sections FeaturesNewsOpinionCareersDIYEngineering Resources More Special ReportsExplainersPodcastsVideosNewslettersTop Programming LanguagesRobots Guide For IEEE Members Current IssueMagazine ArchiveThe Institute For IEEE Members Current IssueMagazine ArchiveThe Institute IEEE Spectrum About UsContact UsReprints & PermissionsAdvertising Follow IEEE Spectrum Support IEEE Spectrum IEEE Spectrum is the flagship publication of the IEEE -- the world's largest professional organization devoted to engineering and applied sciences. Our articles, podcasts, and infographics inform our readers about developments in technology, engineering, and science. Join IEEE Subscribe About IEEEContact & SupportAccessibilityNondiscrimination PolicyTerms IEEE Privacy Policy (c) Copyright 2022 IEEE -- All rights reserved. A not-for-profit organization, IEEE is the world's largest technical professional organization dedicated to advancing technology for the benefit of humanity. IEEE websites place cookies on your device to give you the best user experience. By using our websites, you agree to the placement of these cookies. To learn more, read our Privacy Policy. view privacy policy accept & close Close Stay ahead of the latest technology trends. Become an IEEE member. Enjoy more free content and benefits by creating an account Saving articles to read later requires an IEEE Spectrum account The Institute content is only available for members Downloading full PDF issues is exclusive for IEEE Members Access to Spectrum's Digital Edition is exclusive for IEEE Members Following topics is a feature exclusive for IEEE Members Adding your response to an article requires an IEEE Spectrum account Create an account to access more content and features on IEEE Spectrum, including the ability to save articles to read later, download Spectrum Collections, and participate in conversations with readers and editors. For more exclusive content and features, consider Joining IEEE. This article is for IEEE members only. Join the world's largest professional organization devoted to engineering and applied sciences and get access to all of Spectrum's articles, podcasts, and special reports. Learn more - Join the world's largest professional organization devoted to engineering and applied sciences and get access to all of Spectrum's articles, archives, PDF downloads, and other benefits. Learn more - CREATE AN ACCOUNTSIGN IN JOIN IEEESIGN IN Close Enjoy more free content and benefits by creating an account Create an account to access more content and features on IEEE Spectrum, including the ability to save articles to read later, download Spectrum Collections, and participate in conversations with readers and editors. For more exclusive content and features, consider Joining IEEE. CREATE AN ACCOUNTSIGN IN Computing Topic News Type Meet Twist: MIT's Quantum Programming Language Keeping tabs on data entanglement keeps reins on buggy quantum code Rina Diane Caballar 18 Feb 2022 3 min read Code sits over a background photo of quantum computing hardware Code: MIT; Quantum computer: Graham Carlow/IBM programming languages entanglement MIT programming coding quantum computing A team of researchers at MIT's Computer Science and Artificial Intelligence Laboratory (CSAIL) have created Twist, a new programming language for quantum computing. Twist is designed to make it easier for developers to identify which pieces of data are entangled, thereby allowing them to create quantum programs that have fewer errors and are easier to debug. Twist's foundations lie in identifying entanglement, a phenomenon wherein the states of two pieces of data inside a quantum computer are linked to each other. "Whenever you perform an action on one piece of an entangled piece of data, it may affect the other one. You can implement powerful quantum algorithms with it, but it also makes it unintuitive to reason about the programs you write and easy to introduce subtle bugs," says Charles Yuan, a Ph.D. student in computer science at MIT CSAIL and lead author on the paper about Twist, published in the journal Proceedings of the ACM on Programming Languages. "What Twist does is it provides features that allow a developer to say which pieces of data are entangled and which ones aren't," Yuan says. "By including information about entanglement inside a program, you can check that a quantum algorithm is implemented correctly." One of the language's features is a type system that enables developers to specify which expressions and pieces of data within their programs are pure. A pure piece of data, according to Yuan, is free from entanglement, and thereby free from possible bugs and unintuitive effects caused by entanglement. Twist also has purity assertion operators to affirm that an expression lacks entanglement with any other piece of data, as well as static analyses and run-time checks to verify these assertions. To evaluate the language, the team wrote programs in Twist for a set of well-known quantum algorithms and executed them on a quantum simulator. "We performed experiments that showed the overhead of running these runtime checks is no more than 3.5 percent over running the base program, which we believe is fairly low and a good trade-off for the safety guarantees the language gives you," Yuan says. The team also introduced small bugs to some of the programs and found that Twist can detect those bugs and reject the erroneous programs. "We hope that when people use our language or design new quantum languages for their specific use cases, they'll be able to look at our work and say that the idea of purity and having entanglement as a feature is something they want because it will give them more confidence that their programs are correct without having to run a lot of expensive simulation and testing," says Yuan. While many researchers are focused on building efficient and optimized quantum hardware, Twist aims to fill the gap in quantum software. "Drawing some parallels to what we're seeing with machine learning and other high-performance computing applications--where with every new phase of hardware development we get a new system and potentially new capabilities-- there are perhaps many incredible opportunities to be had by harnessing the hardware. But it almost always is the software that stands in the way of people having access to that hardware and being able to deploy it and use it widely in different software systems," says Michael Carbin, an associate professor at MIT and coauthor of the paper about Twist. "A lot of the work we're doing is laying some of the foundations and trying to tease out what some of the core abstractions are that may make these types of devices more programmable." Yet one of the challenges the team faced in building Twist is the lack of a standard for what quantum programs should look like. "Over the years, people have developed core algorithms to solve individually complex tasks like factoring integers, but it's less clear how we can build an entire ecosystem of software for it," Yuan says. "With Twist, we were able to build the language around our best consensus of the tasks we want to perform on quantum computers and make it as expressive as possible for those tasks." In terms of limitations, Twist can only tell you whether or not a piece of data is entangled with other pieces of data, but not how they're entangled. "The exact way they're entangled is what will determine whether a quantum algorithm is correct, but there are an infinite number of ways in which data can be entangled," says Yuan. "It's a real challenge to be able to give that finer-grained detail, and it's something we'll need to do in the future." The team is now working on another language that builds upon Twist to tackle other quantum phenomena such as phase and superposition, but they hope Twist will pave the way for creating better quantum programs. "For a developer trying to implement a quantum algorithm, they need the tools built into the language to tell them something is happening in their program that's caused by entanglement," Yuan says. "If we can build core language principles and features that allow a developer to reason about entanglement, we can make it so entanglement is less of a cognitive burden, and allow developers to write more intuitive programs." From Your Site Articles * Rigetti Launches Full-Stack Quantum Computing Service and ... > * Coding for Qubits: How to Program in Quantum Computer Assembly ... > Related Articles Around the Web * A beginner's guide to quantum computer programming > * Quantum programming - Wikipedia > programming languages entanglement MIT programming coding quantum computing Rina Diane Caballar Rina Diane Caballar is a journalist and former software engineer based in Wellington, New Zealand. The Conversation (1) [defa] earningstone sangma 21 Feb, 2022 GSM This is much of a great leap towards something which would be cost effective and with possibilities to improve it further, we can hope it would surely enrich the quantum programming. 0 Replies Hide replies Show More Replies 3 rows of images show 4 people (top), 4 speckle patterns with a red box (middle) and the same 4 photos as the top but less clear. Artificial Intelligence Topic Type News The Deep Learning Toolbox Now Apparently Includes Ground-Up Glass 18 Feb 2022 2 min read Two low-slung robots, one with a horizontally spinning blade, the other with a vertical spinner, collide in an area in a shower of sparks Robotics Topic Type Guest Article BattleBots: Coping With Carnage 18 Feb 2022 5 min read Two humans along with several Spot quadruped and Atlas humanoid robots dance in the testing area of Boston Dynamics' offices Robotics News Type Topic Video Friday: Robotics After Hours 18 Feb 2022 4 min read Related Stories Computing Topic News Type Atomically Thin Materials Significantly Shrink Qubits Computing Topic News Type The 2x Gambit: IBM Tech Doubles Qubit Effectiveness Topic News Type Computing The Race to Build a Fault-Tolerant Superconducting Quantum Computer Computing Topic Type Feature The Future of Deep Learning Is Photonic Computing with light could slash the energy needs of neural networks Ryan Hamerly 29 Jun 2021 10 min read This computer rendering depicts the pattern on a photonic chip that the author and his colleagues have devised for performing neural-network calculations using light. Alexander Sludds DarkBlue1 Think of the many tasks to which computers are being applied that in the not-so-distant past required human intuition. Computers routinely identify objects in images, transcribe speech, translate between languages, diagnose medical conditions, play complex games, and drive cars. The technique that has empowered these stunning developments is called deep learning, a term that refers to mathematical models known as artificial neural networks. Deep learning is a subfield of machine learning, a branch of computer science based on fitting complex models to data. While machine learning has been around a long time, deep learning has taken on a life of its own lately. The reason for that has mostly to do with the increasing amounts of computing power that have become widely available--along with the burgeoning quantities of data that can be easily harvested and used to train neural networks. The amount of computing power at people's fingertips started growing in leaps and bounds at the turn of the millennium, when graphical processing units (GPUs) began to be harnessed for nongraphical calculations, a trend that has become increasingly pervasive over the past decade. But the computing demands of deep learning have been rising even faster. This dynamic has spurred engineers to develop electronic hardware accelerators specifically targeted to deep learning, Google's Tensor Processing Unit (TPU) being a prime example. Here, I will describe a very different approach to this problem--using optical processors to carry out neural-network calculations with photons instead of electrons. To understand how optics can serve here, you need to know a little bit about how computers currently carry out neural-network calculations. So bear with me as I outline what goes on under the hood. Almost invariably, artificial neurons are constructed using special software running on digital electronic computers of some sort. That software provides a given neuron with multiple inputs and one output. The state of each neuron depends on the weighted sum of its inputs, to which a nonlinear function, called an activation function, is applied. The result, the output of this neuron, then becomes an input for various other neurons. Reducing the energy needs of neural networks might require computing with light For computational efficiency, these neurons are grouped into layers, with neurons connected only to neurons in adjacent layers. The benefit of arranging things that way, as opposed to allowing connections between any two neurons, is that it allows certain mathematical tricks of linear algebra to be used to speed the calculations. While they are not the whole story, these linear-algebra calculations are the most computationally demanding part of deep learning, particularly as the size of the network grows. This is true for both training (the process of determining what weights to apply to the inputs for each neuron) and for inference (when the neural network is providing the desired results). What are these mysterious linear-algebra calculations? They aren't so complicated really. They involve operations on matrices, which are just rectangular arrays of numbers--spreadsheets if you will, minus the descriptive column headers you might find in a typical Excel file. This is great news because modern computer hardware has been very well optimized for matrix operations, which were the bread and butter of high-performance computing long before deep learning became popular. The relevant matrix calculations for deep learning boil down to a large number of multiply-and-accumulate operations, whereby pairs of numbers are multiplied together and their products are added up. Multiplying With Light [origin] Two beams whose electric fields are proportional to the numbers to be multiplied, x and y, impinge on a beam splitter (blue square). The beams leaving the beam splitter shine on photodetectors (ovals), which provide electrical signals proportional to these electric fields squared. Inverting one photodetector signal and adding it to the other then results in a signal proportional to the product of the two inputs. David Schneider Over the years, deep learning has required an ever-growing number of these multiply-and-accumulate operations. Consider LeNet, a pioneering deep neural network, designed to do image classification. In 1998 it was shown to outperform other machine techniques for recognizing handwritten letters and numerals. But by 2012 AlexNet, a neural network that crunched through about 1,600 times as many multiply-and-accumulate operations as LeNet, was able to recognize thousands of different types of objects in images. Advancing from LeNet's initial success to AlexNet required almost 11 doublings of computing performance. During the 14 years that took, Moore's law provided much of that increase. The challenge has been to keep this trend going now that Moore's law is running out of steam. The usual solution is simply to throw more computing resources--along with time, money, and energy--at the problem. As a result, training today's large neural networks often has a significant environmental footprint. One 2019 study found, for example, that training a certain deep neural network for natural-language processing produced five times the CO[2] emissions typically associated with driving an automobile over its lifetime. Improvements in digital electronic computers allowed deep learning to blossom, to be sure. But that doesn't mean that the only way to carry out neural-network calculations is with such machines. Decades ago, when digital computers were still relatively primitive, some engineers tackled difficult calculations using analog computers instead. As digital electronics improved, those analog computers fell by the wayside. But it may be time to pursue that strategy once again, in particular when the analog computations can be done optically. It has long been known that optical fibers can support much higher data rates than electrical wires. That's why all long-haul communication lines went optical, starting in the late 1970s. Since then, optical data links have replaced copper wires for shorter and shorter spans, all the way down to rack-to-rack communication in data centers. Optical data communication is faster and uses less power. Optical computing promises the same advantages. But there is a big difference between communicating data and computing with it. And this is where analog optical approaches hit a roadblock. Conventional computers are based on transistors, which are highly nonlinear circuit elements--meaning that their outputs aren't just proportional to their inputs, at least when used for computing. Nonlinearity is what lets transistors switch on and off, allowing them to be fashioned into logic gates. This switching is easy to accomplish with electronics, for which nonlinearities are a dime a dozen. But photons follow Maxwell's equations, which are annoyingly linear, meaning that the output of an optical device is typically proportional to its inputs. The trick is to use the linearity of optical devices to do the one thing that deep learning relies on most: linear algebra. To illustrate how that can be done, I'll describe here a photonic device that, when coupled to some simple analog electronics, can multiply two matrices together. Such multiplication combines the rows of one matrix with the columns of the other. More precisely, it multiplies pairs of numbers from these rows and columns and adds their products together--the multiply-and-accumulate operations I described earlier. My MIT colleagues and I published a paper about how this could be done in 2019. We're working now to build such an optical matrix multiplier. Optical data communication is faster and uses less power. Optical computing promises the same advantages. The basic computing unit in this device is an optical element called a beam splitter. Although its makeup is in fact more complicated, you can think of it as a half-silvered mirror set at a 45-degree angle. If you send a beam of light into it from the side, the beam splitter will allow half that light to pass straight through it, while the other half is reflected from the angled mirror, causing it to bounce off at 90 degrees from the incoming beam. Now shine a second beam of light, perpendicular to the first, into this beam splitter so that it impinges on the other side of the angled mirror. Half of this second beam will similarly be transmitted and half reflected at 90 degrees. The two output beams will combine with the two outputs from the first beam. So this beam splitter has two inputs and two outputs. To use this device for matrix multiplication, you generate two light beams with electric-field intensities that are proportional to the two numbers you want to multiply. Let's call these field intensities x and y. Shine those two beams into the beam splitter, which will combine these two beams. This particular beam splitter does that in a way that will produce two outputs whose electric fields have values of (x + y)/[?]2 and (x - y)/[?]2. In addition to the beam splitter, this analog multiplier requires two simple electronic components--photodetectors--to measure the two output beams. They don't measure the electric field intensity of those beams, though. They measure the power of a beam, which is proportional to the square of its electric-field intensity. Why is that relation important? To understand that requires some algebra--but nothing beyond what you learned in high school. Recall that when you square ( x + y)/[?]2 you get (x^2 + 2xy + y^2)/2. And when you square (x - y)/[?]2, you get (x^2 - 2xy + y^2)/2. Subtracting the latter from the former gives 2xy. Pause now to contemplate the significance of this simple bit of math. It means that if you encode a number as a beam of light of a certain intensity and another number as a beam of another intensity, send them through such a beam splitter, measure the two outputs with photodetectors, and negate one of the resulting electrical signals before summing them together, you will have a signal proportional to the product of your two numbers. Image of simulations of the Mach-Zehnder interferometer. Simulations of the integrated Mach-Zehnder interferometer found in Lightmatter's neural-network accelerator show three different conditions whereby light traveling in the two branches of the interferometer undergoes different relative phase shifts (0 degrees in a, 45 degrees in b, and 90 degrees in c). Lightmatter My description has made it sound as though each of these light beams must be held steady. In fact, you can briefly pulse the light in the two input beams and measure the output pulse. Better yet, you can feed the output signal into a capacitor, which will then accumulate charge for as long as the pulse lasts. Then you can pulse the inputs again for the same duration, this time encoding two new numbers to be multiplied together. Their product adds some more charge to the capacitor. You can repeat this process as many times as you like, each time carrying out another multiply-and-accumulate operation. Using pulsed light in this way allows you to perform many such operations in rapid-fire sequence. The most energy-intensive part of all this is reading the voltage on that capacitor, which requires an analog-to-digital converter. But you don't have to do that after each pulse--you can wait until the end of a sequence of, say, N pulses. That means that the device can perform N multiply-and-accumulate operations using the same amount of energy to read the answer whether N is small or large. Here, N corresponds to the number of neurons per layer in your neural network, which can easily number in the thousands. So this strategy uses very little energy. Sometimes you can save energy on the input side of things, too. That's because the same value is often used as an input to multiple neurons. Rather than that number being converted into light multiple times--consuming energy each time--it can be transformed just once, and the light beam that is created can be split into many channels. In this way, the energy cost of input conversion is amortized over many operations. Splitting one beam into many channels requires nothing more complicated than a lens, but lenses can be tricky to put onto a chip. So the device we are developing to perform neural-network calculations optically may well end up being a hybrid that combines highly integrated photonic chips with separate optical elements. I've outlined here the strategy my colleagues and I have been pursuing, but there are other ways to skin an optical cat. Another promising scheme is based on something called a Mach-Zehnder interferometer, which combines two beam splitters and two fully reflecting mirrors. It, too, can be used to carry out matrix multiplication optically. Two MIT-based startups, Lightmatter and Lightelligence, are developing optical neural-network accelerators based on this approach. Lightmatter has already built a prototype that uses an optical chip it has fabricated. And the company expects to begin selling an optical accelerator board that uses that chip later this year. Another startup using optics for computing is Optalysis, which hopes to revive a rather old concept. One of the first uses of optical computing back in the 1960s was for the processing of synthetic-aperture radar data. A key part of the challenge was to apply to the measured data a mathematical operation called the Fourier transform. Digital computers of the time struggled with such things. Even now, applying the Fourier transform to large amounts of data can be computationally intensive. But a Fourier transform can be carried out optically with nothing more complicated than a lens, which for some years was how engineers processed synthetic-aperture data. Optalysis hopes to bring this approach up to date and apply it more widely. Theoretically, photonics has the potential to accelerate deep learning by several orders of magnitude. There is also a company called Luminous, spun out of Princeton University, which is working to create spiking neural networks based on something it calls a laser neuron. Spiking neural networks more closely mimic how biological neural networks work and, like our own brains, are able to compute using very little energy. Luminous's hardware is still in the early phase of development, but the promise of combining two energy-saving approaches--spiking and optics--is quite exciting. There are, of course, still many technical challenges to be overcome. One is to improve the accuracy and dynamic range of the analog optical calculations, which are nowhere near as good as what can be achieved with digital electronics. That's because these optical processors suffer from various sources of noise and because the digital-to-analog and analog-to-digital converters used to get the data in and out are of limited accuracy. Indeed, it's difficult to imagine an optical neural network operating with more than 8 to 10 bits of precision. While 8-bit electronic deep-learning hardware exists (the Google TPU is a good example), this industry demands higher precision, especially for neural-network training. There is also the difficulty integrating optical components onto a chip. Because those components are tens of micrometers in size, they can't be packed nearly as tightly as transistors, so the required chip area adds up quickly. A 2017 demonstration of this approach by MIT researchers involved a chip that was 1.5 millimeters on a side. Even the biggest chips are no larger than several square centimeters, which places limits on the sizes of matrices that can be processed in parallel this way. There are many additional questions on the computer-architecture side that photonics researchers tend to sweep under the rug. What's clear though is that, at least theoretically, photonics has the potential to accelerate deep learning by several orders of magnitude. Based on the technology that's currently available for the various components (optical modulators, detectors, amplifiers, analog-to-digital converters), it's reasonable to think that the energy efficiency of neural-network calculations could be made 1,000 times better than today's electronic processors. Making more aggressive assumptions about emerging optical technology, that factor might be as large as a million. And because electronic processors are power-limited, these improvements in energy efficiency will likely translate into corresponding improvements in speed. Many of the concepts in analog optical computing are decades old. Some even predate silicon computers. Schemes for optical matrix multiplication, and even for optical neural networks, were first demonstrated in the 1970s. But this approach didn't catch on. Will this time be different? Possibly, for three reasons. First, deep learning is genuinely useful now, not just an academic curiosity. Second, we can't rely on Moore's Law alone to continue improving electronics. And finally, we have a new technology that was not available to earlier generations: integrated photonics. These factors suggest that optical neural networks will arrive for real this time--and the future of such computations may indeed be photonic. From Your Site Articles * Deep Learning's Diminishing Returns - IEEE Spectrum > * How Deep Learning Works > Keep Reading | Show less