Quantum computing hardware continues to improve to the point where we may actually see real-world use cases in the next few years and so it’s probably no surprise that we are also seeing a steady increase in research projects that focus on how to best program these machines. One of the newest efforts in this space is Silq, a high-level programming language for quantum computers out of Switzerland’s ETH Zurich.
The emphasis here is on ‘high-level programming language,’ as the researchers behind the language note that existing quantum languages for programmers still work at a very low abstraction level, which makes life for quantum programmers a lot harder than necessary.
“The history of the project is that we wanted to solve a core problem in quantum computing,” ETH associate professor of computer science Martin Vechev told me. “And if you want to solve a core problem in quantum computing, for instance, if you want to analyze and reason about quantum programs, you need to have a language in which these problems are expressed — and there are existing languages. We looked at various problems in quantum computing but what kept coming up as a fundamental issue is that we looked at the programs and how they are expressed — and you see that this is not ideal, this is not optimal.”
“Originally, we didn’t think we would need to create a new language,” Vechev’s Ph.D. student Benjamin Bichsel added. “And we didn’t even consider this in the very beginning. We wanted to solve much more advanced problems in quantum computing. We thought, okay, let’s quickly pick a language and then work with that. And then we realized that the existing languages are completely inadequate for the kind of more high-level properties that we are interested in reasoning about.”
One of the co-authors of the paper on Silq that the team is presenting this week at PLDI 2020 (which includes Timon Gehr and Maximilian Baader, together with Bichsel and Vechev, as co-authors), even said he wouldn’t work with any of the existing languages because they were too annoying for him.
So what’s wrong with the existing languages? “A great way to start entering this is looking at one of the fundamental challenges in quantum computation that doesn’t appear in classical languages, which is that of uncomputation,” Vechev noted. Indeed, uncomputation is at the core of Silq’s approach and built-in natively. While there is a classical analog to uncomputation, it’s not necessarily the most intuitive of concepts.
“In classical languages, if you compute ‘A OR B OR C,’ you would compute ‘A OR B’ first and then use this to compute ‘[the result of this] OR C,’ and just forget about this temporary value that you’ve computed in the meantime,” explained Bichsel. “If you do this in quantum, then you get unintended side effects. […] The bottom line is, what you would expect to happen won’t happen in this case. So you have to deal with this somehow. And what this means for essentially all existing quantum languages is that you are forced to work at a very low level of abstraction, where you have to think about all temporary values. And this essentially prevents any sort of high-level thinking.”
This means that even if you want to do something relatively trivial, like adding to integers, on a quantum machine, you have to think about all of the temporary values you create in the process and explicitly handle them.
“For quantum computation, because you always have to deal with this garbage, like the temporary values that you need to discard — you always have to deal with this. And this makes it extremely annoying to work in these languages,” said Bichsel. Current quantum languages try to work around this, but in a relatively convoluted way, while Silq enables safe, automatic uncomputation out of the box.
Vechsel also added that writing low-level programs is more error-prone and makes it more difficult to understand what the algorithm is actually doing. In addition, Silq’s compiler also tries to prevent programmers from making common mistakes. The team also looked at recent developments in classical languages (like ownership types, linear type systems, etc.) and implemented them in the context of quantum computing — something that’s also a first in Silq.
It’s probably no surprise then that the team found that its language produced programs that were significantly shorter than those written in Q# and Quipper, for example, and used far fewer quantum primitives.
For the time being, Silq is still a research project that doesn’t yet run on any of the existing quantum hardware platforms. Instead, the researchers wrote their own quantum emulator to test their assumptions. “In our case, because we are more high-level, we envision the compilation as a two-step process, where first you express your high-level intent and then it’s the job of the compiler to decide which architecture will this run on and how to optimize for a particular architecture,” said Bichsel.
If you want to delve into all of the details of Silq, the teams paper is now available here.