iqm-benchmarks 2.2__py3-none-any.whl → 2.4__py3-none-any.whl

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.
@@ -322,11 +322,10 @@ def qv_analysis(run: BenchmarkRunResult) -> BenchmarkAnalysisResult:
322
322
  execution_results[str(qubits)] = xrvariable_to_counts(dataset, str(qubits), num_circuits)
323
323
 
324
324
  # Retrieve other dataset values
325
- dataset_dictionary = dataset.attrs[qubits_idx]
326
- sorted_qc_list_indices = dataset_dictionary["sorted_qc_list_indices"]
327
- qc_list = run.circuits["transpiled_circuits"][str(qubits)].circuits
325
+ sorted_qc_list_indices = dataset.attrs[qubits_idx]["sorted_qc_list_indices"]
326
+ qc_list = run.circuits["untranspiled_circuits"][str(qubits)].circuits
328
327
 
329
- qv_results_type[str(qubits)] = dataset_dictionary["qv_results_type"]
328
+ qv_results_type[str(qubits)] = dataset.attrs[qubits_idx]["qv_results_type"]
330
329
  depth[str(qubits)] = len(qubits)
331
330
 
332
331
  # Simulate the circuits and get the ideal heavy outputs
@@ -358,12 +357,14 @@ def qv_analysis(run: BenchmarkRunResult) -> BenchmarkAnalysisResult:
358
357
 
359
358
  dataset.attrs[qubits_idx].update(
360
359
  {
361
- "sorted_qc_list_indices": (sorted_qc_list_indices if rem or physical_layout == "batching" else None),
362
360
  "cumulative_average_heavy_output_probability": cumulative_hop(qv_result),
363
361
  "cumulative_stddev_heavy_output_probability": cumulative_std(qv_result),
364
362
  "heavy_output_probabilities": qv_result,
365
363
  }
366
364
  )
365
+ # Remove sorted_qc_list_indices from dataset if using physical_layout = "fixed"
366
+ if physical_layout == "fixed" and rem is None:
367
+ del dataset.attrs[qubits_idx]["sorted_qc_list_indices"]
367
368
 
368
369
  fig_name, fig = plot_hop_threshold(
369
370
  qubits,
@@ -384,12 +385,11 @@ def qv_analysis(run: BenchmarkRunResult) -> BenchmarkAnalysisResult:
384
385
  mit_shots = dataset.attrs["mit_shots"]
385
386
  rem_quasidistros = dataset.attrs["REM_quasidistributions"]
386
387
  for qubits_idx, qubits in enumerate(qubit_layouts):
387
- qcvv_logger.info(f"REM post-processing for layout {qubits}")
388
- # Retrieve
389
- dataset_dictionary = dataset.attrs[qubits_idx]
388
+ qcvv_logger.info(f"REM post-processing for layout {qubits} with {mit_shots} shots")
390
389
 
391
- qcvv_logger.info(f"Applying REM with {mit_shots} shots")
392
- sorted_qc_list_indices = dataset_dictionary["sorted_qc_list_indices"]
390
+ # Remove sorted_qc_list_indices from dataset if using physical_layout = "fixed"
391
+ if physical_layout == "fixed":
392
+ del dataset.attrs[qubits_idx]["sorted_qc_list_indices"]
393
393
 
394
394
  qv_result_rem = get_rem_hops(
395
395
  rem_quasidistros[f"REM_quasidist_{str(qubits)}"],
@@ -398,7 +398,6 @@ def qv_analysis(run: BenchmarkRunResult) -> BenchmarkAnalysisResult:
398
398
 
399
399
  dataset.attrs[qubits_idx].update(
400
400
  {
401
- "sorted_qc_list_indices": (sorted_qc_list_indices if physical_layout == "batching" else None),
402
401
  "REM_cumulative_average_heavy_output_probability": cumulative_hop(qv_result_rem),
403
402
  "REM_cumulative_stddev_heavy_output_probability": cumulative_std(qv_result_rem),
404
403
  "REM_heavy_output_probabilities": qv_result_rem,
@@ -14,7 +14,6 @@
14
14
  """M3 modification for readout mitigation at IQM QPU's."""
15
15
  import logging
16
16
  from math import ceil
17
- import sys
18
17
  import threading
19
18
  from typing import Any, Dict, Iterable, List
20
19
  import warnings
@@ -28,6 +27,7 @@ from mthree.utils import final_measurement_mapping
28
27
  from qiskit import transpile # pylint: disable = no-name-in-module
29
28
  from qiskit.providers import Backend, BackendV1, BackendV2
30
29
 
30
+ from iqm.benchmarks.logging_config import qcvv_logger
31
31
  from iqm.benchmarks.utils import get_iqm_backend, timeit
32
32
  from iqm.qiskit_iqm import IQMCircuit as QuantumCircuit
33
33
  from iqm.qiskit_iqm.iqm_backend import IQMBackendBase
@@ -220,7 +220,7 @@ class M3IQM(mthree.M3Mitigation):
220
220
  calibration_set_id=cal_id,
221
221
  )
222
222
  jobs.append(_job)
223
- print(f"{len(circs)} calibration circuits ready to be executed!")
223
+ qcvv_logger.info(f"REM: {len(circs)} calibration circuits to be executed!")
224
224
 
225
225
  # Execute job and cal building in new thread.
226
226
  self._job_error = None
@@ -265,11 +265,8 @@ def apply_readout_error_mitigation(
265
265
  Returns:
266
266
  tuple[Any, Any] | tuple[QuasiCollection, list] | QuasiCollection: a list of dictionaries with REM-corrected quasiprobabilities for each outcome.
267
267
  """
268
- # M3IQM uses mthree.mitigation, which for some reason displays many INFO messages
269
- # Not sure if this is the best way to suppress them; MODIFY IF NECESSARY !
270
- warnings.warn("Suppressing INFO messages from M3IQM with logging.disable(sys.maxsize) - update if problematic!")
271
- logging.disable(sys.maxsize)
272
-
268
+ # M3IQM uses mthree.mitigation, which for some reason displays way too many INFO messages
269
+ logging.getLogger().setLevel(logging.WARN)
273
270
  if isinstance(backend_arg, str):
274
271
  backend = get_iqm_backend(backend_arg)
275
272
  else:
@@ -282,5 +279,6 @@ def apply_readout_error_mitigation(
282
279
  mit.cals_from_system(qubits_rem, shots=mit_shots)
283
280
  # Apply the REM correction to the given measured counts
284
281
  rem_quasidistro = [mit.apply_correction(c, q) for c, q in zip(counts, qubits_rem)]
282
+ logging.getLogger().setLevel(logging.INFO)
285
283
 
286
284
  return rem_quasidistro
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iqm-benchmarks
3
- Version: 2.2
3
+ Version: 2.4
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>
6
6
  Project-URL: Homepage, https://github.com/iqm-finland/iqm-benchmarks
@@ -1,10 +1,9 @@
1
1
  iqm/benchmarks/__init__.py,sha256=sAS6OKctANSzgVUEUWugQs9mcKwG9KOTBEsbSYGxtPc,2201
2
2
  iqm/benchmarks/benchmark.py,sha256=SGhBcSxLPUu-cVXAjG4Db2TRobFCRBYoE1NtTDK1lJg,4432
3
3
  iqm/benchmarks/benchmark_definition.py,sha256=AZkvANrf0_0glbq_P_uo_YqbBU9IZa2gJlMVz6qT6VU,10500
4
- iqm/benchmarks/benchmark_experiment.py,sha256=ynbsQS92v6soIgkDEdm3ygNO7f82-dhg7qB1l8jvSFM,6614
5
4
  iqm/benchmarks/circuit_containers.py,sha256=anEtZEsodYqOX-34oZRmuKGeEpp_VfgG5045Mz4-4hI,7562
6
5
  iqm/benchmarks/logging_config.py,sha256=U7olP5Kr75AcLJqNODf9VBhJLVqIvA4AYR6J39D5rww,1052
7
- iqm/benchmarks/readout_mitigation.py,sha256=6lWtDyc0-3WMtVrlwsbC60Ba_xaCDblzdKc34nBbPXg,12327
6
+ iqm/benchmarks/readout_mitigation.py,sha256=7FlbSH-RJTtQuRYLChwkQV_vBv0ZfMQTH519cAbyxQ4,12252
8
7
  iqm/benchmarks/utils.py,sha256=BNbPeNNiFfE72Y-coVjLK3O7y7-j1Ag-l_qyBQsxXRY,20278
9
8
  iqm/benchmarks/compressive_gst/__init__.py,sha256=4F_5YxExn4ysGQaEs-WNfm0yiFBxkKtGAYBZFWnRsSk,915
10
9
  iqm/benchmarks/compressive_gst/compressive_gst.py,sha256=pzkqFQQXEZZJmQgwyLo2_eF3rcK3BwXAj5QfY4poczY,21206
@@ -12,10 +11,10 @@ iqm/benchmarks/compressive_gst/gst_analysis.py,sha256=qaF9zDIadPGe9I0l_SC3EfnODZ
12
11
  iqm/benchmarks/entanglement/__init__.py,sha256=9T7prOwqMmFWdb4t6ETAHZXKK5o6FvU2DvVb6WhNi-U,682
13
12
  iqm/benchmarks/entanglement/ghz.py,sha256=qg6mw1RydosKdc2KoPi6M3q0Ek7eMBPIkWOJC2ZDx8M,39446
14
13
  iqm/benchmarks/optimization/__init__.py,sha256=_ajW_OibYLCtzU5AUv5c2zuuVYn8ZNeZUcUUSIGt51M,747
15
- iqm/benchmarks/optimization/qscore.py,sha256=pTDRrNI2kkujqb5IoaPTiq9MS8OZd9M8Gv0G2Jn3Ka0,28078
14
+ iqm/benchmarks/optimization/qscore.py,sha256=6I13YbFvFq1RcX4mYTw6S4ALb4Ix9t7gjlRzZbaTARM,34038
16
15
  iqm/benchmarks/quantum_volume/__init__.py,sha256=i-Q4SpDWELBw7frXnxm1j4wJRcxbIyrS5uEK_v06YHo,951
17
16
  iqm/benchmarks/quantum_volume/clops.py,sha256=j6BPEj1rKBAHigox7nrvaTLyb4iCrHadBl2d1yiETDA,30956
18
- iqm/benchmarks/quantum_volume/quantum_volume.py,sha256=8UHDyw1aVXnmo9DpK_qGcfa_NLS148a2YdYNDS4NE78,36870
17
+ iqm/benchmarks/quantum_volume/quantum_volume.py,sha256=PPg1kZA5Lx9b24iFVgP_VcgymI6CsD5LfB5Ppfk8TBM,36814
19
18
  iqm/benchmarks/randomized_benchmarking/__init__.py,sha256=IkKo-7zUChxZZd3my_csQCJfJfZNsV3-JTvdG8uqys4,734
20
19
  iqm/benchmarks/randomized_benchmarking/clifford_1q.pkl,sha256=vvSd0pRWxtzyirohO9yf_58mjevkc2-pbuWIEb-4gaw,46928
21
20
  iqm/benchmarks/randomized_benchmarking/clifford_2q.pkl,sha256=ZipqU3crPhz2T35qGFgB4GvMyoi_7pnu8NqW5ZP8NXg,90707258
@@ -37,8 +36,8 @@ mGST/optimization.py,sha256=YHwkzIkYvsZOPjclR-BCQWh24jeqjuXp0BB0WX5Lwow,10559
37
36
  mGST/qiskit_interface.py,sha256=L4H-4SdhP_bjSFFvpQoF1E7EyGbIJ_CI_y4a7_YEwmU,10102
38
37
  mGST/reporting/figure_gen.py,sha256=6Xd8vwfy09hLY1YbJY6TRevuMsQSU4MsWqemly3ZO0I,12970
39
38
  mGST/reporting/reporting.py,sha256=-XBy3OCJIMOsA8cApwKjhVKBwnjSAoxm-voHNbRWytM,25803
40
- iqm_benchmarks-2.2.dist-info/LICENSE,sha256=2Ncb40-hqkTil78RPv3-YiJfKaJ8te9USJgliKqIdSY,11558
41
- iqm_benchmarks-2.2.dist-info/METADATA,sha256=OYot1WoGYKIbfRdSkf_eyho1lRnJLbUDQ6uR_c_2QD8,9103
42
- iqm_benchmarks-2.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
43
- iqm_benchmarks-2.2.dist-info/top_level.txt,sha256=3G23Z-1LGf-IOzTCUl6QwWqiQ3USz25Zt90Ihq192to,9
44
- iqm_benchmarks-2.2.dist-info/RECORD,,
39
+ iqm_benchmarks-2.4.dist-info/LICENSE,sha256=2Ncb40-hqkTil78RPv3-YiJfKaJ8te9USJgliKqIdSY,11558
40
+ iqm_benchmarks-2.4.dist-info/METADATA,sha256=Z-c61lqfGdVvhQmYjB7olZYAJyd9pbA7thPWahqFy4E,9103
41
+ iqm_benchmarks-2.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
42
+ iqm_benchmarks-2.4.dist-info/top_level.txt,sha256=3G23Z-1LGf-IOzTCUl6QwWqiQ3USz25Zt90Ihq192to,9
43
+ iqm_benchmarks-2.4.dist-info/RECORD,,
@@ -1,163 +0,0 @@
1
- # Copyright 2024 IQM Benchmarks developers
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """
16
- Generic Benchmark Experiment class
17
- """
18
-
19
- from copy import deepcopy
20
- from json import dump
21
- from pathlib import Path
22
- import pickle
23
- from time import strftime
24
- from typing import List, Optional, OrderedDict, Union
25
-
26
- from iqm.benchmarks.benchmark import BenchmarkBase, BenchmarkConfigurationBase
27
- from iqm.benchmarks.logging_config import qcvv_logger
28
- from iqm.benchmarks.utils import get_iqm_backend
29
- from iqm.qiskit_iqm.iqm_backend import IQMBackendBase
30
-
31
-
32
- class BenchmarkExperiment:
33
- """
34
- A Benchmark Experiment wraps the execution of one or more benchmarks, checks their requirements are met, stores the
35
- execution results and plots relevant figures.
36
- """
37
-
38
- def __init__(
39
- self,
40
- backend: Union[str, IQMBackendBase],
41
- benchmark_configurations: List[BenchmarkConfigurationBase],
42
- device_id: Optional[str] = None,
43
- ):
44
- """Construct the BenchmarkExperiment class.
45
-
46
- Args:
47
- backend (str | IQMBackendBase): the backend to execute the benchmarks on
48
- benchmark_configurations (List[BenchmarkConfigurationBase]): the configuration(s) of the benchmark(s)
49
- device_id (Optional[str], optional): the identifier of the device. Defaults to None.
50
-
51
- Raises:
52
- ValueError: backend not supported. Try 'garnet' or 'iqmfakeadonis'
53
- """
54
- self.timestamp = strftime("%Y%m%d-%H%M%S")
55
-
56
- if isinstance(backend, str):
57
- self.backend = get_iqm_backend(backend)
58
- else:
59
- assert isinstance(backend, IQMBackendBase)
60
- self.backend = backend
61
-
62
- self.device_id = device_id if device_id is not None else self.backend.name
63
-
64
- benchmarks: OrderedDict[str, BenchmarkBase] = OrderedDict(
65
- (config.benchmark.name(), config.benchmark(self.backend, config)) for config in benchmark_configurations
66
- )
67
-
68
- for benchmark in benchmarks.values():
69
- benchmarks_copy = deepcopy(benchmarks)
70
- benchmarks_copy = benchmark.check_requirements(benchmarks_copy)
71
- self.benchmarks = benchmarks_copy
72
-
73
- def run_experiment(self) -> None:
74
- """Run the Benchmark experiment, and store the configuration, raw data, results and figures."""
75
-
76
- for name, benchmark in self.benchmarks.items():
77
- qcvv_logger.info("\nNow executing " + name)
78
- # Create the directory for results
79
- results_dir = f"Outputs/{self.device_id}/{self.timestamp}/{name}/"
80
- Path(results_dir).mkdir(parents=True, exist_ok=True)
81
-
82
- # Execute the current benchmark
83
- benchmark.generate_requirements(self.benchmarks)
84
- benchmark.execute_full_benchmark()
85
-
86
- # Create configuration JSON file
87
- with open(
88
- f"{results_dir}{self.device_id}_{self.timestamp}_{name}_configuration.json",
89
- "w",
90
- encoding="utf-8",
91
- ) as f_configuration:
92
- dump(benchmark.serializable_configuration.model_dump(), f_configuration)
93
-
94
- # Create untranspiled circuit files
95
- if benchmark.untranspiled_circuits:
96
- for key_qubits in benchmark.untranspiled_circuits.keys():
97
- for key_depth in benchmark.untranspiled_circuits[key_qubits].keys():
98
- with open(
99
- f"{results_dir}{self.device_id}_{self.timestamp}_{name}_qubits_{key_qubits}_depth_{key_depth}_untranspiled.pkl",
100
- "wb",
101
- ) as f_circuits:
102
- pickle.dump(
103
- benchmark.untranspiled_circuits[key_qubits][key_depth],
104
- f_circuits,
105
- )
106
-
107
- # Create transpiled circuit files
108
- for key_qubits in benchmark.transpiled_circuits.keys():
109
- for key_depth in benchmark.transpiled_circuits[key_qubits].keys():
110
- with open(
111
- f"{results_dir}{self.device_id}_{self.timestamp}_{name}_qubits_{key_qubits}_depth_{key_depth}_transpiled.pkl",
112
- "wb",
113
- ) as f_circuits:
114
- pickle.dump(
115
- benchmark.transpiled_circuits[key_qubits][key_depth],
116
- f_circuits,
117
- )
118
-
119
- # Create raw result pickle files
120
- with open(
121
- f"{results_dir}{self.device_id}_{self.timestamp}_{name}_raw_results.pkl",
122
- "wb",
123
- ) as f_raw_results:
124
- pickle.dump(
125
- benchmark.raw_results,
126
- f_raw_results,
127
- )
128
-
129
- # Create raw data JSON file
130
- with open(
131
- f"{results_dir}{self.device_id}_{self.timestamp}_{name}_raw_data.json",
132
- "w",
133
- encoding="utf-8",
134
- ) as f_raw_data:
135
- dump(benchmark.raw_data, f_raw_data)
136
-
137
- # Create job metadata JSON file
138
- with open(
139
- f"{results_dir}{self.device_id}_{self.timestamp}_{name}_job_metadata.json",
140
- "w",
141
- encoding="utf-8",
142
- ) as f_job_metadata:
143
- dump(benchmark.job_meta, f_job_metadata)
144
-
145
- # Create results JSON file
146
- with open(
147
- f"{results_dir}{self.device_id}_{self.timestamp}_{name}_results.json",
148
- "w",
149
- encoding="utf-8",
150
- ) as f_results:
151
- dump(benchmark.results, f_results)
152
-
153
- # Create figures
154
- Path(f"{results_dir}figures/").mkdir(parents=True, exist_ok=True)
155
- for fig_name, fig in benchmark.figures.items():
156
- fig.savefig(
157
- f"{results_dir}figures/{self.device_id}_{self.timestamp}_{name}_{fig_name}",
158
- dpi=250,
159
- bbox_inches="tight",
160
- )
161
-
162
- # Save benchmark
163
- self.benchmarks[benchmark.name()] = benchmark