This article is more than 1 year old

Could we use an LLVM-based cross-compiler to build apps for quantum computers? This alliance says yes

Microsoft, Linux Foundation-backed QIR has a chance to make QC source code portable across different systems

The Linux Foundation has launched a group called the QIR Alliance to make quantum computing applications more portable across hardware architectures and simulators.

The QIR in QIR Alliance stands for Quantum Intermediate Representation, which may not mean much to those unfamiliar with "intermediate representation" in the context of computing.

Within the LLVM compiler framework, an intermediate representation (IR) of classical computer code serves as a platform-independent assembly language. Application source code in C, C++, Rust, Go, and other languages is compiled into this IR by a front-end. From this convenient format, the IR is turned into optimized IR, which is then converted by a back-end into executable code for a target system.

The QIR Alliance aims to provide those programming quantum computers with a Quantum Intermediate Representation that outlines rules for representing quantum programs in LLVM IR.

In essence, QIR will serve as common ground for researchers developing quantum-computing software for various different systems. As documented here by the group, QIR can be used to turn generic quantum programs into operations for specific quantum-computer architectures to perform, or at least that's the hope.

"A consistent IR of quantum programs will enable interoperability between quantum applications and hardware devices, making quantum computing more usable to researchers and developers," explained Thien Nguyen, quantum computer science researcher at America's Oak Ridge National Laboratory, in a statement.

"We look forward to contributing to the QIR specification and the associated compiler toolchain under this partnership."

Microsoft announced QIR last year, and offered as an example this Q# code for generating a Bell pair...

// Assumes that qb1 and qb2 are already in the |0> state
operation BellPair(qb1 : Qubit, qb2 : Qubit) : Unit
{
    H(qb1);
    CNOT(qb1, qb2);
}

...that looks like this when compiled to QIR:

define void @BellPair__body(%Qubit* %qb1, %Qubit* %qb2) {
entry:
  call void @__quantum__qis__h(%Qubit* %qb1)
  call void @__quantum__qis__cnot(%Qubit* %qb1, %Qubit* %qb2)
  ret void
}

One interesting use-case for QIR, according to the Linux Foundation, involves developing "quantum optimizers that operate on QIR and target it to specific hardware backends or linking it with classical high-performance libraries for quantum simulation."

This opens up the possibility of cross-compiling quantum-computing applications not only for quantum machines but also for your non-quantum workstation to run within a simulation environment, allowing you to see how the code operates without having to fire up an actual quantum computer.

This will allow the community to experiment with and develop optimizations and code transformations that work in a variety of use cases

"The QIR Alliance will provide a single representation that can be used for both today’s restricted capabilities and the more powerful systems of the future," said Bettina Heim, principal software engineering manager at Microsoft, in a statement. "This will allow the community to experiment with and develop optimizations and code transformations that work in a variety of use cases."

In an email to The Register, Heim, who in addition to her role at Microsoft also serves as QIR Alliance chair, pointed to Azure Quantum fullstate simulator, currently in private preview, and to Pacific Northwest National Laboratory's high-performance GPU-based simulators, DM-sim and SV-sim, as examples of quantum computer simulations on classical systems that implement QIR.

"The idea is to compile quantum programs into QIR, and then use the LLVM toolchain or Clang to link the QIR with the necessary runtime libraries and a simulator implementation into an executable," she explained. "This executable then runs like any other executable on a CPU, or GPU, or other backends that LLVM supports. The simulator itself is simply a library that can be written in any language that compiles into LLVM."

Heim said the QIR specification is portable and allows for interoperability between programming languages, citing QCOR, developed by Oak Ridge National Laboratory, as an example.

With QIR we aim to build a powerful compiler infrastructure that is capable and flexible enough to target the wide variety of hardware backends

"With QIR we aim to build a powerful compiler infrastructure that is capable and flexible enough to target the wide variety of hardware backends," she said. "The idea is that language-specific frontend compilers compile source code into QIR compliant with the specification. This format is portable and not specific to any particular hardware backend.

"This enables interoperability between any languages that compile to QIR. Before executing QIR on a hardware backend, the QIR is linked with runtime and target specific libraries, optimized further, and then targeted to that specific backend, resulting in a QIR profile. A profile is no longer portable but target specific. This allows the hardware backend to process and support only what makes sense for that particular hardware platform."

Useful quantum computers will be impossible without error correction. Good thing these folks are working on it

READ MORE

Founding QIR Alliance members include Honeywell, Microsoft, Oak Ridge National Laboratory, Quantum Circuits Inc. and Rigetti Computing, under the auspices of the Linux Foundation's Joint Development Foundation. It's interesting seeing Microsoft show up with the Linux Foundation embracing and extending something like LLVM's IR.

Conspicuously absent from the alliance are D-Wave, Google, and IBM, all of which make regular noise about qubits and the like.

IDC on Monday said it expects the annual global market for quantum computers will reach $8.6bn by 2027, a fraction of the $161.93bn projected for 2021 global PC sales. With commercial quantum workloads still many years away, consider the QIR Alliance a long-term bet. ®

More about

TIP US OFF

Send us news


Other stories you might like