Recently, Microsoft called for an intermediate representation for quantum programs, called QIR (Quantum Intermediate Representation), which work as common interfaces between different programming languages for gate-based quantum computing and target quantum computation programs.
Based on the LLVM intermediate language, QIR was introduced on September 23. It specifies rules to represent constructs in LLVM. There are no changes necessary to be made to LLVM for this.
QIR supports Microsoft’s Q# language, which is open-source. However, it is not specific to this only, as any other language used in gate-based quantum computing can be represented. QIR is hardware-agnostic, not locked to certain quantum instructions or gate sets.
A certain application said to be enabled by QIR has an LLVM-based Clang compiler compile QIR into executable machine code. This code is made for a classical target, making a path for building a simulator using C or C++. This involves implementing quantum instruction set functions as well.
The draft QIR specification is available on GitHub courtesy of Microsoft. A compiler extension that generates QIR from Q# was also released, and it can be found in the feature/QIR branch of Q#’s repository. Some instructions are also provided.
According to Microsoft, most large-scale quantum applications will utilise both classical and quantum machines in tandem as quantum computing technology matures and advances. LLVM is meant to offer QIR describing quantum-integrated rich classical computation. It can also integrate with various classical languages and tools already compatible with its tool chain.
Compilers often follow the common pattern of compiling the source language into an intermediate representation, usually to allow the representation of different source languages. This intermediate representation allows code to be optimised and transformed. As the actual target platform is identified, the intermediate representation can simply be compiled to executable code.
Microsoft is one of the world’s most famous technology company. With a goal to build and invest in technology to make a lasting positive impact, Microsoft has made waves in the quantum community with its tools such as QDK and Q#. Microsoft’s is also perusing a Quantum Cloud approach with its Microsoft Quantum Azure service.