Skip to content

Commit 1483001

Browse files
abbycrossrobertodrdavidemateriafpietraHuangJunye
authored
Ajc/algorithmiq new branch - finishing work started in #4639 (#4693)
CC: @fpietra @HuangJunye --------- Signed-off-by: Roberto Di Remigio Eikås <robertodr@users.noreply.github.com> Co-authored-by: Roberto Di Remigio Eikås <robertodr@users.noreply.github.com> Co-authored-by: davidemateria <davide.materia@algorithmiq.fi> Co-authored-by: Francesca <francesca@algorithmiq.fi> Co-authored-by: Junye Huang <h.jun.ye@gmail.com> Co-authored-by: Francesca Pietracaprina <fpietra@users.noreply.github.com> Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>
1 parent 5a99164 commit 1483001

File tree

9 files changed

+940
-32
lines changed

9 files changed

+940
-32
lines changed

docs/guides/algorithmiq-tem.ipynb

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@
1010
"description: Introduction to TEM, a Qiskit Function by Algorithmiq, to compute estimations with software post-processing error mitigation using tensor networks.\n",
1111
"---\n",
1212
"\n",
13-
"\n",
1413
"{/* cspell:ignore POVM, mathbf, Filippov, Lindblad, Leahy, Rossi, García, Pérez, Minev, Kandala, Temme, informationally */}"
1514
]
1615
},
16+
{
17+
"cell_type": "markdown",
18+
"id": "d606b64e",
19+
"metadata": {
20+
"tags": [
21+
"version-info"
22+
]
23+
},
24+
"source": []
25+
},
1726
{
1827
"cell_type": "markdown",
1928
"id": "dde95705",
@@ -28,12 +37,8 @@
2837
},
2938
{
3039
"cell_type": "markdown",
31-
"id": "a5773f7a",
32-
"metadata": {
33-
"tags": [
34-
"version-info"
35-
]
36-
},
40+
"id": "b130b1ae",
41+
"metadata": {},
3742
"source": [
3843
"{/*\n",
3944
" DO NOT EDIT THIS CELL!!!\n",
@@ -155,15 +160,14 @@
155160
},
156161
{
157162
"cell_type": "code",
158-
"execution_count": 1,
163+
"execution_count": null,
159164
"id": "cc0a8093",
160165
"metadata": {},
161166
"outputs": [],
162167
"source": [
163168
"from qiskit_ibm_catalog import QiskitFunctionsCatalog\n",
164169
"\n",
165170
"tem_function_name = \"algorithmiq/tem\"\n",
166-
"\n",
167171
"catalog = QiskitFunctionsCatalog(channel=\"ibm_quantum_platform\")\n",
168172
"\n",
169173
"# Load your function\n",
@@ -183,7 +187,7 @@
183187
},
184188
{
185189
"cell_type": "code",
186-
"execution_count": 2,
190+
"execution_count": null,
187191
"id": "ab05b87f",
188192
"metadata": {},
189193
"outputs": [],
@@ -213,8 +217,9 @@
213217
"options = {\"default_precision\": 0.02}\n",
214218
"\n",
215219
"# Define backend to use. TEM will choose the least-busy device reported by IBM if not specified\n",
216-
"backend_name = \"ibm_torino\"\n",
220+
"backend_name = \"ibm_marrakesh\"\n",
217221
"\n",
222+
"# Run the TEM function (uses around three minutes of QPU time)\n",
218223
"job = tem.run(pubs=[pub], backend_name=backend_name, options=options)"
219224
]
220225
},
@@ -254,13 +259,22 @@
254259
},
255260
{
256261
"cell_type": "code",
257-
"execution_count": 4,
262+
"execution_count": 7,
258263
"id": "ad5b9a53",
259264
"metadata": {},
260-
"outputs": [],
265+
"outputs": [
266+
{
267+
"name": "stdout",
268+
"output_type": "stream",
269+
"text": [
270+
"0.10229839785546409\n"
271+
]
272+
}
273+
],
261274
"source": [
262275
"result = job.result()\n",
263-
"evs = result[0].data.evs"
276+
"evs = result[0].data.evs\n",
277+
"print(evs[0])"
264278
]
265279
},
266280
{
@@ -306,19 +320,38 @@
306320
"\n",
307321
"A dictionary containing the advanced options for the TEM. The dictionary may contain the keys in the following table. If any of the options are not provided, the default value listed in the table will be used. The default values are good for typical use of TEM.\n",
308322
"\n",
309-
"Name | Choices | Description | Default\n",
323+
"Name | Type | Description | Default\n",
310324
"-- | -- | -- | --\n",
311-
"`tem_max_bond_dimension` | int | The maximum bond dimension to be used for the tensor networks. | 500 |\n",
312-
"`tem_compression_cutoff` | float | The cutoff value to be used for the tensor networks. | 1e-16\n",
313-
"`compute_shadows_bias_from_observable` | bool | A boolean flag indicating whether the bias for the classical shadows measurement protocol should be tailored to the PUB observable or not. If False, the classical shadows protocol (equal probability of measuring Z, X, Y) will be used.| False\n",
314-
"`shadows_bias` | np.ndarray | The bias to be used for the randomized classical shadows measurement protocol, a 1d or 2d array of size 3 or shape (num_qubits, 3) respectively. order is ZXY | np.array([1 / 3, 1 / 3, 1 / 3])\n",
315-
"`max_execution_time` | int or `None` | The maximum execution time on the QPU in seconds. If the runtime exceeds this value, the job will be canceled. If `None`, a default limit set by Qiskit Runtime will apply. | `None`\n",
316-
"`num_randomizations` | int | The number of randomizations to be used for noise learning and gate twirling. | 32\n",
317-
"`max_layers_to_learn` | int | The maximum number of unique layers to learn. | 4\n",
318-
"`mitigate_readout_error` | bool | A Boolean flag indicating whether to perform readout error mitigation or not. | True\n",
319-
"`num_readout_calibration_shots` | int | The number of shots to be used for readout error mitigation. | 10000\n",
320-
"`default_precision` | float | The default precision to be used for the PUBs for which the precision is not specified. |0.02\n",
321-
"`seed` | int or `None` | Set the seed of the random number generator for reproducibility. If `None`, don't set the seed. | None"
325+
"`tem_max_bond_dimension` | int | The maximum bond dimension for the tensor networks. | 128 |\n",
326+
"`tem_compression_cutoff` | float | The cutoff value to be used for the tensor networks. | 1e-10 |\n",
327+
"`compute_shadows_bias_from_observable` | bool | Whether the bias for the classical shadows measurement protocol should be tailored to the PUB observable. If False, the classical shadows protocol (equal probability of measuring Z, X, Y) will be used. | False |\n",
328+
"`shadows_bias` | np.ndarray | The bias to be used for the randomized classical shadows measurement protocol, a 1D or 2D array of size 3 or shape (num_qubits, 3) respectively. Order is ZXY. | np.array([1 / 3, 1 / 3, 1 / 3]) |\n",
329+
"`max_execution_time` | int or None | The maximum execution time on the QPU in seconds. If the runtime exceeds this value, the job will be canceled. If None, the default limit set by Qiskit Runtime will apply. | None |\n",
330+
"`num_randomizations` | int | The number of randomizations to be used for noise learning and gate twirling. | 32 |\n",
331+
"`max_layers_to_learn` | int | The maximum number of unique layers to learn. | 4 |\n",
332+
"`mitigate_readout_error` | bool | Whether to perform readout error mitigation. | True |\n",
333+
"`num_readout_calibration_shots` | int | The number of shots to be used for readout error mitigation. | 10000 |\n",
334+
"`default_precision` | float | The default precision to be used for any PUBs for which the precision is not specified. | 0.05 |\n",
335+
"`default_shots` | int or None | The number of shots to use per PUB. If provided, this overrides the specified precision. Otherwise, the number of shots is estimated to provide the precision requested. | None |\n",
336+
"`seed` | int or None | Set the seed for the random number generator for reproducibility. | None |\n",
337+
"`shots_per_randomization` | int | The total number of shots to use per random learning circuit. | 128 |\n",
338+
"`layer_pair_depths` | list[int] | The circuit depths (measured in number of pairs) to use in learning experiments. | [0, 1, 2, 4, 16, 32] |\n",
339+
"`layer_noise_model` | NoiseLearnerResult, Sequence[LayerError], or None | The precomputed noise learner result from a previously executed run. | None |\n",
340+
"`private` | bool | Whether the QPU jobs should be private. Setting it to True will prevent subsequent downloads of the experiment data and is recommended for confidential jobs. | False |\n",
341+
"`tem_enforce_linear_circuit` | bool | Whether to enforce the circuit to be in linear topology. | False |\n",
342+
"\n",
343+
"#### Precision\n",
344+
"\n",
345+
"The precision of the results can be requested in three ways. The precision can be passed in the PUB, and it will apply to that PUB only. Otherwise, a `default_precision` can be passed in the options as specified above. Finally, for advanced use, the specific number of shots per PUB can be passed in the options with `default_shots`, and it will override any other precision option.\n",
346+
"\n",
347+
"If a `default_precision` or a per-PUB value is passed, the number of shots is estimated in order to achieve the desired precision. This is done based on the chosen QPU parameters and error rates as follows:\n",
348+
"\n",
349+
"- Calculating the error per layered gate (EPLG), which quantifies the noise introduced by layers of two-qubit gates. If backend properties are available, it extracts the relevant fidelity; otherwise, it uses a default value.\n",
350+
"- Counting the number of two-qubit gates in the circuit, as these are typically the main contributors to noise.\n",
351+
"- Computing a noise prefactor based on the number of two-qubit gates and the EPLG.\n",
352+
"- Using the requested precision, it estimates the required number of shots by scaling with the noise prefactor and the inverse of the square of the precision.\n",
353+
"\n",
354+
"This approach ensures that the number of shots is sufficient to achieve the desired precision, taking into account both the circuit structure and the backend's noise characteristics."
322355
]
323356
},
324357
{
@@ -334,7 +367,7 @@
334367
"Name |Type | Description\n",
335368
"-- | -- | --\n",
336369
"data | DataBin | A Qiskit [DataBin](/docs/api/qiskit/qiskit.primitives.DataBin) containing the TEM mitigated observable and its standard error. The DataBin has the following fields: <ul><li>`evs`: The TEM-mitigated observable value.</li><li>`stds`: The standard error of the TEM-mitigated observable.</li></ul>\n",
337-
"metadata | dict | A dictionary containing additional results. The dictionary contains the following keys: <ul><li>`\"evs_non_mitigated\"`: The observable value without error mitigation.</li><li>`\"stds_non_mitigated\"`: The standard error of the result without error mitigation.</li><li>`\"evs_mitigated_no_readout_mitigation\"`: The observable value with error mitigation but without readout error mitigation.</li><li>`\"stds_mitigated_no_readout_mitigation\"`: The standard error of the result with error mitigation but without readout error mitigation.</li><li>`\"evs_non_mitigated_with_readout_mitigation\"`: The observable value without error mitigation but with readout error mitigation.</li><li>`\"stds_non_mitigated_with_readout_mitigation\"`: The standard error of the result without error mitigation but with readout error mitigation.</li></ul>"
370+
"metadata | dict | A dictionary containing additional results. The dictionary contains the following keys: <ul><li>`\"evs_non_mitigated\"`: The observable value without error mitigation.</li><li>`\"stds_non_mitigated\"`: The standard error of the result without error mitigation.</li><li>`\"evs_mitigated_no_readout_mitigation\"`: The observable value with error mitigation but without readout error mitigation.</li><li>`\"stds_mitigated_no_readout_mitigation\"`: The standard error of the result with error mitigation but without readout error mitigation.</li><li>`\"evs_non_mitigated_with_readout_mitigation\"`: The observable value without error mitigation but with readout error mitigation.</li><li>`\"stds_non_mitigated_with_readout_mitigation\"`: The standard error of the result without error mitigation but with readout error mitigation.</li><li>`\"resource_usage\"`: A dictionary containing the time resources used by the TEM. </li></ul>"
338371
]
339372
},
340373
{
@@ -357,7 +390,7 @@
357390
"name": "stdout",
358391
"output_type": "stream",
359392
"text": [
360-
"PrimitiveResult([PubResult(data=DataBin(evs=np.ndarray(<shape=(1,), dtype=float64>), stds=np.ndarray(<shape=(1,), dtype=float64>)), metadata={'evs_non_mitigated': array([-0.01661743]), 'stds_non_mitigated': array([0.05974053]), 'evs_mitigated_no_readout_mitigation': array([-0.01683714]), 'stds_mitigated_no_readout_mitigation': array([0.06033673]), 'evs_non_mitigated_with_readout_mitigation': array([-0.01912836]), 'stds_non_mitigated_with_readout_mitigation': array([0.08066867])})], metadata={'resource_usage': {'RUNNING: OPTIMIZING_FOR_HARDWARE': {'CPU_TIME': 1.026586}, 'RUNNING: WAITING_FOR_QPU': {'CPU_TIME': 1885.478459}, 'RUNNING: POST_PROCESSING': {'CPU_TIME': 10.883811999999999}, 'RUNNING: EXECUTING_QPU': {'QPU_TIME': 158.0}}})\n"
393+
"PrimitiveResult([PubResult(data=DataBin(evs=np.ndarray(<shape=(1,), dtype=float64>), stds=np.ndarray(<shape=(1,), dtype=float64>)), metadata={'evs_non_mitigated': array([0.09305761]), 'stds_non_mitigated': array([0.05499456]), 'evs_mitigated_no_readout_mitigation': array([0.09371257]), 'stds_mitigated_no_readout_mitigation': array([0.05546237]), 'evs_non_mitigated_with_readout_mitigation': array([0.10156985]), 'stds_non_mitigated_with_readout_mitigation': array([0.05788876])})], metadata={'resource_usage': {'RUNNING: OPTIMIZING_FOR_HARDWARE': {'CPU_TIME': 1.018068}, 'RUNNING: WAITING_FOR_QPU': {'CPU_TIME': 411.145994}, 'RUNNING: POST_PROCESSING': {'CPU_TIME': 10.018932999999997}, 'RUNNING: EXECUTING_QPU': {'QPU_TIME': 187.0}}})\n"
361394
]
362395
}
363396
],
@@ -390,10 +423,7 @@
390423
"\n",
391424
"<Admonition type=\"tip\" title=\"Recommendations\">\n",
392425
"\n",
393-
"- [Request access to Algorithmiq Tensor-network error mitigation](https://quantum.cloud.ibm.com/functions?id=algorithmiq-tem)\n",
394-
"- Review [Filippov, S., et al. (2023). Scalable tensor-network error mitigation for near-term quantum computing. arXiv preprint arXiv:2307.11740.](https://arxiv.org/abs/2307.11740)\n",
395-
"- Review [Filippov, S., et al. (2024). Scalability of quantum error mitigation techniques: from utility to advantage. arXiv preprint arXiv:2403.13542.](https://arxiv.org/abs/2403.13542)\n",
396-
"- Review [Fischer, E. F., et al. (2024). Dynamical simulations of many-body quantum chaos on a quantum computer. arXiv preprint arXiv:2411.00765.](https://arxiv.org/abs/2411.00765)\n",
426+
"- [Request access to Algorithmiq Tensor-network error mitigation](https://quantum.ibm.com/functions?id=4b1b9d76-c18b-4788-b70b-15125111fbe6)\n",
397427
"\n",
398428
"</Admonition>"
399429
]

docs/tutorials/_toc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@
166166
{
167167
"title": "Simulate 2D tilted-field Ising with the QESEM function",
168168
"url": "/docs/tutorials/qedma-2d-ising-with-qesem"
169+
},
170+
{
171+
"title": "Simulate a kicked Ising model with the TEM function",
172+
"url": "/docs/tutorials/simulate-kicked-ising-tem"
169173
}
170174
]
171175
},

docs/tutorials/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ Qiskit Functions are a collection of pre-packaged error management and applicati
111111

112112
* [Simulate 2D tilted-field Ising with the QESEM function](/docs/tutorials/qedma-2d-ising-with-qesem)
113113

114+
* [Simulate a kicked Ising model with the TEM function](/docs/tutorials/simulate-kicked-ising-tem)
115+
114116
- Experiment with domain-specific problems with **Application functions** -- with familiar inputs and outputs to classical solvers.
115117

116118
* [Quantum Portfolio Optimizer - A Qiskit Function by Global Data Quantum](/docs/tutorials/global-data-quantum-optimizer)

0 commit comments

Comments
 (0)