iqm-benchmarks 2.3__py3-none-any.whl → 2.5__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.

Potentially problematic release.


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

@@ -10,8 +10,8 @@ import warnings
10
10
 
11
11
  import numpy as np
12
12
  from qiskit import transpile
13
- from qiskit.quantum_info import random_clifford, random_pauli
14
- from qiskit_aer import Aer
13
+ from qiskit.quantum_info import Clifford, random_clifford, random_pauli
14
+ from qiskit_aer import Aer, AerSimulator
15
15
  from scipy.spatial.distance import hamming
16
16
  import xarray as xr
17
17
 
@@ -262,9 +262,13 @@ def generate_pauli_dressed_mrb_circuits(
262
262
  pauli_dressed_circuits_untranspiled: List[QuantumCircuit] = []
263
263
  pauli_dressed_circuits_transpiled: List[QuantumCircuit] = []
264
264
 
265
+ sim_method = "stabilizer"
266
+ simulator = AerSimulator(method=sim_method)
267
+
265
268
  for _ in range(pauli_samples_per_circ):
266
269
  # Initialize the quantum circuit object
267
270
  circ = QuantumCircuit(num_qubits)
271
+ circ_untransp = QuantumCircuit(num_qubits)
268
272
  # Sample all the random Paulis
269
273
  paulis = [random_pauli(num_qubits) for _ in range(depth + 1)]
270
274
 
@@ -282,6 +286,7 @@ def generate_pauli_dressed_mrb_circuits(
282
286
  )
283
287
  circ.barrier()
284
288
  circ.compose(cycle_layers[k], inplace=True)
289
+ circ_untransp.compose(cycle_layers[k], inplace=True)
285
290
  circ.barrier()
286
291
 
287
292
  # Apply middle Pauli
@@ -307,9 +312,6 @@ def generate_pauli_dressed_mrb_circuits(
307
312
  for i in range(num_qubits):
308
313
  circ.compose(clifford_layer[i].to_instruction().inverse(), qubits=[i], inplace=True)
309
314
 
310
- # Add measurements
311
- circ.measure_all()
312
-
313
315
  # Transpile to backend - no optimize SQG should be used!
314
316
  if isinstance(backend_arg, str):
315
317
  retrieved_backend = get_iqm_backend(backend_arg)
@@ -317,6 +319,13 @@ def generate_pauli_dressed_mrb_circuits(
317
319
  assert isinstance(backend_arg, IQMBackendBase)
318
320
  retrieved_backend = backend_arg
319
321
 
322
+ circ_untransp = circ.copy()
323
+ # Add measurements to untranspiled - after!
324
+ circ_untranspiled = transpile(Clifford(circ_untransp).to_circuit(), simulator)
325
+ circ_untranspiled.measure_all()
326
+
327
+ # Add measurements to transpiled - before!
328
+ circ.measure_all()
320
329
  circ_transpiled = transpile(
321
330
  circ,
322
331
  backend=retrieved_backend,
@@ -325,7 +334,7 @@ def generate_pauli_dressed_mrb_circuits(
325
334
  routing_method=routing_method,
326
335
  )
327
336
 
328
- pauli_dressed_circuits_untranspiled.append(circ)
337
+ pauli_dressed_circuits_untranspiled.append(circ_untranspiled)
329
338
  pauli_dressed_circuits_transpiled.append(circ_transpiled)
330
339
 
331
340
  # Store the circuit
@@ -418,14 +427,14 @@ def mrb_analysis(run: BenchmarkRunResult) -> BenchmarkAnalysisResult:
418
427
  observations = {}
419
428
  dataset = run.dataset.copy(deep=True)
420
429
 
421
- shots = dataset.attrs["shots"]
430
+ # shots = dataset.attrs["shots"]
422
431
  num_circuit_samples = dataset.attrs["num_circuit_samples"]
423
432
  num_pauli_samples = dataset.attrs["num_pauli_samples"]
424
433
 
425
434
  density_2q_gates = dataset.attrs["density_2q_gates"]
426
435
  two_qubit_gate_ensemble = dataset.attrs["two_qubit_gate_ensemble"]
427
436
 
428
- max_gates_per_batch = dataset.attrs["max_gates_per_batch"]
437
+ # max_gates_per_batch = dataset.attrs["max_gates_per_batch"]
429
438
 
430
439
  # Analyze the results for each qubit layout of the experiment dataset
431
440
  qubits_array = dataset.attrs["qubits_array"]
@@ -445,8 +454,9 @@ def mrb_analysis(run: BenchmarkRunResult) -> BenchmarkAnalysisResult:
445
454
  else:
446
455
  assigned_mrb_depths = {str(qubits_array[i]): [2 * m for m in depths_array[i]] for i in range(len(depths_array))}
447
456
 
448
- transpiled_circuits = run.circuits["transpiled_circuits"]
449
- simulator = Aer.get_backend("qasm_simulator")
457
+ mrb_sim_circuits = run.circuits["untranspiled_circuits"]
458
+ sim_method = "stabilizer"
459
+ simulator = AerSimulator(method=sim_method) # Aer.get_backend("stabilizer")
450
460
 
451
461
  all_noisy_counts: Dict[str, Dict[int, List[Dict[str, int]]]] = {}
452
462
  all_noiseless_counts: Dict[str, Dict[int, List[Dict[str, int]]]] = {}
@@ -465,22 +475,12 @@ def mrb_analysis(run: BenchmarkRunResult) -> BenchmarkAnalysisResult:
465
475
  all_noisy_counts[str(qubits)][depth] = xrvariable_to_counts(
466
476
  dataset, identifier, num_circuit_samples * num_pauli_samples
467
477
  )
468
-
469
478
  qcvv_logger.info(f"Depth {depth}")
470
- # Execute the quantum circuits on the simulated, ideal backend
471
- # pylint: disable=unbalanced-tuple-unpacking
472
- all_noiseless_jobs, _ = submit_execute(
473
- {tuple(qubits): transpiled_circuits[f"{str(qubits)}_depth_{str(depth)}"].circuits},
474
- simulator,
475
- shots,
476
- calset_id=None,
477
- max_gates_per_batch=max_gates_per_batch,
478
- )
479
479
 
480
- # Retrieve counts
481
- all_noiseless_counts[str(qubits)][depth], time_retrieve_noiseless[str(qubits)][depth] = retrieve_all_counts(
482
- all_noiseless_jobs
483
- )
480
+ mrb_circs = mrb_sim_circuits[f"{str(qubits)}_depth_{str(depth)}"].circuits
481
+
482
+ qcvv_logger.info("Getting simulation counts")
483
+ all_noiseless_counts[str(qubits)][depth] = simulator.run(mrb_circs).result().get_counts()
484
484
 
485
485
  # Compute polarizations for the current depth
486
486
  polarizations[depth] = compute_polarizations(
@@ -695,7 +695,7 @@ class MirrorRandomizedBenchmarking(Benchmark):
695
695
  mrb_untranspiled_circuits_lists: Dict[int, List[QuantumCircuit]] = {}
696
696
  time_circuit_generation[str(qubits)] = 0
697
697
  for depth in assigned_mrb_depths[str(qubits)]:
698
- qcvv_logger.info(f"Depth {depth}")
698
+ qcvv_logger.info(f"Depth {depth} - Generating all circuits")
699
699
  mrb_circuits[depth], elapsed_time = generate_fixed_depth_mrb_circuits(
700
700
  qubits,
701
701
  self.num_circuit_samples,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iqm-benchmarks
3
- Version: 2.3
3
+ Version: 2.5
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,7 +1,6 @@
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
6
  iqm/benchmarks/readout_mitigation.py,sha256=7FlbSH-RJTtQuRYLChwkQV_vBv0ZfMQTH519cAbyxQ4,12252
@@ -12,7 +11,7 @@ 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
17
  iqm/benchmarks/quantum_volume/quantum_volume.py,sha256=PPg1kZA5Lx9b24iFVgP_VcgymI6CsD5LfB5Ppfk8TBM,36814
@@ -26,7 +25,7 @@ iqm/benchmarks/randomized_benchmarking/clifford_rb/clifford_rb.py,sha256=q8bHcrV
26
25
  iqm/benchmarks/randomized_benchmarking/interleaved_rb/__init__.py,sha256=sq6MgN_hwlpkOj10vyCU4e6eKSX-oLcF2L9na6W2Gt4,681
27
26
  iqm/benchmarks/randomized_benchmarking/interleaved_rb/interleaved_rb.py,sha256=PlHn1J8VPaJF5csNH8jxcifz_MdisOEPU54kU-FYoLY,26920
28
27
  iqm/benchmarks/randomized_benchmarking/mirror_rb/__init__.py,sha256=ZekEqI_89nXzGO1vjM-b5Uwwicy59M4fYHXfA-f0MIg,674
29
- iqm/benchmarks/randomized_benchmarking/mirror_rb/mirror_rb.py,sha256=kYlcH0uFdFZmZhkPPEliUTftfDTpefjFdlTgDDo_NXM,33819
28
+ iqm/benchmarks/randomized_benchmarking/mirror_rb/mirror_rb.py,sha256=AmPAp80wWc_6ao4OMZBUNGX0_WlSnz9utN4436ZcjJ0,33990
30
29
  mGST/LICENSE,sha256=TtHNq55cUcbglb7uhVudeBLUh_qPdUoAEvU0BBwFz-k,1098
31
30
  mGST/README.md,sha256=v_5kw253csHF4-RfE-44KqFmBXIsSMRmOtN0AUPrRxE,5050
32
31
  mGST/additional_fns.py,sha256=_SEJ10FRNM7_CroysT8hCLZTfpm6ZhEIDCY5zPTnhjo,31390
@@ -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.3.dist-info/LICENSE,sha256=2Ncb40-hqkTil78RPv3-YiJfKaJ8te9USJgliKqIdSY,11558
41
- iqm_benchmarks-2.3.dist-info/METADATA,sha256=9X5g_7kRRtPKs581ILEaU7C00SDdWERCXjoa_OCi4Jw,9103
42
- iqm_benchmarks-2.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
43
- iqm_benchmarks-2.3.dist-info/top_level.txt,sha256=3G23Z-1LGf-IOzTCUl6QwWqiQ3USz25Zt90Ihq192to,9
44
- iqm_benchmarks-2.3.dist-info/RECORD,,
39
+ iqm_benchmarks-2.5.dist-info/LICENSE,sha256=2Ncb40-hqkTil78RPv3-YiJfKaJ8te9USJgliKqIdSY,11558
40
+ iqm_benchmarks-2.5.dist-info/METADATA,sha256=c3KkSGEMw7ux1jcjbN4k-JU-hNfQSLcg8TOfQZb2npo,9103
41
+ iqm_benchmarks-2.5.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
42
+ iqm_benchmarks-2.5.dist-info/top_level.txt,sha256=3G23Z-1LGf-IOzTCUl6QwWqiQ3USz25Zt90Ihq192to,9
43
+ iqm_benchmarks-2.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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