Building workflows with the IBM Circuit function
Building workflows with the IBM Circuit function
Estimated QPU usage: 26 minutes (tested on IBM Brisbane)
In this notebook, we will walk through an example of building and running a workflow using the IBM Circuit function. This function takes Primitive Unified Blocs (PUBs) as inputs and returns error-mitigated expectation values as outputs. It provides an automated and customized pipeline to optimize circuits and execute on quantum hardware so that researchers can focus on algorithm and application discovery.
Visit the documentation for an introduction to Qiskit Functions and learn how to get started with the IBM Circuit function.
Requirements
Before starting this tutorial, be sure you have the following installed:
- Qiskit SDK 1.2 or later (
pip install qiskit ) - Qiskit Runtime 0.28 or later (
pip install qiskit-ibm-runtime ) - IBM Qiskit Functions Catalog client 0.0.0 or later (
pip install qiskit-ibm-catalog ) - Qiskit Aer 0.15.0 or later (
pip install qiskit-aer )
Build the Qiskit pattern
We implement the example workflow using the Qiskit pattern as a guide. For this tutorial, we consider a general hardware-efficient Trotterized time evolution circuit for the 2D tranverse-field Ising model and compute the global magnetization. Such a circuit is useful in different application domains such as condensed matter physics, chemistry, machine learning etc. For more information on the structure of this model, refer to Nature 618, 500–505 (2023).
The IBM Circuit function combines capabilities from the Qiskit transpiler service and Qiskit Runtime Estimator to provide a simplified interface for running circuits. The function performs transpilation, error suppresion, error mitigation, and circuit execution within a single managed service so that we can focus on mapping the problem to circuits rather than building out each step of the pattern ourselves.
Step 1. Map classical inputs to a quantum problem
- Input: Parameters to create the quantum circuit
- Output: Abstract circuit and observables
Construct the circuit
The circuit we will create is a hardware-efficient, Trotterized time evolution circuit for the 2D transverse-field Ising model. We start with selecting a backend. Properties of this backend (i.e., its coupling map) will be used to define the quantum problem and ensure it is hardware-efficient.
No output produced
Next, we get the coupling map from the backend.
No output produced
We want to be careful in how we design the layers of our circuit. We will do this by coloring the edges of the coupling map (i.e., grouping the disjoint edges) and use that coloring to more efficiently place gates in the circuit. This will lead to a shallower circuit with layers of gates that can be executed simultaneously on the hardware.
No output produced
Next, we write a simple helper function that implements the hardware-efficient, Trotterized time evolution circuit for the 2D transverse-field Ising model using the edge coloring obtained above.
No output produced
We will choose the number of qubits and trotter steps and then construct the circuit.
Output:
In order to benchmark the quality of the execution, we need to compare it with the ideal outcome. The circuit of choice is beyond brute force classical simulation. So, we fix the parameters of all the
No output produced
Construct the observable
In this tutorial, we will compute the global magnetization along for our -qubit problem: . This requires first computing the single-site magnetization for each qubit , which we define below.
Output:
SparsePauliOp(['ZIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII'],
coeffs=[1.+0.j])
Steps 2 and 3: Optimize problem and execute with the IBM Circuit function
- Input: Abstract circuit and observables
- Output: Mitigated expectation values
Now, we can pass the abstract circuit and observables to the IBM Circuit function. It will handle transpilation and execution on quantum hardware for us and return mitigated expectation values. First, we load the function from the IBM Qiskit Functions Catalog.
No output produced
The IBM Circuit function takes
No output produced
We can also configure the
In this tutorial, we will set the
No output produced
With the inputs specified, we submit the job to the IBM Circuit function for optimization and execution.
No output produced
Step 4: Post-process results
- Input: Results from the IBM Circuit function
- Output: Global magnetization
Compute the global magnetization
The result from running the function has the same format as the Estimator.
No output produced
We obtain the mitigated and non-mitigated expectation values from this result. These expectation values represent the single-site magnetization along the direction. We average these to arrive at the global magnetization and compare against the ideal value of
Output:
mitigated: 0.9749883476088692
unmitigated: 0.7832977198447583
Tutorial Survey
Tutorial Survey Please take one minute to provide feedback on this tutorial. Your insights will help us improve our content offerings and user experience. |
Was this page helpful?