Q-CTRL digest

Why Q-CTRL does quantum programming in Python

June 6, 2018
Written by
Marcus Strom

The Black Opal suite is coming to the public soon and we wanted to share a bit of insight about the architectural approach we've taken in designing our products.

We're building a fully engineered, tested, and secured cloud-based platform for quantum control, not just shipping a package to download (and perpetually update). This way we can continually bring our customers the best new quantum control features as soon as they're built.

When designing a new system like Black Opal from scratch, developers need to decide what programming language to use. While this won't always matter to end users, we want to help our most discerning customers understand the thinking behind our choice of quantum programming in Python.

It boils down to ease of use, speed of development, support for collaboration in our team, and transparency of Q-CTRL's unique approach to quantum control.

Ease of Collaboration and Transparency Make Python our Obvious Choice

Team Photo
Virginia Frey (Quantum Control Engineer) and Kevin Nguyen (Lead Back-end Engineer).

As was discussed in last week's blog quantum technologists will be able to enter relevant inputs about their system into Black Opal's front end; this ranges from basic information like gate speeds through to complex noise spectra characterizing the environment experienced by qubits. That information is processed in the back-end by Python-compatible libraries that perform calculations to match your system with the most appropriate controls for your needs, often based on algorithms exploiting filter functions.

This process has been developed by our team, including Quantum Control Engineer Virginia Frey and Lead Back-End Engineer, Kevin Nguyen.

I asked them why Q-CTRL relies on the quantum programming Python language rather than the arguably faster C++ language.

Ms Frey said: "One reason we use Python is it's much simpler than C++. That's important when you have a big group of people working together where some team members are professional programmers while others are quantum scientists. So it's much easier for all of us, as a team, to pick up a task and build something quickly.

But it's about more than just local collaboration. Using Python enables the team to leverage the global community's efforts as well. "Python has a huge global open-source community. This means there are a lot of fantastic libraries that have been developed by this community."

A Python library is an in-built collection of methods and functions that give you computational capacity without having to write your own code. Common libraries, such as NumPy and SciPy, provide utility to perform complex numerical operations.

These libraries are mostly written in C, so by using Python we leverage the development speed from using a relatively easy to understand language with the processing speed from inbuilt libraries that use compiled languages.

Ms Frey said: "Whatever we do numerically is implemented in these libraries." This includes the computational process used to characterize and optimize controls for multi-qubit gates. As discussed in a recent blog post, expanding the filter function formalism beyond single-qubit systems is challenging.

The quantum control engineering team led by Dr Michael Hush and Dr Harrison Ball has used these Python libraries as building blocks for Q-CTRL's computational algorithms. Using libraries ensures we don't waste time reinventing the wheel and can focus on the important part: quantum control.

Our focus really is all about bringing the most powerful capabilities to our customers as rapidly as possible. This is essential in a rapidly developing field like quantum technology where new techniques and even basic physics insights emerge every day.

Mr Nguyen said: "It might be logical to ask, if C is faster why not just use that language without the Python 'wrapper'? The answer to that is the Python allows for much faster development speed. So we sacrifice a little bit of processing speed for the speed of the development process."

Ms Frey said there is a division of labour in the structure of the programming. "Everything that is computationally really hard is implemented in a fast C language and Python calls on this to run its processes."

"So it's not Python versus C," Mr Nguyen said. "In essence, we are using both."

As well as the flexibility it gives to the back-end of Black Opal, Mr Nguyen said there is another important aspect to using Python that goes directly to our product architecture.

"The Black Opal platform we are building is an API, which is a cloud-based service. Python is much better suited to build these sorts of systems," he said.

Python gives the team access to web-based frameworks like Django which includes security features embedded into its framework. Mr Nguyen said: "This means we are safe against attacks such as SQL injection, request forgery or cross-site scripting. This is really important for companies trusting us to help them with their most critical tasks."

Ms Frey pointed out that quantum experimentalists are also familiar with Python in their own work. Mr Nguyen agreed, describing it as the 'native tongue' of the research community in which we operate. This opens up possibilities for our work to have broader impact, but also helps to ensure it's trusted by research teams who may initially be incredulous about black-box solutions.

He said: "By quantum programming in Python, there are elements of our work that can be open to our community. Quantum researchers familiar with Python can then look at what we are doing and have confidence in our processes."

Q-CTRL founder and CEO, Professor Michael Biercuk, said: "Transparency and accountability for what we do are central to our mission as a company. Working in the same programming language as our community is just a small part of our commitment to being real, being honest, and being trusted."