Lesson 12: Utility I
Tamiya Onodera (July 5, 2024)
© IBM Corp. 2024
Approximate QPU time to run this experiment is 45 seconds.
Click here to download this notebook in Jupyter format.
Click here to download the pdf of the original lecture. Please note that some code snippets may become deprecated since these are static images.
1. Introduction to the utility paper
In this lesson, we run a utility-scale circuit which appears in what we informally call "the utility paper" published in Nature Vol 618, 15 June 2023. The paper deals with the time evolution of the 2D transverse-field Ising model. In particular, they consider time dynamics of the Hamiltonian,
in which is the coupling of nearest-neighbor spins with and is the global transverse field.
They simulate spin dynamics from an initial state by means of first-order Trotter decomposition of the time-evolution operator,
in which the evolution time is discretized into Trotter steps and and are and rotation gates, respectively.
They ran experiments on an IBM Quantum Eagle processor, which is a 127-qubit device with heavy-hex connectivity, applying interactions to all the qubits and interactions for all the edges of the coupling map. Please note that all the interactions cannot be applied simultaneously due to "data dependance". Hence, they color the coupling map to group them into layers. Those in a layer are assigned the same color, and can be applied in parallel.
In addition, for experimental simplicity, they focused on the case .
The novel contribution of the paper is that they built quantum circuits at a scale beyond statevector simulation, ran them on noisy quantum computers, and succeeded in extracting reliable results. That is, they demonstrated the utility of noisy quantum computers. In doing so, they applied zero-noise extrapolation (ZNE) with probabilistic error amplification (PEA) to mitigate errors from noisy devices.
From then on, we called such experiments and circuits "utility-scale".
1.1 Your goal
Your goal in this lesson is to build a utility-scale circuit and run it on an Eagle processor. It is beyond the scope of this notebook to extract reliable results, partly because PEA is an experimental feature of Qiskit at this time of writing and partly because applying ZNE with PEA will take a fair amount of time.
Concretely, you are asked to build and run the circuit corresponding to Figure 4b of the paper, and plot the "unmitigated" points of your own. As you see, it is a 127-qubit 60-layer (20 Trotter steps) circuit with the as an observable.
Sound like a big deal? Don't worry. The last three lessons of this course provide stepping stones. To begin, we will demonstrate a smaller-scale experiment which is to build and run on a fake device a 27-qubilt 6-layer (2 Trotter steps) circuit with the as an observable.
That's all for the introduction. Let us go on a utility-scale adventure!
Output:
'1.3.0'
No output produced
No output produced
No output produced
2. Preparation
2.1 Construct RZZ(- / 2)
First, observe that the RZZ gate in general requires two gates.
Output:
As mentioned above, we focus on the RZZ gate with a specific angle, - / 2, for this experiment. As shown in the paper, it can be realized with just one gate.
Output:
We define a gate in terms of this circuit for future reference.
No output produced
Let us make a random use of the newly-defined
Output:
Before using this further, let's verify the logical equivalence of
Output:
True
2.2 Color the coupling map
Let us study how we color the coupling map of a backend. This is needed to group interactions into layers.
To begin with, let us visualize the coupling map of a backend. Note the coupling maps are heavy-hexagonal for all the current IBM Quantum devices.
Output:
To color a coupling map, we use rustworkx, which is a Python package for working with graphs and complex networks. It provides multiple coloring algorithms, which are all heuristic and thus aren't guaranteed to find a minimal coloring.
Having said this, since heavy-hex graphs are bipartite, we pick up graph_bipartite_edge_color, which should find a minimal coloring for these graphs.
No output produced
Heavy-hexagonal graphs should be painted in three colors. Let us check this for the above coupling map.
Output:
ibm_kyiv, 127-qubit device, 3 colors assigned.
Yes, it is!
For fun, let us paint the coupling map to the coloring obtained, using the feature of rustworks visualization.
Output:
3. Solve the Trotterized time evolution of a 2D Ising model.
Let us define a routine to construct a circuit of the utility paper for the time evolution of a 2D Ising model. The routine takes three parameters, a backend, an integer indicating the number of Trotter steps, and a Boolean controlling the barrier insertion.
No output produced
Please note that we have already manually performed qubit mapping and routing for the circuit constructed. Thus, when we transpile the circuit later, we do not (should not) ask the transpiler to do qubit mapping and routing. As you will soon see, we invoke it with the optimization level as 1 and the layout method as "trivial".
Next we define a simple routine to get the information about the circuit constructed for a quick check.
No output produced
Let us exercise these routines. You should see a circuit of 27 qubit 15 layers (5 Trotter steps). Since the fake device has 28 edges, there should be 28*5 entangling gages.
Output:
27 qubits × 15 layers (20-depth), Gate breakdown: CIRCUIT-2238 140, RX 135, BARRIER 5
27 qubits × 15 layers (60-depth), Gate breakdown: SDG 280, UNITARY 280, CX 140, R 135, BARRIER 5
4. Solve the 27-qubit version of the problem.
We now demonstrate a smaller-scale version of the utility experiment. We build a 27-qubit 6-layer (2 Trotter steps) circuit with as an observable, and run it both on AerSimulator and a fake device.
Of course, we follow our four-step workflow, "Qiskit Pattern", which consists of Map, Optimize, Execute, and Post-Process. More concretely,
- Map classical inputs to a quantum computation.
- Optimize circuits for quantum computation.
- Execute circuits using primitives.
- Post-process and return results in classical format.
In the following, we have the Map step for creating a circuit for a smaller-scale experiment. We then have one set of Optimize and Execute for AerSimulator and another for a fake device. Finally, we have the Post-Process step to plot the results.
4.1 Step 1: Map
No output produced
4.2 Steps 2 and 3: Optimize and Execute (Simulator)
Output:
27 qubits × 6 layers (23-depth), Gate breakdown: SDG 112, UNITARY 112, CX 56, R 54
27 qubits × 6 layers (16-depth), Gate breakdown: U3 80, CX 56, R 54, U1 32, U 28
One user ran the next cell using a MacBook Pro with 2.3 GHz quad-core Intel Core i7 Processor eqipped with 32GB 3LPDDR4X RAM which is running macOS 14.5. It took 161ms in Wall time. Each laptop will be slightly different.
Output:
CPU times: user 672 ms, sys: 663 ms, total: 1.34 s
Wall time: 172 ms
4.3 Steps 2 and 3: Optimize and Execute (Fake device)
Output:
27 qubits × 6 layers (23-depth), Gate breakdown: SDG 112, UNITARY 112, CX 56, R 54
27 qubits × 6 layers (49-depth), Gate breakdown: SDG 324, U1 274, H 162, CX 56, U3 14
When the same user ran the next cell with the same environment as above, it took 2min 19s in Wall Time. Executing a circuit on a fake device invokes noisy simulation which takes much longer time than exact simulation. We recommend you not execute a larger circuit (such as a 27-qubit 9 layers with 3 Trotter steps) on a fake device.
Output:
CPU times: user 12min, sys: 9.82 s, total: 12min 10s
Wall time: 46.7 s
4.4 Step 4: Post-process
We plot the results from exact and noisy simulations. You see the severe effects of noise on FakeToronto.
Output:
5. Solve the 127-qubit version of the problem.
It is your goal to run the utility-scale experiment as mentioned at the beginning. You will create and execute a 127-qubit and 60-layer (20 Trotter steps) circuit with as an observable. We recommend you try to do this yourself, using the code for the 27-qubit version when appropriate. But the solution is provided here.
Solution:
5.1 Step 1: Map
No output produced
5.2 Stepa 2 & 3: Optimize and Execute
We note that the coupling map of the Eagle processor has 144 edges.
Output:
127 qubits × 60 layers (260-depth), Gate breakdown: SDG 5760, UNITARY 5760, CX 2880, R 2540
127 qubits × 60 layers (302-depth), Gate breakdown: RZ 12399, SX 3924, X 3243, ECR 2880
Output:
job id=ctxq4t3ckyk0008a81pg
5.3 Post-process
We provide the values for the "mitigated" points in Figure 4b of the utility paper. Please plot these together with your results.
Output:
Are your results similar to the "unmitigated" in Figure 4b? They could be very different, depending on the device and its condition at the time of experiment. Do not worry about the results themselves. What we will check is whether you have done the coding correctly. If you have done so, congratulations, you have reached the starting line of the utility era.
As in the Utility paper, scientists across the globe have put forth tremendous ingenuity to extracting meaningful results even in the presence of noise. The end goal of this collective effort is quantum advantage: a state in which quantum computers can solve some problems of use in industry faster, with higher fidelity, or more cheaply than classical computers. This is not likely to be a single event, but rather an era in which classical reproduction of quantum results takes progressively longer, until at some point that quantum lead time becomes critically important. One thing is clear about quantum advantage: we get there only through the utility-scale experiments. If this course results in your joining the quest, which is full of challenge and fun, we would be more than happy.
Reference
- Kim, Y., Eddins, A., Anand, S. et al. Evidence for the utility of quantum computing before fault tolerance, Nature 618, 500–505 (2023).
Was this page helpful?