How to Get a Numeric Resource Estimate¶
This how-to guide walks you through the high-level steps of getting quantum resource estimates for a simple Workbench program.
Quantum resource estimation is a process that estimates the resources required to run a quantum program on a fault-tolerant quantum computer under certain assumptions about its architecture. You can read more about the resource metrics gathered by Workbench and their interpretation in Getting Basic Numeric Resource Estimates.
Step 1. Initialize the QPU¶
Create a QPU object. Do not provide any arguments beyond num_qubits to the constructor.
qpu = QPU(num_qubits=4)
If your program is too big to be simulated using one of the Workbench simulators, you need to specify a list of filters that does not include a simulator. You can use filter preset NO_SIM_DEFAULT, which allows you to draw circuits and run resource estimation, or NO_SIM_LONG, which supports resource estimation without circuit drawing.
qpu = QPU(num_qubits=4, filters=NO_SIM_DEFAULT)
Step 2. Write the program¶
Write the Workbench code following the steps outlined in How to Write a Simple Program.
Step 3. Get resource estimates¶
Create a ResourceEstimator object using the resource_estimator() API call and fetch the resource estimates from it using its resources() method.
from psiqworkbench.resource_estimation.qre import resource_estimator
resources = resource_estimator(qpu).resources()
display(resources)
Example¶
The following example shows how to get resource estimates for the Workbench program from How to Write a Simple Program that prepares two Bell states in two different ways (using the primitive gates and using state preparation library) and then measures them.
from psiqworkbench import QPU, Qubits
from psiqworkbench.resource_estimation.qre import resource_estimator
from workbench_algorithms import ArbitraryStatePrep
# Initialize a QPU
qpu = QPU(num_qubits=4)
# Allocate qubits
reg1 = Qubits(2, "reg1", qpu=qpu)
reg2 = Qubits(2, "reg2", qpu=qpu)
# Perform the computation using primitive gates
reg1[0].had()
reg1[1].x(cond=reg1[0])
# Perform the computation using library routines
state_prep = ArbitraryStatePrep([1, 0, 0, 1])
state_prep.compute(reg2)
# Get the results
res1 = reg1.read()
res2 = reg2.read()
# Get resource estimates
resources = resource_estimator(qpu).resources()
display(resources)
{'active_volume': 44,
'gidney_lelbows': 0,
'gidney_relbows': 0,
'measurements': 4,
'rotations': 1,
'pprs': 0,
'ppms': 0,
't_gates': 0,
'toffs': 0,
'qubit_highwater': 4}