How to run multiple configurations of target parameters with the Resource Estimator
In this article, you learn how to run multiple configurations of target parameters and compare them using the Azure Quantum Resource Estimator.
For information about how to run the Resource Estimator, see Different ways to use the Resource Estimator.
Prerequisites
The latest version of Visual Studio Code or open VS Code on the Web.
The latest version of the Quantum Development Kit extension. For installation details, see Installing the QDK on VS Code.
Install the latest version of the Python, and Jupyter extensions for VS Code.
The latest Azure Quantum
qsharp
package.python -m pip install --upgrade qsharp
Batching with the Resource Estimator
The Azure Quantum Resource Estimator allows you to run jobs with multiple configurations of target parameters, also known as batching, as a single job to avoid rerunning multiple jobs on the same quantum program.
A resource estimation job consist of two types of job parameters:
- Target parameters: qubit model, QEC schemes, error budget, constraints on the component-level, and distillation units.
- Operation arguments: arguments that can be passed to the program (if the QIR entry point contains arguments).
One item consists of one configuration of job parameters, that is one configuration of target parameters and operation arguments. Several items are represented as an array of job parameters.
Some scenarios where you may want to batch multiple items as a single job:
- Run multiple target parameters with same operation arguments in all items.
- Run multiple target parameters with different operation arguments in all items.
- Easily compare multiple results in a tabular format.
- Easily compare multiple results in a chart.
How to run batch estimation
Batching with Q# can be done in a Jupyter Notebook in VS Code. You can perform a batch estimation by passing a list of target parameters to the params
parameter of the qsharp.estimate
function.
The following example shows how to run two configurations of target parameters as a single job. The first configuration uses the default target parameters, and the second configuration uses the qubit_maj_ns_e6
qubit parameter and the floquet_code
QEC scheme.
In the same Jupyter Notebook of your Q# program, add a new cell and run the following code:
result_batch = qsharp.estimate("RunProgram()", params=
[{}, # Default parameters
{
"qubitParams": {
"name": "qubit_maj_ns_e6"
},
"qecScheme": {
"name": "floquet_code"
}
}])
result_batch.summary_data_frame(labels=["Gate-based ns, 10⁻³", "Majorana ns, 10⁻⁶"])
You can also construct a list of estimation target parameters using the EstimatorParams
class. The following code shows how to batch six configurations of target parameters as a single job.
from qsharp.estimator import EstimatorParams, QubitParams, QECScheme
labels = ["Gate-based µs, 10⁻³", "Gate-based µs, 10⁻⁴", "Gate-based ns, 10⁻³", "Gate-based ns, 10⁻⁴", "Majorana ns, 10⁻⁴", "Majorana ns, 10⁻⁶"]
params = EstimatorParams(num_items=6)
params.error_budget = 0.333
params.items[0].qubit_params.name = QubitParams.GATE_US_E3
params.items[1].qubit_params.name = QubitParams.GATE_US_E4
params.items[2].qubit_params.name = QubitParams.GATE_NS_E3
params.items[3].qubit_params.name = QubitParams.GATE_NS_E4
params.items[4].qubit_params.name = QubitParams.MAJ_NS_E4
params.items[4].qec_scheme.name = QECScheme.FLOQUET_CODE
params.items[5].qubit_params.name = QubitParams.MAJ_NS_E6
params.items[5].qec_scheme.name = QECScheme.FLOQUET_CODE
qsharp.estimate("RunProgram()", params=params).summary_data_frame(labels=labels)
Note
If you run into any issue while working with the Resource Estimator, check out the Troubleshooting page, or contact AzureQuantumInfo@microsoft.com.