Submit transpiled circuits
Background
To get the best performance from your circuits, the Qiskit Runtime service will pass all circuits through Qiskit's transpiler before running them. While this is usually a good thing, we might sometimes want to disable this by passing the argument
For example, we may know better than the transpiler in some cases, or want to target a specific subset of qubits on a specific device. In this tutorial, we'll disable automatic transpilation to test the performance of different transpiler settings. This example will take you through the full process of creating, transpiling, and submitting circuits.
Setup
No output produced
Output:
'ibmq_mumbai'
Step 1: Map classical inputs to a quantum problem
In the following code cell, we create a small circuit that our transpiler will try to optimize. In this example, we create a circuit that carries out Grover's algorithm, with an oracle that marks the state
Output:
Output:
Step 2: Optimize problem for quantum execution.
Next, we transpile the circuits for our backend. We're going to compare the performance of the transpiler with
In the following cell, we transpile
Output:
CNOTs (optimization_level=0): 27
CNOTs (optimization_level=3): 14
Since CNOTs usually have a high error rate, the circuit transpiled with
Another way we can improve performance is through dynamic decoupling, where we apply a sequence of gates to idling qubits. This cancels out some unwanted interactions with the environment. In the following cell, we add dynamic decoupling to the circuit transpiled with
No output produced
Output:
Step 3: Execute using Qiskit Primitives.
At this point, we have a list of circuits transpiled for our system. In the following cell, we create an instance of the sampler primitive, and start a batched job using the context manager (
Within the context manager, we sample the circuits and store the results to
No output produced
Step 4: Post-process, return result in classical format.
Finally, we can plot the results from the device runs against the ideal distribution. You can see the results with
Output:
We can confirm this by computing the Hellinger fidelity between each set of results and the ideal distribution (higher is better, and 1 is perfect fidelity).
Output:
0.873
0.983
0.981
Output:
'0.19.1'
Output:
'1.0.0rc1'
Was this page helpful?