At this nascent stage of quantum computing, each of the limited hardware/device makers have their own software stacks. As the ecosystem evolves and early use cases prove out, there might be a more accessible, generalizable way to interface the quantum and traditional computing worlds: good old-fashioned Python.
After all, if experimental use of different hardware platforms in concert with traditional systems is the reality for most quantum work today, what could be better than simplified scripting to test and prototype?
According to Alexander McCaskey and Thien Nguyen from Oak Ridge National Lab, where a great deal of quantum algorithm and software work has taken place over the last several years, Python holds promise to bridge the hybrid divide for just that simplified prototyping reason. This wasn’t simple per se, it took building an extension onto Python that allows heterogeneous hybrid quantum/traditional computing via a robust C++ infrastructure for quantum “just-in-time” compilation. But the results that balance usability in a hardware agnostic way (something of utmost importance now) are compelling.
The ORNL researchers say Python is a fit during these early stages of quantum/traditional work for a few reasons, including getting around some pesky problems for Python in HPC, at least. Given the remote interactions between the classical compute and quantum resources, performance isn’t primary. Further, using Python opens the door to all the available libraries, from application- to network-specific. The most compelling reason is the most obvious—these workloads are in the early experimental stages. Having a language that allows quick prototyping via easy scripting makes experimentation more straightforward.
“[Quantum] programmers are forced to switch frameworks – learn new data structures and models – every time they want to program a different quantum computer, if they desire to get the most out of the feature set provided by the framework. This has a large effect on algorithmic and benchmarking research activities that require the ability to quickly prototype algorithms and applications and compare execution across a variety of near-term QPUs.”
“Python is a popular programming language known for its flexibility, usability, readability, and focus on developer productivity,” McCaskey and Nguyen explain. “The quantum software community has adopted Python on a number of large-scale efforts due to these characteristics, as well as the remote nature of near-term quantum processors. The use of Python has enabled quick prototyping for quantum code that directly benefits pertinent research and development efforts in quantum scientific computing. However, this rapid prototyping ability comes at the cost of future performant integration for tightly-coupled CPU-QPU architectures with fast-feedback.”
The approach the ORNL researchers developed is a bit more complicated than just introducing Python in to the mix, of course. The experimental hybrid programming model is based on the qcor C++ extension as the grounding platform for both system to interface with Python on top. They have developed a new Python extension for that “just-in-time” compiling, one that can be easily swapped between the various quantum hardware devices from IBM, Rigetti, Honeywell (among others) in addition to running quantum simulations on Summit supercomputer-scale resources.
As the ORNL team describes, “The just-in-time compiler in Python operates in three phases: (1) capturing functions intended to describe quantum kernels by means of Python decorators, (2) delegating the compilation of the quantum kernel body to the qcor just-in-time compiler, and (3) invoking the compiled functions with runtime parameters provided in Python.”
Our work seeks to provide a futureproof platform for rapid prototyping and experimentation of quantum scientific computing applications under both loosely and tightly coupled CPU-QPU machine models. We anticipate that this core Pythonic infrastructure can serve as a foundation for rapid experimentation via scripting, application libraries, and benchmarking of quantum-classical use-cases in a hardware-agnostic manner.
A detailed assessment of their just-in-time compiler and the framework across a number of architectures is available here.
Sign up to our Newsletter
Featuring highlights, analysis, and stories from the week directly from us to your inbox with nothing in between.
Be the first to comment