iqm-benchmarks 2.17__tar.gz → 2.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of iqm-benchmarks might be problematic. Click here for more details.

Files changed (100) hide show
  1. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/CHANGELOG.rst +4 -0
  2. {iqm_benchmarks-2.17/src/iqm_benchmarks.egg-info → iqm_benchmarks-2.18}/PKG-INFO +1 -1
  3. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/devices/devices.rst +1 -0
  4. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/devices/spark.ipynb +17 -6
  5. iqm_benchmarks-2.18/docs/devices/star.ipynb +543 -0
  6. iqm_benchmarks-2.18/docs/examples/example_qscore.ipynb +824 -0
  7. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/optimization/qscore.py +15 -5
  8. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18/src/iqm_benchmarks.egg-info}/PKG-INFO +1 -1
  9. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm_benchmarks.egg-info/SOURCES.txt +1 -0
  10. iqm_benchmarks-2.18/tests/test_qscore.py +50 -0
  11. iqm_benchmarks-2.17/docs/examples/example_qscore.ipynb +0 -1199
  12. iqm_benchmarks-2.17/tests/test_qscore.py +0 -28
  13. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/.github/workflows/main.yml +0 -0
  14. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/.github/workflows/publish.yml +0 -0
  15. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/.github/workflows/tag_and_release.yml +0 -0
  16. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/.gitignore +0 -0
  17. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/LICENSE +0 -0
  18. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/MANIFEST.in +0 -0
  19. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/README.md +0 -0
  20. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/benchmark_runner.py +0 -0
  21. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docbuild +0 -0
  22. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/API.rst +0 -0
  23. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/Makefile +0 -0
  24. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/_static/images/favicon.ico +0 -0
  25. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/_static/images/logo.png +0 -0
  26. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/_templates/autosummary-class-template.rst +0 -0
  27. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/_templates/autosummary-module-template.rst +0 -0
  28. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/changelog.rst +0 -0
  29. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/conf.py +0 -0
  30. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/development/development.rst +0 -0
  31. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/development/generate_2qubit_cliffords.ipynb +0 -0
  32. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/development/how_to_make_your_own_benchmark.ipynb +0 -0
  33. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_clifford_rb.ipynb +0 -0
  34. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_clops.ipynb +0 -0
  35. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_experiment_all.ipynb +0 -0
  36. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_ghz.ipynb +0 -0
  37. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_ghz_deneb.ipynb +0 -0
  38. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_gst.ipynb +0 -0
  39. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_interleaved_rb.ipynb +0 -0
  40. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_mirror_rb.ipynb +0 -0
  41. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_quantum_volume.ipynb +0 -0
  42. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/example_quantum_volume_deneb.ipynb +0 -0
  43. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/examples/examples.rst +0 -0
  44. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/index.rst +0 -0
  45. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/license.rst +0 -0
  46. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/docs/readme.md +0 -0
  47. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/format +0 -0
  48. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/pyproject.toml +0 -0
  49. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/requirements.txt +0 -0
  50. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/scheduled_experiments/adonis/__init__.py +0 -0
  51. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/scheduled_experiments/adonis/weekly.py +0 -0
  52. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/setup.cfg +0 -0
  53. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/__init__.py +0 -0
  54. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/benchmark.py +0 -0
  55. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/benchmark_definition.py +0 -0
  56. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/circuit_containers.py +0 -0
  57. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/compressive_gst/__init__.py +0 -0
  58. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/compressive_gst/compressive_gst.py +0 -0
  59. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/compressive_gst/gst_analysis.py +0 -0
  60. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/entanglement/__init__.py +0 -0
  61. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/entanglement/ghz.py +0 -0
  62. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/logging_config.py +0 -0
  63. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/optimization/__init__.py +0 -0
  64. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/quantum_volume/__init__.py +0 -0
  65. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/quantum_volume/clops.py +0 -0
  66. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/quantum_volume/quantum_volume.py +0 -0
  67. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/__init__.py +0 -0
  68. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/clifford_1q.pkl +0 -0
  69. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/clifford_2q.pkl +0 -0
  70. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/clifford_rb/__init__.py +0 -0
  71. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/clifford_rb/clifford_rb.py +0 -0
  72. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/interleaved_rb/__init__.py +0 -0
  73. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/interleaved_rb/interleaved_rb.py +0 -0
  74. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/mirror_rb/__init__.py +0 -0
  75. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/mirror_rb/mirror_rb.py +0 -0
  76. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/multi_lmfit.py +0 -0
  77. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/randomized_benchmarking/randomized_benchmarking_common.py +0 -0
  78. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/readout_mitigation.py +0 -0
  79. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm/benchmarks/utils.py +0 -0
  80. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm_benchmarks.egg-info/dependency_links.txt +0 -0
  81. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm_benchmarks.egg-info/requires.txt +0 -0
  82. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/iqm_benchmarks.egg-info/top_level.txt +0 -0
  83. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/LICENSE +0 -0
  84. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/README.md +0 -0
  85. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/additional_fns.py +0 -0
  86. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/algorithm.py +0 -0
  87. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/compatibility.py +0 -0
  88. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/low_level_jit.py +0 -0
  89. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/optimization.py +0 -0
  90. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/qiskit_interface.py +0 -0
  91. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/reporting/figure_gen.py +0 -0
  92. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/src/mGST/reporting/reporting.py +0 -0
  93. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/tag-from-pipeline.sh +0 -0
  94. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/test +0 -0
  95. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/tests/test_ghz.py +0 -0
  96. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/tests/test_gst.py +0 -0
  97. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/tests/test_qv.py +0 -0
  98. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/tests/test_rb.py +0 -0
  99. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/tests/unit/test_benchmark_circuit.py +0 -0
  100. {iqm_benchmarks-2.17 → iqm_benchmarks-2.18}/update-requirements.py +0 -0
@@ -2,6 +2,10 @@
2
2
  Changelog
3
3
  =========
4
4
 
5
+ Version 2.18
6
+ ============
7
+ * Added notebook to benchmark IQM Star QPUs and bug fixes done for Qscore.
8
+
5
9
  Version 2.17
6
10
  ============
7
11
  * Update installation command for development mode. `#41 <https://github.com/iqm-finland/iqm-benchmarks/pull/41>`_
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: iqm-benchmarks
3
- Version: 2.17
3
+ Version: 2.18
4
4
  Summary: A package for implementation of Quantum Characterization, Verification and Validation (QCVV) techniques on IQM's hardware at gate level abstraction
5
5
  Author-email: IQM Finland Oy <developers@meetiqm.com>, Aniket Rath <aniket.rath@meetiqm.com>, Jami Rönkkö <jami@meetiqm.com>, Pedro Figueroa Romero <pedro.romero@meetiqm.com>, Vicente Pina Canelles <vicente.pina@meetiqm.com>, Raphael Brieger <raphael.brieger@meetiqm.com>, Stefan Seegerer <stefan.seegerer@meetiqm.com>, Miikka Koistinen <miikka@meetiqm.com>, Adrian Auer <adrian.auer@meetiqm.com>, Nadia Milazzo <nadia.milazzo@meetiqm.com>
6
6
  Project-URL: Homepage, https://github.com/iqm-finland/iqm-benchmarks
@@ -6,3 +6,4 @@ This section provides examples and guidance on how to benchmark specific IQM dev
6
6
  :maxdepth: 1
7
7
 
8
8
  spark
9
+ star
@@ -49,6 +49,7 @@
49
49
  "source": [
50
50
  "import os\n",
51
51
  "from iqm.qiskit_iqm import IQMProvider\n",
52
+ "import random\n",
52
53
  "\n",
53
54
  "os.environ[\"IQM_TOKENS_FILE\"]=\"YOUR TOKEN HERE\"\n",
54
55
  "iqm_url = 'YOUR URL HERE'\n",
@@ -71,10 +72,17 @@
71
72
  "metadata": {},
72
73
  "outputs": [],
73
74
  "source": [
74
- "from rustworkx.visualization import mpl_draw\n",
75
- "from rustworkx import spring_layout\n",
75
+ "import networkx as nx\n",
76
+ "import matplotlib.pyplot as plt\n",
76
77
  "\n",
77
- "mpl_draw(backend.coupling_map.graph.to_undirected(multigraph=False), arrows=True, with_labels=True, node_color='#32a8a4', pos=spring_layout(backend.coupling_map.graph, num_iter=200))"
78
+ "coupling_map = backend.coupling_map\n",
79
+ "\n",
80
+ "G = nx.Graph()\n",
81
+ "G.add_edges_from(coupling_map) \n",
82
+ "pos = nx.spring_layout(G, seed=42) \n",
83
+ "nx.draw(G, pos, with_labels=True, node_color='lightblue', edge_color='gray', \n",
84
+ " node_size=1000, font_size=10, linewidths=1.5, width=2)\n",
85
+ "plt.show()"
78
86
  ]
79
87
  },
80
88
  {
@@ -640,7 +648,7 @@
640
648
  "QSCORE = QScoreConfiguration(\n",
641
649
  " num_instances = 100,\n",
642
650
  " num_qaoa_layers= 1,\n",
643
- " shots = 2**8,\n",
651
+ " shots = 1000,\n",
644
652
  " calset_id=None, \n",
645
653
  " min_num_nodes = 2,\n",
646
654
  " max_num_nodes = 5,\n",
@@ -652,7 +660,10 @@
652
660
  " [2, 0, 1],\n",
653
661
  " [2, 0, 1, 3],\n",
654
662
  " [2, 0, 1, 3, 4]],\n",
655
- " seed = 1\n",
663
+ " seed = random.randint(1, 999999),\n",
664
+ " REM = True,\n",
665
+ " mit_shots = 1000,\n",
666
+ " qpu_topology = \"crystal\",\n",
656
667
  " )"
657
668
  ]
658
669
  },
@@ -750,7 +761,7 @@
750
761
  "\n",
751
762
  "### QS \n",
752
763
  "obs_qs = result_qscore.observations\n",
753
- "qs = np.argmin([obs_qs[i].value-0.2 for i in range(len(obs_qs)) if obs_qs[i].name == 'approximation_ratio' and obs_qs[i].value-0.2>0])+2\n",
764
+ "qs = np.argmin([obs_qs[i].value-0.2 for i in range(len(obs_qs)) if obs_qs[i].name == 'mean_approximation_ratio' and obs_qs[i].value-0.2>0])+2\n",
754
765
  "\n",
755
766
  "\n",
756
767
  "summary = {'5-qubit GHZ state fidelity': ['≥ 0.5', fidelity],\n",
@@ -0,0 +1,543 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "8665b62277d47a17",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Benchmarking IQM Star"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "afde8699",
14
+ "metadata": {},
15
+ "source": [
16
+ "This notebook allows you to run some useful benchmarks for the Star system."
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "markdown",
21
+ "id": "66ed5587739635b5",
22
+ "metadata": {},
23
+ "source": [
24
+ "## Connect to the backend"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": null,
30
+ "id": "691a27964b11b9ed",
31
+ "metadata": {
32
+ "ExecuteTime": {
33
+ "end_time": "2024-11-26T11:04:54.444032Z",
34
+ "start_time": "2024-11-26T11:04:52.642210Z"
35
+ }
36
+ },
37
+ "outputs": [],
38
+ "source": [
39
+ "import os\n",
40
+ "from iqm.qiskit_iqm import IQMProvider\n",
41
+ "import random\n",
42
+ "\n",
43
+ "QPU = \"deneb\" # or any other star QPU\n",
44
+ "token = \"\"\n",
45
+ "os.environ[\"IQM_TOKEN\"] = token\n",
46
+ "\n",
47
+ "iqm_url = \"https://cocos.resonance.meetiqm.com/\" + QPU\n",
48
+ "provider = IQMProvider(iqm_url)\n",
49
+ "backend = provider.get_backend()"
50
+ ]
51
+ },
52
+ {
53
+ "cell_type": "markdown",
54
+ "id": "06f43ca2",
55
+ "metadata": {},
56
+ "source": [
57
+ "We can access the Star backend and plot its connectivity graph to check that everything is working properly."
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": null,
63
+ "id": "e183e7c5",
64
+ "metadata": {},
65
+ "outputs": [],
66
+ "source": [
67
+ "import networkx as nx\n",
68
+ "import matplotlib.pyplot as plt\n",
69
+ "\n",
70
+ "coupling_map = backend.coupling_map\n",
71
+ "\n",
72
+ "G = nx.Graph()\n",
73
+ "G.add_edges_from(coupling_map) \n",
74
+ "pos = nx.spring_layout(G, seed=42) \n",
75
+ "nx.draw(G, pos, with_labels=True, node_color='lightblue', edge_color='gray', \n",
76
+ " node_size=1000, font_size=10, linewidths=1.5, width=2)\n",
77
+ "plt.show()"
78
+ ]
79
+ },
80
+ {
81
+ "cell_type": "markdown",
82
+ "id": "34c084c2",
83
+ "metadata": {},
84
+ "source": [
85
+ "## As one can see, the label \"0\" is reserved for the resontor. So it is advised to define the qubit indices in the layout of interest starting from 1.\n",
86
+ "\n",
87
+ "We run the cell below to ignore those warnings that are not critical for the correct run of the benchmarks."
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "code",
92
+ "execution_count": null,
93
+ "id": "28154b11",
94
+ "metadata": {},
95
+ "outputs": [],
96
+ "source": [
97
+ "import warnings\n",
98
+ "warnings.filterwarnings(action=\"ignore\") "
99
+ ]
100
+ },
101
+ {
102
+ "cell_type": "markdown",
103
+ "id": "3a5460c0",
104
+ "metadata": {},
105
+ "source": [
106
+ "## GHZ state fidelity"
107
+ ]
108
+ },
109
+ {
110
+ "cell_type": "markdown",
111
+ "id": "42d71982",
112
+ "metadata": {},
113
+ "source": [
114
+ "The GHZ (Greenberger-Horne-Zeilinger) state is a maximally entangled quantum state that involves three or more qubits, $n$. It is an equal superposition of all qubits being in state 0 and all qubits being in state 1, i.e., $| GHZ \\rangle = \\frac{1}{\\sqrt{2}}(|0\\rangle^{\\otimes n}+|1\\rangle^{\\otimes n})$.\n",
115
+ "\n",
116
+ "The GHZ state fidelity acts as a **witness** for genuine multi-qubit entanglement if found to be above $0.5$. This means that the measurement results cannot be explained without entanglement involving **all** qubits, so it is a great way to evaluate the \"quantumness\" of the computer. \n",
117
+ "\n",
118
+ "The state $\\rho_{\\text{ideal}}= |GHZ\\rangle\\langle GHZ|$ is a pure state, so in this case the fidelity can be computed as:\n",
119
+ "\n",
120
+ "$$\n",
121
+ "F(\\text{ideal}, \\text{measured})= \\langle GHZ | \\rho_{\\text{measured}} | GHZ \\rangle,$$\n",
122
+ "\n",
123
+ "where $\\rho_{\\text{measured}}$ is the density matrix given by the actual results of the quantum computer. The ideal GHZ state density matrix entries can be written as $\\rho_{i,j}=\\langle i| \\rho_{\\text{ideal}} | j \\rangle$ where $i,j$ are the $n$ basis states $\\{|00..0\\rangle, ..., |11..1\\rangle\\}$; only the corner entries $\\rho_{0,0},\\rho_{0,n},\\rho_{n,0}$ and $\\rho_{n,n} $ are non-zero. This simplifies the process since we only need to measure these four components. In the fidelity formula, all other entries are effectively nullified by the zero entries in the ideal state matrix. To measure the coherences (off-diagonal entries) we use the method of multiple quantum coherences [Mooney, 2021](https://iopscience.iop.org/article/10.1088/2399-6528/ac1df7/meta). "
124
+ ]
125
+ },
126
+ {
127
+ "cell_type": "code",
128
+ "execution_count": null,
129
+ "id": "55bf7633",
130
+ "metadata": {},
131
+ "outputs": [],
132
+ "source": [
133
+ "from iqm.benchmarks.entanglement.ghz import GHZConfiguration, GHZBenchmark"
134
+ ]
135
+ },
136
+ {
137
+ "cell_type": "code",
138
+ "execution_count": null,
139
+ "id": "29c9dda9",
140
+ "metadata": {},
141
+ "outputs": [],
142
+ "source": [
143
+ "num_qubits = backend.num_qubits\n",
144
+ "chosen_layout = [list(range(1,qubits+1)) for qubits in range(2,num_qubits)]\n",
145
+ "GHZ = GHZConfiguration(\n",
146
+ " state_generation_routine=\"star\",\n",
147
+ " custom_qubits_array=chosen_layout,\n",
148
+ " shots=2000,\n",
149
+ " fidelity_routine=\"coherences\", \n",
150
+ " rem=True,\n",
151
+ " mit_shots=1000,\n",
152
+ ")"
153
+ ]
154
+ },
155
+ {
156
+ "cell_type": "code",
157
+ "execution_count": null,
158
+ "id": "f2d380a8",
159
+ "metadata": {},
160
+ "outputs": [],
161
+ "source": [
162
+ "benchmark_ghz = GHZBenchmark(backend, GHZ)\n",
163
+ "run_ghz = benchmark_ghz.run()"
164
+ ]
165
+ },
166
+ {
167
+ "cell_type": "code",
168
+ "execution_count": null,
169
+ "id": "770f39cb",
170
+ "metadata": {},
171
+ "outputs": [],
172
+ "source": [
173
+ "result_ghz = benchmark_ghz.analyze()\n",
174
+ "result_ghz.plot_all()"
175
+ ]
176
+ },
177
+ {
178
+ "cell_type": "markdown",
179
+ "id": "beb8d573",
180
+ "metadata": {},
181
+ "source": [
182
+ "## Quantum Volume"
183
+ ]
184
+ },
185
+ {
186
+ "cell_type": "markdown",
187
+ "id": "a8451afb",
188
+ "metadata": {},
189
+ "source": [
190
+ "Quantum volume is a single-number metric that was introduced in [Cross, 2019](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.100.032328). It evaluates the quality of a quantum processor via the largest random *square* circuit, i.e., with the same number of layers of parallel random 2-qubit unitaries as number of qubits, that it can run successfully.\n",
191
+ "\n",
192
+ "The success of a run is based on the heavy output probability, which corresponds to the probability of observing *heavy outputs*, i.e. the measurement outputs that occcur with a probability greater than the median of the distribution. The heavy output generation problem asks if the generated distribution of the random circuit we run contains heavy outputs at least 2/3 of the time (on average) with a high confidence level, typically higher than 97.5%. It can be shown that the heavy output probability for an ideal device is at around 0.85 asymptotically. \n",
193
+ "The quantum volume is then defined as\n",
194
+ "\n",
195
+ "$$\\log_2 V_q = \\underset{n}{\\text{argmax}} \\min (n, d(n))$$\n",
196
+ "\n",
197
+ "where $n \\leq N$ is a number of qubits and $d(n)$ is the *achievable depth*, i.e. the largest depth such that we are confident the probability of observing a heavy output is greater than 2/3.\n"
198
+ ]
199
+ },
200
+ {
201
+ "cell_type": "code",
202
+ "execution_count": null,
203
+ "id": "2953c181",
204
+ "metadata": {},
205
+ "outputs": [],
206
+ "source": [
207
+ "from iqm.benchmarks.quantum_volume.quantum_volume import QuantumVolumeConfiguration, QuantumVolumeBenchmark"
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "markdown",
212
+ "id": "aa510035",
213
+ "metadata": {},
214
+ "source": [
215
+ "We define a combination of qubits to test quantum volume on. Due to the star topology, the combinations must not contain the index of the resontor \"0\"."
216
+ ]
217
+ },
218
+ {
219
+ "cell_type": "code",
220
+ "execution_count": null,
221
+ "id": "0a828dca",
222
+ "metadata": {},
223
+ "outputs": [],
224
+ "source": [
225
+ "chosen_layouts = [[1,2,5]] ## choose the optimal layouts to run\n",
226
+ "QV = QuantumVolumeConfiguration(\n",
227
+ " num_circuits=500, \n",
228
+ " shots=2**8,\n",
229
+ " calset_id=None,\n",
230
+ " num_sigmas=2,\n",
231
+ " choose_qubits_routine=\"custom\",\n",
232
+ " custom_qubits_array=chosen_layouts, \n",
233
+ " qiskit_optim_level=3,\n",
234
+ " optimize_sqg=True,\n",
235
+ " max_gates_per_batch=10_000,\n",
236
+ " rem=True,\n",
237
+ " mit_shots=1_000,\n",
238
+ ")"
239
+ ]
240
+ },
241
+ {
242
+ "cell_type": "markdown",
243
+ "id": "f4961b2b",
244
+ "metadata": {},
245
+ "source": [
246
+ "> If you want to modify the settings above, please refer to the documentation [here](https://iqm-finland.github.io/iqm-benchmarks/api/iqm.benchmarks.quantum_volume.quantum_volume.QuantumVolumeConfiguration.html#iqm.benchmarks.quantum_volume.quantum_volume.QuantumVolumeConfiguration)."
247
+ ]
248
+ },
249
+ {
250
+ "cell_type": "markdown",
251
+ "id": "121ddd03",
252
+ "metadata": {},
253
+ "source": [
254
+ "Warning: The following code cell may take few minutes to run since it will compute the benchmark on all the qubit layouts specified above."
255
+ ]
256
+ },
257
+ {
258
+ "cell_type": "code",
259
+ "execution_count": null,
260
+ "id": "4a5abb3d",
261
+ "metadata": {},
262
+ "outputs": [],
263
+ "source": [
264
+ "benchmark_qv = QuantumVolumeBenchmark(backend, QV)\n",
265
+ "run_qv = benchmark_qv.run()"
266
+ ]
267
+ },
268
+ {
269
+ "cell_type": "code",
270
+ "execution_count": null,
271
+ "id": "7d649b35",
272
+ "metadata": {},
273
+ "outputs": [],
274
+ "source": [
275
+ "result_qv = benchmark_qv.analyze()\n",
276
+ "for v in result_qv.plots.values():\n",
277
+ " display(v)"
278
+ ]
279
+ },
280
+ {
281
+ "cell_type": "markdown",
282
+ "id": "bbd2d8a9",
283
+ "metadata": {},
284
+ "source": [
285
+ "## Circuit Layer Operations Per Second (CLOPS)"
286
+ ]
287
+ },
288
+ {
289
+ "cell_type": "markdown",
290
+ "id": "4e659f10",
291
+ "metadata": {},
292
+ "source": [
293
+ "CLOPS is a metric that estimates the speed at which a quantum computer can execute Quantum Volume (QV) layers of a quantum circuit. That is, the circuits to calculate this benchmark have the same structure as the ones used for QV. Here we follow the definition introduced in ([Wack, 2021](https://arxiv.org/abs/2110.14108)), but other versions of this benchmark exist. \n",
294
+ "\n",
295
+ "CLOPS is measured by means of a quantum variational-like protocol, where templates of parametrized QV circuits are assigned random parameters, executed, and outcomes are used as a seed to assign new parameters and repeat the process. The ratio of number of templates ($M$), parameter updates ($K$), measurement shots ($S$) and QV layers ($\\log_2\\mathrm{QV}$) with the time taken to run all, constitutes the CLOPS value: \n",
296
+ "\n",
297
+ "$$\n",
298
+ "\\mathrm{CLOPS}=M\\times{K}\\times{S}\\times\\log_2\\mathrm{QV}/\\mathrm{total\\_time}.\n",
299
+ "$$\n",
300
+ "\n",
301
+ "Notice that the total CLOPS time includes that of assignment of parameters, submission of circuits and retrieval of results."
302
+ ]
303
+ },
304
+ {
305
+ "cell_type": "code",
306
+ "execution_count": null,
307
+ "id": "1e1687c8",
308
+ "metadata": {},
309
+ "outputs": [],
310
+ "source": [
311
+ "from iqm.benchmarks.quantum_volume.clops import CLOPSConfiguration, CLOPSBenchmark, plot_times"
312
+ ]
313
+ },
314
+ {
315
+ "cell_type": "code",
316
+ "execution_count": null,
317
+ "id": "e2c3a156",
318
+ "metadata": {},
319
+ "outputs": [],
320
+ "source": [
321
+ "CLOPS = CLOPSConfiguration(\n",
322
+ " qubits=[1,2,5], # run with the same layout as \n",
323
+ " num_circuits=100,\n",
324
+ " num_updates=10, \n",
325
+ " num_shots=100, \n",
326
+ " calset_id=None,\n",
327
+ " qiskit_optim_level=3,\n",
328
+ " optimize_sqg=True,\n",
329
+ " routing_method=\"sabre\",\n",
330
+ " physical_layout=\"fixed\",\n",
331
+ ")"
332
+ ]
333
+ },
334
+ {
335
+ "cell_type": "markdown",
336
+ "id": "e9f0a8d4",
337
+ "metadata": {},
338
+ "source": [
339
+ "> If you want to modify the settings above, please refer to the documentation [here](https://iqm-finland.github.io/iqm-benchmarks/api/iqm.benchmarks.quantum_volume.clops.CLOPSConfiguration.html#iqm.benchmarks.quantum_volume.clops.CLOPSConfiguration)."
340
+ ]
341
+ },
342
+ {
343
+ "cell_type": "code",
344
+ "execution_count": null,
345
+ "id": "dcd33d91",
346
+ "metadata": {},
347
+ "outputs": [],
348
+ "source": [
349
+ "benchmark_clops = CLOPSBenchmark(backend, CLOPS)\n",
350
+ "run_clops = benchmark_clops.run()"
351
+ ]
352
+ },
353
+ {
354
+ "cell_type": "code",
355
+ "execution_count": null,
356
+ "id": "28d75dac",
357
+ "metadata": {},
358
+ "outputs": [],
359
+ "source": [
360
+ "result_clops = benchmark_clops.analyze()\n",
361
+ "fig_clops = plot_times(result_clops.dataset, result_clops.observations)\n",
362
+ "display(fig_clops[1])"
363
+ ]
364
+ },
365
+ {
366
+ "cell_type": "markdown",
367
+ "id": "4ee1e163",
368
+ "metadata": {},
369
+ "source": [
370
+ "## Q-Score"
371
+ ]
372
+ },
373
+ {
374
+ "cell_type": "markdown",
375
+ "id": "e62cba69",
376
+ "metadata": {},
377
+ "source": [
378
+ "*The Q-score measures the maximum number of qubits that can be used\n",
379
+ "effectively to solve the MaxCut combinatorial optimization problem with the Quantum Approximate\n",
380
+ "Optimization Algorithm* - [Martiel,2021](https://ieeexplore.ieee.org/document/9459509)\n",
381
+ "\n",
382
+ "The graphs chosen for the benchmark are random Erdős-Rényi graphs with 50% edge-probability between nodes.\n",
383
+ "The obtained cost of the solution, i.e. the average number of cut edges, must be above a certain threshold. Specifically, one has to find the cost of a graph to be above $\\beta\\geq 0.2$ on a scale where $\\beta = 0$ corresponds to a random solution and $\\beta = 1$ to an ideal solution. "
384
+ ]
385
+ },
386
+ {
387
+ "cell_type": "code",
388
+ "execution_count": null,
389
+ "id": "036d7839",
390
+ "metadata": {},
391
+ "outputs": [],
392
+ "source": [
393
+ "from iqm.benchmarks.optimization.qscore import QScoreConfiguration, QScoreBenchmark"
394
+ ]
395
+ },
396
+ {
397
+ "cell_type": "code",
398
+ "execution_count": null,
399
+ "id": "22b8116c",
400
+ "metadata": {},
401
+ "outputs": [],
402
+ "source": [
403
+ "num_qubits = backend.num_qubits\n",
404
+ "chosen_layout = [list(range(1,qubits+1)) for qubits in range(1,num_qubits)]\n",
405
+ "QSCORE = QScoreConfiguration(\n",
406
+ " num_instances = 1,\n",
407
+ " num_qaoa_layers= 1,\n",
408
+ " shots = 10000,\n",
409
+ " calset_id=None, \n",
410
+ " min_num_nodes = 2,\n",
411
+ " max_num_nodes = None,\n",
412
+ " use_virtual_node = True,\n",
413
+ " use_classically_optimized_angles = True,\n",
414
+ " choose_qubits_routine = \"custom\",\n",
415
+ " custom_qubits_array=chosen_layout,\n",
416
+ " seed = random.randint(1, 999999),\n",
417
+ " REM = True,\n",
418
+ " mit_shots = 1000,\n",
419
+ " qpu_topology = \"star\",\n",
420
+ " )"
421
+ ]
422
+ },
423
+ {
424
+ "cell_type": "markdown",
425
+ "id": "58813ef0",
426
+ "metadata": {},
427
+ "source": [
428
+ "> If you want to modify the settings above, please refer to the documentation [here](https://iqm-finland.github.io/iqm-benchmarks/api/iqm.benchmarks.optimization.qscore.QScoreConfiguration.html#iqm.benchmarks.optimization.qscore.QScoreConfiguration)."
429
+ ]
430
+ },
431
+ {
432
+ "cell_type": "markdown",
433
+ "id": "c5f14175",
434
+ "metadata": {},
435
+ "source": [
436
+ "Warning: The following code cell may take **several** minutes to run."
437
+ ]
438
+ },
439
+ {
440
+ "cell_type": "code",
441
+ "execution_count": null,
442
+ "id": "aed5ee90",
443
+ "metadata": {},
444
+ "outputs": [],
445
+ "source": [
446
+ "benchmark_qscore = QScoreBenchmark(backend, QSCORE)\n",
447
+ "run_qscore = benchmark_qscore.run()"
448
+ ]
449
+ },
450
+ {
451
+ "cell_type": "code",
452
+ "execution_count": null,
453
+ "id": "0bec0284",
454
+ "metadata": {},
455
+ "outputs": [],
456
+ "source": [
457
+ "result_qscore = benchmark_qscore.analyze()"
458
+ ]
459
+ },
460
+ {
461
+ "cell_type": "code",
462
+ "execution_count": null,
463
+ "id": "619342db",
464
+ "metadata": {},
465
+ "outputs": [],
466
+ "source": [
467
+ "result_qscore.plot_all()"
468
+ ]
469
+ },
470
+ {
471
+ "cell_type": "markdown",
472
+ "id": "70bdb002",
473
+ "metadata": {},
474
+ "source": [
475
+ "## Summary"
476
+ ]
477
+ },
478
+ {
479
+ "cell_type": "code",
480
+ "execution_count": null,
481
+ "id": "d805a3d9",
482
+ "metadata": {},
483
+ "outputs": [],
484
+ "source": [
485
+ "import numpy as np\n",
486
+ "\n",
487
+ "### GHZ\n",
488
+ "obs_ghz = result_ghz.observations\n",
489
+ "fidelity = round(min([obs_ghz[i].value for i in range(len(obs_ghz)) if obs_ghz[i].name=='fidelity']),2)\n",
490
+ "\n",
491
+ "### QV\n",
492
+ "obs_qv = result_qv.observations\n",
493
+ "qv = max([obs_qv[i].value for i in range(len(obs_qv)) if obs_qv[i].name=='QV_result'])\n",
494
+ "\n",
495
+ "### CLOPS\n",
496
+ "obs_clops = result_clops.observations\n",
497
+ "clops = max([obs_clops[item]['clops_v']['value'] for item in obs_clops])\n",
498
+ "\n",
499
+ "### QS \n",
500
+ "obs_qs = result_qscore.observations\n",
501
+ "qs = np.argmin([obs_qs[i].value-0.2 for i in range(len(obs_qs)) if obs_qs[i].name == 'mean_approximation_ratio' and obs_qs[i].value-0.2>0])+2\n",
502
+ "\n",
503
+ "\n",
504
+ "summary = {'GHZ state fidelity': ['≥ 0.5', fidelity],\n",
505
+ " 'Quantum Volume': qv, \n",
506
+ " 'CLOPS': clops, \n",
507
+ " 'Q-Score': qs \n",
508
+ "}\n"
509
+ ]
510
+ },
511
+ {
512
+ "cell_type": "code",
513
+ "execution_count": null,
514
+ "id": "78cf1680",
515
+ "metadata": {},
516
+ "outputs": [],
517
+ "source": [
518
+ "summary"
519
+ ]
520
+ }
521
+ ],
522
+ "metadata": {
523
+ "kernelspec": {
524
+ "display_name": "iqm-benchmarks",
525
+ "language": "python",
526
+ "name": "python3"
527
+ },
528
+ "language_info": {
529
+ "codemirror_mode": {
530
+ "name": "ipython",
531
+ "version": 3
532
+ },
533
+ "file_extension": ".py",
534
+ "mimetype": "text/x-python",
535
+ "name": "python",
536
+ "nbconvert_exporter": "python",
537
+ "pygments_lexer": "ipython3",
538
+ "version": "3.11.11"
539
+ }
540
+ },
541
+ "nbformat": 4,
542
+ "nbformat_minor": 5
543
+ }