Silq – First Intuitive Programming Language For Quantum Computers

Researchers at ETH Zurich have designed the first programming language, Silq, that can be used to program quantum computers as simply, reliably and safely as classical computers. Silq is the very first high-level programming language for quantum computers. High-level programming languages are more expressive, meaning that they can describe even complex tasks and algorithms with less code.

Silq programming language

Silq is a new high level quantum programming language developed by ETH Zurich. The intent is do provide a language that enables code that is shorter and simpler, less error prone, and more intuitive that existing lower level programming languages. The developers indicate that this will provide programs with much fewer lines of code than other programming languages; on average -46% versus Q# and -38% versus Quipper. A key feature is that it provides for automatic uncomputation of temporary values. This is more complicated than resetting a temporary classical value because the temporary qubits are entangled with other qubits and resetting it by measuring it can have some unintended consequences.  For now, Silq does not generate code for any existing hardware backend and only supports its own simulator.

Silq is the first quantum programming language that is not designed primarily around the construction and functionality of the hardware, but on the mindset of the programmers when they want to solve a problem—without requiring them to understand every detail of the computer architecture and implementation.

Silq is also the first programming language that automatically identifies and erases values that are no longer needed. It’s a major breakthrough in terms of optimizing the programming of quantum computers.

silq

As a key novelty, Silq helps to bridge the conceptual gap between classical and quantum languages. As a consequence, Silq (i) lowers the entrance barrier for non-expert quantum programmers, (ii) generally helps to express complicated algorithms cleanly and concisely, and (iii) facilitates a tech-transfer of 50+ years of programming and analysis techniques developed for classical computing, to the domain of quantum programming.

Comparison

While traditionally quantum algorithms were often specified in terms of circuits, quantum languages express quantum algorithms more conveniently as source code. However, existing quantum languages force the programmer to work at a low level of abstraction, still essentially specifying quantum circuits that explicitly apply quantum operations to individual quantum bits. As a consequence, implementing quantum algorithms in these languages is tedious and error-prone.

In contrast, Silq supports a descriptive view on quantum algorithms that expresses the high-level intent of the programmer. Then, the compilation of these algorithms to low-level quantum circuits becomes a second-order concern that can be handled by a specialized compiler, much like in classical programming languages.silqExperimental evaluation demonstrates that Silq programs are significantly shorter than equivalent programs in other quantum languages (on average -46% for ​Q#,​ -38% for ​Quipper​), while using only half the number of quantum primitives. Thus, Silq programs are not only shorter, but also easier to read and write, as they require less primitives and concepts.

Most of over evaluation focused on Q#, because (i) it is one of the most widely used quantum languages, (ii) we consider it to be more high-level than ​Cirq or ​QisKit​, and (iii) the Q# coding contests from ​2018 and ​2019 provide a large collection if Q# implementations we were able to leverage for our comparison.

Team​

Silq was developed by ​Benjamin Bichsel​, ​Maximilian Baader​, ​Timon Gehr​, and Prof. Martin Vechev​, who are all part of the SRI Lab, a research group at ETH Zurich’s Department of Computer Science.

Resources

  • Silq’s webpage (​http://silq.ethz.ch/​) offers a detailed introduction of Silq’s ​key concepts ​, a demonstration of ​Silq’s benefits over Q# ​, concrete ​examples of Silq algorithms, instructions​ on installation, and much more.
  • Silq’s parser, type checker, and simulator are publicly available at GitHub and licensed under the Boost Software License 1.0.

Key Benefit – Automatic Uncomputation

The key benefit of Silq is that it automatically (without intervention from the programmer) handles ​uncomputation of temporary values. In the following, we explain the necessity of uncomputation, and the benefits of automating it.

Analogously to the classical setting, quantum computations often produce temporary values. However, as a key challenge specific to quantum computation, removing such values from consideration induces an ​implicit measurement ​collapsing the state. In turn, collapsing can result in unintended side-effects on the state due to the phenomenon of ​entanglement​. Surprisingly, due to the quantum principle of ​deferred measurement​, preserving values until computation ends is equivalent to measuring them immediately after their last use, and hence cannot prevent this problem.

To remove temporary values from consideration without inducing an implicit measurement, algorithms in existing languages must explicitly uncompute all temporary values, i.e., modify their state to enable ignoring them without side-effects. In particular, even dropping the result of a sub-expression like ​x||y in ​(x||y)||z requires explicitly applying gates that uncompute this value, essentially forcing the programmer to perform manual memory management.

This results in a significant gap from quantum to classical languages, where discarding temporary values typically requires no action (except for heap values not garbage-collected). This gap is a major roadblock preventing the adoption of quantum languages as the implicit side-effects resulting from uncomputation mistakes, such as silently dropping temporary values, are highly unintuitive.

In contrast, Silq is comparable to high-level languages like Rust, in that it automatically handles uncomputation in a safe way. Among other benefits, this allows us to naturally support nested expressions, as known from classical languages.

Key Technique – Quantum Type System.​

Silq introduces a novel ​quantum type system which exploits a fundamental pattern in quantum algorithms, stating that uncomputation can be done safely if (i) the original evaluation of the uncomputed value can be described classically, and (ii) the variables used to evaluate it are preserved and can thus be leveraged for uncomputation.

Silq’s quantum type system allows it to detect this pattern, ensuring uncomputation is possible. Moreover, Silq also detects when uncomputation is not possible. In this case, Silq reports an error—before even running the algorithm. As a consequence, all Silq algorithms are physical: they can be realized on a quantum computer, and never attempt physically impossible operations like invalid uncompuation or reversing a measurement.

Future Benefits.

Silq is expected to advance various tools central to programming quantum computers. First, Silq compilers may require fewer quantum bits, e.g., by more flexibly picking the time of uncomputation. Second, static analyzers for Silq can safely assume (instead of explicitly proving) temporary values are discarded safely. Third, Silq simulators may improve performance by dropping temporary values instead of explicitly simulating uncomputation. Finally, Silq’s key language features are relevant beyond Silq, as they can be incorporated into existing languages such as QWire or Q#.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *