WOLFRAM

Reduce Quantum Noise with Wolfram Language and Fire Opal

Reduce Quantum Noise with Wolfram Language and Fire Opal

Practical quantum computers have not entered the mainstream, but that has not stopped researchers and developers from innovating. Simulating quantum results on classical hardware and getting meaningful results from noisy quantum hardware are two important areas with lots of recent innovations.

The Wolfram Quantum Framework is a toolkit for Wolfram Language that offers quantum simulations. The Framework brings quantum experimentation to anyone and opens the door for more research and development of quantum algorithms. This can also be used to connect with external cloud services such as Amazon Braket or IBM Quantum for an even closer look at what running on quantum hardware could be.

Reducing the Chance of Misfires with Fire Opal

Because of the presence of environmental noise, quantum processing units (QPUs) are susceptible to “misfires,” potentially leading to erroneous outcomes when executing a quantum algorithm on a QPU. To address this challenge, Wolfram has partnered with Q-CTRL, making it easier than ever to get useful results out of quantum hardware.

Q-CTRL’s Fire Opal offers a support system that automatically includes error-suppression techniques as the quantum circuit is translated to hardware-specific instructions, and also runs on a QPU. This greatly increases the probability of obtaining an accurate result from the intended algorithm and makes it possible to successfully run more complex algorithms. The following graph shows the improvement in QPU results using Fire Opal when compared with exact predictions of quantum theory for this phase estimation algorithm:

Predictions of quantum theory for phase estimation algorithm

The preceding graph shows an example of what the QPU results look like both with and without Fire Opal in comparison with the exact predictions by the Wolfram Quantum Framework.

Please note: To run the complete code sequence presented in this post, an API to a quantum cloud service provider is required. Download the notebook here to interact with the complete post.

Computing the Quantum Theory Predictions

The Wolfram Quantum Framework allows you to easily specify quantum circuits and analyze their behavior as predicted by quantum theory. The framework is developed as a paclet in the Wolfram Paclet Repository and can be installed by running the following code in a notebook:

PacletInstall

After installing and loading the paclet, create a circuit to implement the standard phase estimation algorithm for a given operator—in this case, a phase operator with the angle 2π/7:

qc = QuantumCircuitOperator

You can show the diagram of this circuit by simply asking for the "Diagram" property of the circuit operator:

qc ["Diagram"

Next, compute the measurement probabilities for each outcome as predicted by quantum theory. In this case, the results have also been numericized for a speedier result. If you want the exact results, don’t use N on the circuit; simply use qc[]. The result is returned as a quantum measurement object:

mea = N

From the measurement object, you can plot the probability of each outcome:

mea ["ProbabilityPlot"

Connecting to Quantum Hardware Service Providers

Connections to external services (such as quantum hardware access) can be utilized by establishing a service connection. If you want to use an IBM backend, create an IBM Quantum account.

To create a new connection to IBMQ, you can use the following code:

ibmq = ServiceConnect

The first time you attempt to connect to a service that requires an API token, you will see the following window appear:

IBMQ WolframConnector

If you choose to save the connection, you can simply use ServiceConnect["IBMQ"] the next time that you want to connect on the same system.

After the connection is established, you can ask for the queue of all available backends:

ibmq ["BackendQueue"

With the service connection established, running a circuit can be as simple as the following code structure:

QuantumCircuitOperator

Note that you must replace backend with an actual QPU name, such as "ibm_kyoto".

However, this simplest method requires waiting for the job to complete and receiving a response before proceeding with any further computations. This will mean your kernel is busy waiting for a response from the hardware provider.

If you want to do other local computations while waiting for the submitted job to complete, one method is to use a separate kernel to send the request and handle the response. The following code does this and assigns the result to the variable qpu in the current kernel session:

LocalSubmit

Note that the wait time for QPU providers to provide responses can vary quite a lot, and is dependent on the queue for the specific backend. Once the job is done, you can also check on results using the service connection and the appropriate job ID:

ibmq ["JobResults"

If you already know the job is done and want to store the results in the variable qpu, you can use the appropriate job ID and perform some post-processing to get the data into shape:

qpu =

With results in hand, you can visualize them as a bar chart:

BarChart [ qpu

Fine-Tuning with Fire Opal

So far, you have just seen how to use a service connection to run your circuit on quantum computing hardware. Using Fire Opal as part of the process is as simple as adding another option. Set the "FireOpal" parameter to True when providing a method option to your quantum circuit operator. Running the code with a valid circuit operator and specified backend will prompt redirection to the Fire Opal webpage, where login is required:

QuantumCircuitOperator

One can first validate the compatibility of circuits for Fire Opal. Note that by default Fire Opal’s “validate” feature is not active. For example, the following circuit returns an error:

QuantumCircuitOperator[Bell], Failure

As before, you may want to utilize a separate kernel or other method to avoid keeping your system busy waiting for the response from the QPU provider. Remember to fill in the parameter for the desired backend before running the code:

LocalSubmit

If the job is already done, you can retrieve past results in the same way as before, this time storing them in the variable fireOpal:

fireOpal

As before, you can visualize the results:

BarChart [ fireOpal

If you want to immediately analyze the results of an experiment without submitting your own jobs to QPUs, you can use the results here from one experiment:

exact =

The exact results are computed using the Wolfram Quantum Framework and are the probabilities one would expect from the mathematics of quantum theory. They provide a nice baseline for comparing what comes back from the inherently noisy QPUs of today. One set of measurements for the phase estimation circuit in the first section was done without using Fire Opal, and another set was done using Fire Opal.

Combine the results and visualize them in a bar chart for easy comparison:

GraphicsColumn @

Fire Opal’s improvement of the experimental results is visually evident as the expected peak at a particular measurement outcome. Notice how the theoretical result for this circuit is sharply peaked at one particular measurement value, while the hardware without Fire Opal provides a much greater deviation from the expected results.

Reviewing the Results

To compare the results of the phase estimation quantitatively, one can choose from a variety of statistical tests.

For example, one can compute how “different” one distribution is from another using the Kullback–Leibler divergence. Smaller numbers of this quantity indicate the two distributions are more similar. Compare the results both with and without Fire Opal to the exact reference distribution:

With [ {P

With [ {P

Another test to consider is the Kolmogorov–Smirnov test. The convention for this function is that larger numbers indicate it is more likely the results are from the exact reference distribution:

KolmogorovSmirnovTest [Values

KolmogorovSmirnovTest [Values

Finally, let’s compute the Hellinger fidelity as a measure of the distance between distributions. Smaller numbers of this quantity indicate the distributions are more similar:

With [ {P

With [ {P

With three different quantitative evaluations to support our work, Fire Opal has proved itself to be a valuable resource to improve the accuracy of the quantum circuit extension when running on a QPU.

The Future of Quantum Computing

As quantum hardware advances, the possibilities for quantum computing become more exciting. Using the Wolfram Quantum framework for algorithm design, cloud service providers for quantum hardware access and Fire Opal for increased hardware performance, it has never been easier to innovate.

For more information on how to partner with us and make your own quantum noise, please contact us at quantum@wolfram.com.

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.