iqm-benchmarks 2.51__py3-none-any.whl → 2.52__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.
@@ -25,7 +25,7 @@ import matplotlib.pyplot as plt
25
25
  import networkx
26
26
  from networkx import Graph, all_pairs_shortest_path, is_connected, minimum_spanning_tree
27
27
  import numpy as np
28
- from qiskit import QuantumRegister
28
+ from qiskit import ClassicalRegister, QuantumRegister
29
29
  from qiskit.quantum_info import random_clifford
30
30
  from qiskit.transpiler import CouplingMap
31
31
  from qiskit_aer import Aer
@@ -55,6 +55,7 @@ from iqm.benchmarks.utils import (
55
55
  xrvariable_to_counts,
56
56
  )
57
57
  from iqm.qiskit_iqm import IQMCircuit as QuantumCircuit
58
+ from iqm.qiskit_iqm import transpile_to_IQM
58
59
  from iqm.qiskit_iqm.iqm_backend import IQMBackendBase
59
60
 
60
61
 
@@ -304,6 +305,74 @@ def generate_ghz_log_cruz(num_qubits: int) -> QuantumCircuit:
304
305
  return qc
305
306
 
306
307
 
308
+ ## can introduce another fucntion to time order here CZ and pick the best MOVE qubit.
309
+
310
+
311
+ def generate_ghz_star_optimal(
312
+ qubit_layout: List[int], cal_url: str, backend: IQMBackendBase, inv: bool = False
313
+ ) -> QuantumCircuit:
314
+ """
315
+ Generates the circuit for creating a GHZ state by maximizing the number of CZ gates between a pair of MOVE gates.
316
+
317
+ Args:
318
+ qubit_layout: List[int]
319
+ The layout of qubits for the GHZ state.
320
+ cal_url: str
321
+ The calibration URL for extracting fidelities.
322
+ backend: IQMBackendBase
323
+ The backend to be used for the quantum circuit.
324
+ inv: bool
325
+ Whether to generate the inverse circuit.
326
+
327
+ Returns:
328
+ QuantumCircuit: A quantum circuit generating a GHZ state on a given number of qubits.
329
+ """
330
+ num_qubits = len(qubit_layout)
331
+
332
+ # Initialize quantum and classical registers
333
+ comp_r = QuantumRegister(1, "comp_r") # Computational resonator
334
+ q = QuantumRegister(backend.num_qubits, "q") # Qubits
335
+ c = ClassicalRegister(num_qubits, "c")
336
+ qc = QuantumCircuit(comp_r, q, c, name="GHZ_star_optimal")
337
+
338
+ cal_data = extract_fidelities(cal_url, all_metrics=True)
339
+ # Determine the best move qubit
340
+ move_dict = {q + 1: cal_data[1][q] for q in qubit_layout} ## +1 to match qubit indexing in cal data
341
+ best_move = max(move_dict, key=move_dict.get)
342
+
343
+ T2 = cal_data[-1]["t2_echo_time"]
344
+ t2_dict = {qubit + 1: T2[qubit + 1] for qubit in qubit_layout} ## +1 to match qubit indexing in cal data
345
+ cz_order = dict(sorted(t2_dict.items(), key=lambda item: item[1], reverse=True))
346
+ qubits_to_measure = list(cz_order.keys())
347
+ cz_order.pop(best_move)
348
+
349
+ # Construct the quantum circuit
350
+ qc.h(best_move)
351
+ qc.move(best_move, 0)
352
+ for qubit in cz_order.keys():
353
+ qc.cx(0, qubit)
354
+ qc.barrier()
355
+ qc.move(best_move, 0)
356
+ qc.barrier()
357
+ qc.measure(sorted(qubits_to_measure), list(range(num_qubits)))
358
+
359
+ if inv:
360
+ comp_r = QuantumRegister(1, "comp_r") # Computational resonator
361
+ q = QuantumRegister(backend.num_qubits, "q") # Qubits
362
+ c = ClassicalRegister(num_qubits, "c")
363
+ qc = QuantumCircuit(comp_r, q, c, name="GHZ_star_optimal_inv")
364
+
365
+ qc.move(best_move, 0)
366
+ for qubit in reversed(cz_order.keys()):
367
+ qc.cx(0, qubit)
368
+ qc.barrier()
369
+ qc.move(best_move, 0)
370
+ qc.h(best_move)
371
+ qc.barrier()
372
+
373
+ return qc
374
+
375
+
307
376
  def generate_ghz_star(num_qubits: int) -> QuantumCircuit:
308
377
  """
309
378
  Generates the circuit for creating a GHZ state by maximizing the number of CZ gates between a pair of MOVE gates.
@@ -648,7 +717,20 @@ class GHZBenchmark(Benchmark):
648
717
  optimize_sqg=self.optimize_sqg,
649
718
  )
650
719
  final_ghz = ghz_native_transpiled
651
-
720
+ elif routine == "star_optimal":
721
+ if self.cal_url is None:
722
+ raise ValueError("Calibration URL must be provided for 'star_optimal' routine.")
723
+ ghz = generate_ghz_star_optimal(qubit_layout, self.cal_url, self.backend)
724
+ circuit_group.add_circuit(ghz)
725
+ ghz_native_transpiled = transpile_to_IQM(
726
+ ghz,
727
+ self.backend,
728
+ existing_moves_handling=True,
729
+ perform_move_routing=False,
730
+ optimize_single_qubits=self.optimize_sqg,
731
+ optimization_level=self.qiskit_optim_level,
732
+ )
733
+ final_ghz = [ghz_native_transpiled]
652
734
  else:
653
735
  ghz_log = [generate_ghz_log_cruz(qubit_count), generate_ghz_log_mooney(qubit_count)]
654
736
  ghz_native_transpiled, _ = perform_backend_transpilation(
@@ -691,27 +773,54 @@ class GHZBenchmark(Benchmark):
691
773
 
692
774
  qc = qc_list[0].copy()
693
775
  qc.remove_final_measurements()
694
- qc_inv = qc.inverse()
695
776
  phases = [np.pi * i / (qubit_count + 1) for i in range(2 * qubit_count + 2)]
696
- for phase in phases:
697
- qc_phase = qc.copy()
698
- qc_phase.barrier()
699
- for qubit, _ in enumerate(qubit_layout):
700
- qc_phase.p(phase, qubit)
701
- qc_phase.barrier()
702
- qc_phase.compose(qc_inv, inplace=True)
703
- qc_phase.measure_active()
704
- qc_list.append(qc_phase)
777
+ if self.state_generation_routine == "star_optimal":
778
+ qc_inv = generate_ghz_star_optimal(qubit_layout, self.cal_url, self.backend, inv=True)
779
+ for phase in phases:
780
+ qc_phase = qc.copy()
781
+ qc_phase.barrier()
782
+ for _, qubit in enumerate(qubit_layout):
783
+ qc_phase.p(phase, qubit + 1)
784
+ qc_phase.barrier()
785
+ qc_phase.compose(qc_inv, inplace=True)
786
+ qc_phase.measure([q + 1 for q in qubit_layout], list(range(qubit_count)))
787
+ qc_list.append(qc_phase)
788
+ else:
789
+ qc_inv = qc.inverse()
790
+ for phase in phases:
791
+ qc_phase = qc.copy()
792
+ qc_phase.barrier()
793
+ for qubit, _ in enumerate(qubit_layout):
794
+ qc_phase.p(phase, qubit)
795
+ qc_phase.barrier()
796
+ qc_phase.compose(qc_inv, inplace=True)
797
+ qc_phase.measure_active()
798
+ qc_list.append(qc_phase)
705
799
 
706
800
  fixed_coupling_map = set_coupling_map(qubit_layout, self.backend, "fixed")
707
- qc_list_transpiled, _ = perform_backend_transpilation(
708
- qc_list,
709
- self.backend,
710
- qubit_layout,
711
- fixed_coupling_map,
712
- qiskit_optim_level=self.qiskit_optim_level,
713
- optimize_sqg=self.optimize_sqg,
714
- )
801
+
802
+ if self.state_generation_routine == "star_optimal":
803
+ qc_list_transpiled = [
804
+ transpile_to_IQM(
805
+ ghz,
806
+ self.backend,
807
+ existing_moves_handling=True,
808
+ perform_move_routing=False,
809
+ optimize_single_qubits=self.optimize_sqg,
810
+ optimization_level=self.qiskit_optim_level,
811
+ )
812
+ for ghz in qc_list
813
+ ]
814
+
815
+ else:
816
+ qc_list_transpiled, _ = perform_backend_transpilation(
817
+ qc_list,
818
+ self.backend,
819
+ qubit_layout,
820
+ fixed_coupling_map,
821
+ qiskit_optim_level=self.qiskit_optim_level,
822
+ optimize_sqg=self.optimize_sqg,
823
+ )
715
824
  circuit_group = CircuitGroup(name=idx, circuits=qc_list)
716
825
  self.circuits["untranspiled_circuits"].circuit_groups.append(circuit_group)
717
826
  return qc_list_transpiled
@@ -791,7 +900,6 @@ class GHZBenchmark(Benchmark):
791
900
  transpiled_ghz_group: CircuitGroup = self.generate_native_ghz(
792
901
  qubit_layout, qubit_count, self.state_generation_routine
793
902
  )
794
-
795
903
  match self.fidelity_routine:
796
904
  case "randomized_measurements":
797
905
  all_circuits_list, _ = self.append_rms(cast(int, self.num_RMs), qubit_layout)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iqm-benchmarks
3
- Version: 2.51
3
+ Version: 2.52
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>, Adrian Auer <adrian.auer@meetiqm.com>, Raphael Brieger <raphael.brieger@meetiqm.com>, Alessio Calzona <alessio.calzona@meetiqm.com>, Pedro Figueroa Romero <pedro.romero@meetiqm.com>, Amin Hosseinkhani <amin.hosseinkhani@meetiqm.com>, Miikka Koistinen <miikka@meetiqm.com>, Nadia Milazzo <nadia.milazzo@meetiqm.com>, Vicente Pina Canelles <vicente.pina@meetiqm.com>, Aniket Rath <aniket.rath@meetiqm.com>, Jami Rönkkö <jami@meetiqm.com>, Stefan Seegerer <stefan.seegerer@meetiqm.com>
6
6
  Project-URL: Homepage, https://github.com/iqm-finland/iqm-benchmarks
@@ -13,7 +13,7 @@ iqm/benchmarks/compressive_gst/__init__.py,sha256=LneifgYXtcwo2jcXo7GdUEHL6_peip
13
13
  iqm/benchmarks/compressive_gst/compressive_gst.py,sha256=_thQfc9qmIJqAcS3Kg4ITEYl8Ofi8xgC_oZotrmyzVk,28484
14
14
  iqm/benchmarks/compressive_gst/gst_analysis.py,sha256=H6EQGbpI_sig69Jy6hflg6alMTtjB0t9tHftygzA2YA,41240
15
15
  iqm/benchmarks/entanglement/__init__.py,sha256=sHVVToRWRCz0LSntk1rQaoSNNeyZLPoiTjUKWZWrk1E,778
16
- iqm/benchmarks/entanglement/ghz.py,sha256=bM0bqKnyyT3gnN4QNQfzOS8lXp7bqo1pNlUfo4LK3ug,41586
16
+ iqm/benchmarks/entanglement/ghz.py,sha256=drTmV2JQi9ZYr2_Gl28aizFDbV4TQ2NYynsRou-6re0,45946
17
17
  iqm/benchmarks/entanglement/graph_states.py,sha256=6qACedd3UXpiowXc9GW4QhSwO-CzHXnBA3dIC6nCIbE,62788
18
18
  iqm/benchmarks/optimization/__init__.py,sha256=_ajW_OibYLCtzU5AUv5c2zuuVYn8ZNeZUcUUSIGt51M,747
19
19
  iqm/benchmarks/optimization/qscore.py,sha256=iDbL9aKR-fgw1kQA7cdjkEjwKW6ySufs9kexXgzxwMk,46058
@@ -35,7 +35,7 @@ iqm/benchmarks/randomized_benchmarking/interleaved_rb/__init__.py,sha256=sq6MgN_
35
35
  iqm/benchmarks/randomized_benchmarking/interleaved_rb/interleaved_rb.py,sha256=OHoAWajCE48dRDInwQUT8VvtzKad0ExefdqvZFTaYzs,28918
36
36
  iqm/benchmarks/randomized_benchmarking/mirror_rb/__init__.py,sha256=jRKbivWCZ3xdO1k0sx-ygC3s5DUkGSModd975PoAtcg,692
37
37
  iqm/benchmarks/randomized_benchmarking/mirror_rb/mirror_rb.py,sha256=ijieNymik3BeEUpXS-m64mtgdHz9iAFELuLooHeZY0E,33252
38
- iqm_benchmarks-2.51.dist-info/licenses/LICENSE,sha256=2Ncb40-hqkTil78RPv3-YiJfKaJ8te9USJgliKqIdSY,11558
38
+ iqm_benchmarks-2.52.dist-info/licenses/LICENSE,sha256=2Ncb40-hqkTil78RPv3-YiJfKaJ8te9USJgliKqIdSY,11558
39
39
  mGST/LICENSE,sha256=TtHNq55cUcbglb7uhVudeBLUh_qPdUoAEvU0BBwFz-k,1098
40
40
  mGST/README.md,sha256=v_5kw253csHF4-RfE-44KqFmBXIsSMRmOtN0AUPrRxE,5050
41
41
  mGST/additional_fns.py,sha256=MV0Pm5ap59IjhT_E3QhsZyM7lXOF1RZ9SD11zoaf43A,31781
@@ -46,7 +46,7 @@ mGST/optimization.py,sha256=x9tJ9wMQ5aONWpNpBMVtK0rwE6DRcOU33htNgrt0tx4,11015
46
46
  mGST/qiskit_interface.py,sha256=uCdn-Q9CXI2f4FQSxGUy8GmmzQhr9NhCOFb2VPj0gTs,10061
47
47
  mGST/reporting/figure_gen.py,sha256=xFPAHx1Trdqz7swn0kRqwc_jbRaNxhG9Nvx0jeitooo,25847
48
48
  mGST/reporting/reporting.py,sha256=Wss1-zFsMEhzrrXKfP-RICau80ezjDIzcN555KhSehc,34160
49
- iqm_benchmarks-2.51.dist-info/METADATA,sha256=jVyI05sFKgiBDmFwkfhIfoB-HT4gHIf9CDv7s4dRFvM,10968
50
- iqm_benchmarks-2.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
51
- iqm_benchmarks-2.51.dist-info/top_level.txt,sha256=3G23Z-1LGf-IOzTCUl6QwWqiQ3USz25Zt90Ihq192to,9
52
- iqm_benchmarks-2.51.dist-info/RECORD,,
49
+ iqm_benchmarks-2.52.dist-info/METADATA,sha256=sgMF6sIgC9aFl-8ylHXenilP3QSrM93s-RT30FSuEmk,10968
50
+ iqm_benchmarks-2.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
51
+ iqm_benchmarks-2.52.dist-info/top_level.txt,sha256=3G23Z-1LGf-IOzTCUl6QwWqiQ3USz25Zt90Ihq192to,9
52
+ iqm_benchmarks-2.52.dist-info/RECORD,,