Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 2faada0

Browse files
authored
Update resource estimation notebooks to use new features (#772)
* Change error rate for T-state requirements. * Input arguments for Q# sample. * Input arguments for Q# sample. * Fix broken link.
1 parent fe3c9c5 commit 2faada0

File tree

4 files changed

+31
-48
lines changed

4 files changed

+31
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ This repo contains several configuration files that will make it easy to get sta
8080

8181
### Visual Studio Code
8282

83-
If you prefer to develop code locally, we recommend to install an editor such as [Visual Studio Code](https://code.visualstudio.com/download). Make sure to install the [.NET Core SDK 3.1 or later](https://www.microsoft.com/net/download) on your local machine. For more detailed instructions on how to set up VS Code for development with the QDK, go to our docs [here](https://docs.microsoft.com/azure/quantum/install-command-line-qdk).
83+
If you prefer to develop code locally, we recommend to install an editor such as [Visual Studio Code](https://code.visualstudio.com/download). Make sure to install the [.NET Core SDK 3.1 or later](https://dotnet.microsoft.com/download) on your local machine. For more detailed instructions on how to set up VS Code for development with the QDK, go to our docs [here](https://docs.microsoft.com/azure/quantum/install-command-line-qdk).
8484

8585
Once you have installed VS Code and the .NET Core SDK, download this repository to your computer and open the folder in VS Code. The editor will automatically recognize the files in the `.vscode` folder and request you to install the recommended extension. This includes the [Microsoft Quantum Development Kit for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=quantum.quantum-devkit-vscode) extension, which is the fastest way to get started with the QDK.
8686

samples/azure-quantum/resource-estimation/advanced-estimation.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@
6767
"As running example algorithm we are creating a multiplier using the [MultiplyI](https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.arithmetic.multiplyi) operation. We can configure the size of the multiplier with a bitwidth parameter. The operation will have two input registers with that bitwidth, and one output register with the size of twice the bitwidth."
6868
]
6969
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": null,
73+
"metadata": {},
74+
"outputs": [],
75+
"source": [
76+
"EstimateMultiplication: any = None # Make Python recognize the Q# function (optional)"
77+
]
78+
},
7079
{
7180
"cell_type": "code",
7281
"execution_count": null,
@@ -131,13 +140,7 @@
131140
"We are now submitting resource estimation jobs for all combinations of job\n",
132141
"parameters and input arguments.\n",
133142
"\n",
134-
"Since the Resource Estimator does not support input parameters for operations,\n",
135-
"we are creating a wrapper operation on the fly by inserting the bitwidth\n",
136-
"directly into the source code and then compiling it using `qsharp.compile`.\n",
137-
"This is a generic method that you can use to generate operations for resource\n",
138-
"estimation from Python.\n",
139-
"\n",
140-
"We then submit this wrapper operation for each experiment configuration using\n",
143+
"We submit the multiplication operation for each experiment configuration using\n",
141144
"`qsharp.azure.submit`. This will return a job object from which we extract the\n",
142145
"Job ID. and store it in the `jobs` dictionary. Note that loop will not wait for\n",
143146
"jobs to be finished."
@@ -157,13 +160,10 @@
157160
"display(progress_bar)\n",
158161
"\n",
159162
"for bitwidth in bitwidths:\n",
160-
" callable = qsharp.compile(f\"\"\"operation EstimateMultiplication{bitwidth}() : Unit {{ EstimateMultiplication({bitwidth}); }}\"\"\");\n",
161-
" print(callable)\n",
162-
"\n",
163163
" for name, params in input_params.items():\n",
164164
" progress_bar.description = f\"{bitwidth}: {name}\"\n",
165165
"\n",
166-
" result = qsharp.azure.submit(callable, jobParams=params)\n",
166+
" result = qsharp.azure.submit(EstimateMultiplication, bitwidth=bitwidth, jobParams=params)\n",
167167
" jobs[name].append(result.id)\n",
168168
" progress_bar.value += 1"
169169
]

samples/azure-quantum/resource-estimation/estimation-qir.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"The QIR we submit to the function defined above must be passed in bitcode\n",
149149
"format. We obtain this format by calling `bitcode` instead of `ir` on the\n",
150150
"module. We can also pass resource estimation specific arguments, e.g., setting\n",
151-
"the error rate to 1%."
151+
"the error rate to 0.5%."
152152
]
153153
},
154154
{
@@ -157,7 +157,7 @@
157157
"metadata": {},
158158
"outputs": [],
159159
"source": [
160-
"job = resource_estimation_job_from_qir(provider, module.bitcode(), errorBudget=0.01)\n",
160+
"job = resource_estimation_job_from_qir(provider, module.bitcode(), errorBudget=0.005)\n",
161161
"\n",
162162
"# Alternatively you can generate QIR bitcode using the ir_to_bitcode function from PyQIR, e.g.,\n",
163163
"#\n",

samples/azure-quantum/resource-estimation/estimation-qsharp.ipynb

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@
7070
"As running example algorithm we are creating a multiplier using the [MultiplyI](https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.arithmetic.multiplyi) operation. We can configure the size of the multiplier with a bitwidth parameter. The operation will have two input registers with that bitwidth, and one output register with the size of twice the bitwidth."
7171
]
7272
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"metadata": {},
77+
"outputs": [],
78+
"source": [
79+
"EstimateMultiplication: any = None # Make Python recognize the Q# function (optional)"
80+
]
81+
},
7382
{
7483
"cell_type": "code",
7584
"execution_count": null,
@@ -100,36 +109,7 @@
100109
"cell_type": "markdown",
101110
"metadata": {},
102111
"source": [
103-
"In order to estimate an operation using the Azure Quantum Resource Estimator target, it cannot take any input arguments and must have a `Unit` return value. But we can simply create a new instance for a specific bitwidth, for example 8 in this case."
104-
]
105-
},
106-
{
107-
"cell_type": "code",
108-
"execution_count": null,
109-
"metadata": {},
110-
"outputs": [],
111-
"source": [
112-
"EstimateMultiplication8: any = None # Make Python recognize the Q# function (optional)"
113-
]
114-
},
115-
{
116-
"cell_type": "code",
117-
"execution_count": null,
118-
"metadata": {},
119-
"outputs": [],
120-
"source": [
121-
"%%qsharp\n",
122-
"\n",
123-
"operation EstimateMultiplication8() : Unit {\n",
124-
" EstimateMultiplication(8);\n",
125-
"}"
126-
]
127-
},
128-
{
129-
"cell_type": "markdown",
130-
"metadata": {},
131-
"source": [
132-
"Let's now estimate the physical resources for this operation using the default assumptions. We can submit the operation to the resource estimation target using the `qsharp.azure.execute` function."
112+
"Let's now estimate the physical resources for this operation using a bitwidth of 8 and the default assumptions. We can submit the operation to the resource estimation target using the `qsharp.azure.execute` function."
133113
]
134114
},
135115
{
@@ -138,7 +118,7 @@
138118
"metadata": {},
139119
"outputs": [],
140120
"source": [
141-
"result = qsharp.azure.execute(EstimateMultiplication8)"
121+
"result = qsharp.azure.execute(EstimateMultiplication, bitwidth=8)"
142122
]
143123
},
144124
{
@@ -226,7 +206,8 @@
226206
"metadata": {},
227207
"outputs": [],
228208
"source": [
229-
"result = qsharp.azure.execute(EstimateMultiplication8,\n",
209+
"result = qsharp.azure.execute(EstimateMultiplication,\n",
210+
" bitwidth=8,\n",
230211
" jobParams={\n",
231212
" \"qubitParams\": {\n",
232213
" \"name\": \"qubit_maj_ns_e6\"\n",
@@ -477,7 +458,8 @@
477458
"metadata": {},
478459
"outputs": [],
479460
"source": [
480-
"result_maj_floquet = qsharp.azure.execute(EstimateMultiplication8,\n",
461+
"result_maj_floquet = qsharp.azure.execute(EstimateMultiplication,\n",
462+
" bitwidth=8,\n",
481463
" jobParams={\n",
482464
" \"qubitParams\": {\n",
483465
" \"name\": \"qubit_maj_ns_e6\"\n",
@@ -567,7 +549,8 @@
567549
"metadata": {},
568550
"outputs": [],
569551
"source": [
570-
"result_maj_floquet_e1 = qsharp.azure.execute(EstimateMultiplication8,\n",
552+
"result_maj_floquet_e1 = qsharp.azure.execute(EstimateMultiplication,\n",
553+
" bitwidth=8,\n",
571554
" jobParams={\n",
572555
" \"qubitParams\": {\n",
573556
" \"name\": \"qubit_maj_ns_e6\"\n",

0 commit comments

Comments
 (0)