Out[]=

This notebook explores the Wolfram Quantum Framework and its integration with Q-CTRL’s Fire Opal. The key integration code is: with being quantum objects. The code first creates a quantum circuit in Mathematica. With no input, the circuit computation is done locally in Mathematica for exact quantum predictions: . Using the specified method, a job is sent to a backend leveraging Fire Opal features and the corresponding measurement results are obtained.

QuantumCircuitOperator[{,,...}][Method->{"Qiskit","Provider"->"IBMProvider","Backend"->backend,"FireOpal"->True}]

obj

1

obj

2

obj

i

QuantumCircuitOperator[{,,...}][]

obj

1

obj

2

The Wolfram Quantum Framework transforms quantum computation by enabling symbolic and numeric operations, seamlessly integrating analog and digital quantum processes. Mathematica users can engage with quantum hardware through cloud services, connecting to, e.g., Amazon Web Services (AWS) and IBM Quantum. The primary challenge of excessive noise in QPUs is tackled by Q-CTRL’s Fire Opal, which delivers effective error suppression technology for quantum computers as a simple, fully-automated solution suitable for any user.

Install the Wolfram quantum paclet:

In[]:=

PacletInstall["https://wolfr.am/DevWQCF",ForceVersionInstall->True]Needs["Wolfram`QuantumFramework`"]

Out[]=

PacletObject

qc=QuantumCircuitOperator["PhaseEstimation"[QuantumOperator["P"[2Pi/7]]]]

Out[]=

QuantumCircuitOperator

Show the circuit diagram:

qc["Diagram",FontSize->9]

Out[]=

Calculate the numerical quantum predictions as a quantum measurement object:

mea=N[qc][]

Out[]=

QuantumMeasurement

Generate quantum measurement results:

mea"ProbabilityPlot",AspectRatio,PlotLabel"Exact quantum predictions"

1

4

Out[]=

Now we will focus on submitting the quantum circuit object to an IBM QPU. If you have not yet, create an IBM Quantum account and get your token APIs. Then connect to IBM Quantum API:

ibmq=ServiceConnect["IBMQ","New"]

Out[]=

ServiceObject

When running the above code, a new page pops up:

Fill out your API token and click “Agree and Continue.”

If you use only , the previous connection that was saved on the system will be used, if any.

ServiceConnect["IBMQ"]

Check you account information to confirm you have connected successfully:

In[]:=

ibmq["Account"]

Check the queue of all the available backends:

ibmq["BackendQueue"]

Out[]=

The code below allows users to submit queries to a specified backend, but it requires waiting for the cloud-based job to complete before proceeding with any further computations (the kernel will be busy):

QuantumCircuitOperator[...][Method->{"Qiskit","Provider"->"IBMProvider","Backend"->backend}]

A workaround involves utilizing a separate kernel to execute the quantum circuit on the QPU backend, and then assigning the evaluation result to the variable in the current session. Note you must replace backend by an actual QPU name, such as “ibm_kyoto”:

LocalSubmit[Needs["Wolfram`QuantumFramework`"];N[QuantumCircuitOperator["PhaseEstimation"[QuantumOperator["P"[2Pi/7]]]]][Method->{"Qiskit","Provider"->"IBMProvider","Backend"->backend}],HandlerFunctions-><|"TaskFinished"->((qpu=#EvaluationResult)&)|>]

We employ LocalSubmit to ensure that other computations can proceed independently. The duration of quantum computations in the code, excluding QuantumCircuitOperator, is unrelated to Mathematica and the Wolfram Quantum Framework. Once Qiskit completes circuit transpilation and the related steps, the circuit is sent to the QPU through API connection and a new job appears in your IBM Quantum account under “Jobs.” Upon the job completion, the quantum measurement results will be assigned to qpu. This happens only if you wait long enough for the job to be completed on the IBM Cloud.

It usually takes a long time for job completion. Once completed, users can get the result using this code:

ibmq["JobResults","JobID"->jobID]

Based on the obtained results, it is possible to calculate the corresponding probability outcomes:

qpu=With[{counts=Cases[Normal@ibmq["JobResults","JobID"->jobID],<|"counts"->as_|>:>as,All][[1]]},Normalize[Join[AssociationThread[Tuples[{0,1},4]->0],KeyMap[Reverse@IntegerDigits[Interpreter["HexInteger"][#],2,4]&,counts]],Total]];

Represent the results using a bar chart:

In[]:=

BarChartqpu,ChartLabels->Placed[Keys[qpu],Tooltip],AspectRatio->14,PlotLabel->"QPU results (no Fire Opal)",ChartStyle->

Out[]=

To leverage Fire Opal features, simply set the FireOpal parameter to True in the code. Running the code below will prompt redirection to the Fire Opal webpage, where login is required. You can also sign up for an account and authenticate using an API key.

In[]:=

QuantumCircuitOperator[...][Method->{"Qiskit","Provider"->"IBMProvider","Backend"->backend,"FireOpal"->True}]

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

As before, utilize a separate kernel to execute the quantum circuit on the QPU backend, and then assigning the evaluation result to the variable in the current session:

Similar to the previous scenario, after job completion, the quantum measurement results are assigned to fireOpal. To obtain results without waiting for the extended IBM Cloud processing time, users can use the following code:

Represent the results using a bar chart:

Here are the compiled results from Wolfram Quantum Framework (quantum predictions), QPU results both without Fire Opal and with Fire Opal, allowing users to easily compare the outcomes:

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

Fire Opal’s performance improvement is evident visually and can be quantitatively explored.

Compute the statistical distance using the Kullback–Leibler divergence with the exact probability distribution as the reference:

A value of 0 indicates that the two distributions in question have identical quantities of information. As one can see from the numbers above, the Fire Opal divergence is lower and therefore the results align much better with the expected exact predictions.

With this test, a higher value means a greater likelihood of shared values between the two distributions. This test also shows that the results using Fire Opal are much closer to the exact distribution.

Another test to consider is the Hellinger Fidelity, a metric that compares the expected and actual outputs of the machine following state generation—higher is better and the ideal value is 1.

As you can tell from both the visual comparison and the quantitative fidelity metrics, Fire Opal improves the accuracy of the circuit execution by removing hardware noise.