Clifford Randomized Benchmarking (RB) Example#
%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
Choose (or define) a backend#
#backend = "fakeadonis"
backend = "fakeapollo"
#backend = "garnet"
#backend = "deneb"
Set IQM Token if using Resonance.#
# import os
# os.environ["IQM_TOKEN"] = ""
Randomized Benchmarking Configuration#
NB: Clifford RB is executed by default with Interleaved RB !
from iqm.benchmarks.randomized_benchmarking.clifford_rb.clifford_rb import *
EXAMPLE_CRB = CliffordRBConfiguration(
qubits_array=[[0,1],[3,4]],#,[8,9],[13,14],[17,18],[5,6],[10,11],[15,16]],
sequence_lengths=[2**(m+1)-1 for m in range(6)],
num_circuit_samples=25,
shots=2**8,
calset_id=None,
parallel_execution=False,
)
Run the experiment#
benchmark_clifford_rb = CliffordRandomizedBenchmarking(backend, EXAMPLE_CRB)
run_clifford_rb = benchmark_clifford_rb.run()
2024-12-17 11:56:12,750 - iqm.benchmarks.logging_config - INFO - Clifford dictionaries imported successfully !
2024-12-17 11:56:12,750 - iqm.benchmarks.logging_config - INFO - Executing sequential Clifford RB on qubits [0, 1]. Will generate and submit all 25 Clifford RB circuits for each depth [1, 3, 7, 15, 31, 63]
2024-12-17 11:56:12,750 - iqm.benchmarks.logging_config - INFO - Now at sequence length 1
2024-12-17 11:56:12,831 - iqm.benchmarks.logging_config - INFO - Now at sequence length 3
2024-12-17 11:56:12,992 - iqm.benchmarks.logging_config - INFO - Now at sequence length 7
2024-12-17 11:56:13,341 - iqm.benchmarks.logging_config - INFO - Now at sequence length 15
2024-12-17 11:56:14,040 - iqm.benchmarks.logging_config - INFO - Now at sequence length 31
2024-12-17 11:56:20,469 - iqm.benchmarks.logging_config - INFO - Now at sequence length 63
2024-12-17 11:56:23,291 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [0, 1]
2024-12-17 11:56:23,292 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [0, 1]
2024-12-17 11:56:23,349 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [0, 1]
2024-12-17 11:56:23,541 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [0, 1]
2024-12-17 11:56:23,600 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [0, 1]
2024-12-17 11:56:23,756 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [0, 1]
2024-12-17 11:56:23,837 - iqm.benchmarks.logging_config - INFO - All jobs for qubits [0, 1] and sequence lengths [1, 3, 7, 15, 31, 63] submitted successfully!
2024-12-17 11:56:24,025 - iqm.benchmarks.logging_config - INFO - Executing sequential Clifford RB on qubits [3, 4]. Will generate and submit all 25 Clifford RB circuits for each depth [1, 3, 7, 15, 31, 63]
2024-12-17 11:56:30,171 - iqm.benchmarks.logging_config - INFO - Now at sequence length 1
2024-12-17 11:56:30,905 - iqm.benchmarks.logging_config - INFO - Now at sequence length 3
2024-12-17 11:56:31,544 - iqm.benchmarks.logging_config - INFO - Now at sequence length 7
2024-12-17 11:56:31,899 - iqm.benchmarks.logging_config - INFO - Now at sequence length 15
2024-12-17 11:56:32,624 - iqm.benchmarks.logging_config - INFO - Now at sequence length 31
2024-12-17 11:56:34,004 - iqm.benchmarks.logging_config - INFO - Now at sequence length 63
2024-12-17 11:56:43,319 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [3, 4]
2024-12-17 11:56:43,319 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [3, 4]
2024-12-17 11:56:43,400 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [3, 4]
2024-12-17 11:56:43,569 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [3, 4]
2024-12-17 11:56:43,777 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [3, 4]
2024-12-17 11:56:43,840 - iqm.benchmarks.logging_config - INFO - Submitting batch with 25 circuits corresponding to qubits [3, 4]
2024-12-17 11:56:44,048 - iqm.benchmarks.logging_config - INFO - All jobs for qubits [3, 4] and sequence lengths [1, 3, 7, 15, 31, 63] submitted successfully!
2024-12-17 11:56:44,098 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[0, 1]_depth_1
2024-12-17 11:56:44,323 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [0, 1] and depth 1 run to the dataset
2024-12-17 11:56:45,186 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[0, 1]_depth_3
2024-12-17 11:56:45,186 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [0, 1] and depth 3 run to the dataset
2024-12-17 11:56:45,225 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[0, 1]_depth_7
2024-12-17 11:56:45,225 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [0, 1] and depth 7 run to the dataset
2024-12-17 11:56:45,267 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[0, 1]_depth_15
2024-12-17 11:56:45,267 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [0, 1] and depth 15 run to the dataset
2024-12-17 11:56:45,314 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[0, 1]_depth_31
2024-12-17 11:56:45,315 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [0, 1] and depth 31 run to the dataset
2024-12-17 11:56:45,364 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[0, 1]_depth_63
2024-12-17 11:56:45,364 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [0, 1] and depth 63 run to the dataset
2024-12-17 11:56:45,416 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[3, 4]_depth_1
2024-12-17 11:56:45,417 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [3, 4] and depth 1 run to the dataset
2024-12-17 11:56:45,476 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[3, 4]_depth_3
2024-12-17 11:56:45,476 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [3, 4] and depth 3 run to the dataset
2024-12-17 11:56:45,542 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[3, 4]_depth_7
2024-12-17 11:56:45,542 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [3, 4] and depth 7 run to the dataset
2024-12-17 11:56:45,615 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[3, 4]_depth_15
2024-12-17 11:56:45,616 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [3, 4] and depth 15 run to the dataset
2024-12-17 11:56:45,697 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[3, 4]_depth_31
2024-12-17 11:56:45,697 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [3, 4] and depth 31 run to the dataset
2024-12-17 11:56:45,789 - iqm.benchmarks.logging_config - INFO - Retrieving all counts for qubits_[3, 4]_depth_63
2024-12-17 11:56:45,789 - iqm.benchmarks.logging_config - INFO - Adding counts of qubits [3, 4] and depth 63 run to the dataset
2024-12-17 11:56:45,890 - iqm.benchmarks.logging_config - INFO - RB experiment concluded !
Perform the analysis#
result_clifford_rb = benchmark_clifford_rb.analyze()
2024-12-17 11:56:45,931 - iqm.benchmarks.logging_config - INFO - Post-processing sequential RB for qubits [[0, 1], [3, 4]]
2024-12-17 11:56:45,938 - iqm.benchmarks.logging_config - INFO - Qubits [0, 1] and depth 1
2024-12-17 11:56:45,945 - iqm.benchmarks.logging_config - INFO - Qubits [0, 1] and depth 3
2024-12-17 11:56:45,952 - iqm.benchmarks.logging_config - INFO - Qubits [0, 1] and depth 7
2024-12-17 11:56:45,959 - iqm.benchmarks.logging_config - INFO - Qubits [0, 1] and depth 15
2024-12-17 11:56:45,966 - iqm.benchmarks.logging_config - INFO - Qubits [0, 1] and depth 31
2024-12-17 11:56:45,972 - iqm.benchmarks.logging_config - INFO - Qubits [0, 1] and depth 63
2024-12-17 11:56:45,979 - iqm.benchmarks.logging_config - INFO - Qubits [3, 4] and depth 1
2024-12-17 11:56:45,986 - iqm.benchmarks.logging_config - INFO - Qubits [3, 4] and depth 3
2024-12-17 11:56:45,993 - iqm.benchmarks.logging_config - INFO - Qubits [3, 4] and depth 7
2024-12-17 11:56:45,999 - iqm.benchmarks.logging_config - INFO - Qubits [3, 4] and depth 15
2024-12-17 11:56:46,006 - iqm.benchmarks.logging_config - INFO - Qubits [3, 4] and depth 31
2024-12-17 11:56:46,013 - iqm.benchmarks.logging_config - INFO - Qubits [3, 4] and depth 63
{'clifford': {'[0, 1]': 0.946844466999168}}
[0, 1]
clifford
{'clifford': {'[3, 4]': 0.9429197366921651}}
[3, 4]
clifford
run_clifford_rb.dataset.attrs
{'session_timestamp': '20241217-115553',
'execution_timestamp': '20241217-115553',
'backend_configuration_name': 'fakeapollo',
'backend_name': 'IQMFakeApolloBackend',
'benchmark': 'clifford_rb',
'shots': 256,
'max_gates_per_batch': None,
'calset_id': None,
'routing_method': 'sabre',
'physical_layout': 'fixed',
'qubits_array': [[0, 1], [3, 4]],
'sequence_lengths': [1, 3, 7, 15, 31, 63],
'num_circuit_samples': 25,
'parallel_execution': False,
0: {'qubits': [0, 1],
'depth_1': {'time_circuit_generation': 10.541001081466675,
'time_submit': 0.0006990432739257812,
'time_retrieve': 0.22491073608398438,
'all_job_metadata': {'batch_job_1': {'job_id': '8f305755-e038-4596-8617-d96ba3f42ca9',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_3': {'time_circuit_generation': 10.541001081466675,
'time_submit': 0.05647683143615723,
'time_retrieve': 0.0005230903625488281,
'all_job_metadata': {'batch_job_1': {'job_id': '2fe0b406-8977-4567-bba0-d4168f0883ed',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_7': {'time_circuit_generation': 10.541001081466675,
'time_submit': 0.19257187843322754,
'time_retrieve': 0.0004839897155761719,
'all_job_metadata': {'batch_job_1': {'job_id': '8299918c-be26-40d5-8778-9ea4468a1df2',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_15': {'time_circuit_generation': 10.541001081466675,
'time_submit': 0.05831408500671387,
'time_retrieve': 0.0004811286926269531,
'all_job_metadata': {'batch_job_1': {'job_id': '174640c4-9ff3-4ca3-9ffc-d6aa5be304f3',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_31': {'time_circuit_generation': 10.541001081466675,
'time_submit': 0.1564040184020996,
'time_retrieve': 0.0006189346313476562,
'all_job_metadata': {'batch_job_1': {'job_id': '7bb739f2-31bc-40af-8dbf-1d60a9310391',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_63': {'time_circuit_generation': 10.541001081466675,
'time_submit': 0.08135986328125,
'time_retrieve': 0.0004200935363769531,
'all_job_metadata': {'batch_job_1': {'job_id': 'f414a2c1-75c8-4d5a-9e4b-ccce29903f5f',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}}},
1: {'qubits': [3, 4],
'depth_1': {'time_circuit_generation': 13.147684812545776,
'time_submit': 0.0005502700805664062,
'time_retrieve': 0.00039887428283691406,
'all_job_metadata': {'batch_job_1': {'job_id': '8832576a-6d6e-4abe-8cfa-5001e6bb98ee',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_3': {'time_circuit_generation': 13.147684812545776,
'time_submit': 0.08015298843383789,
'time_retrieve': 0.00039315223693847656,
'all_job_metadata': {'batch_job_1': {'job_id': 'ecc1bcea-ef4c-4f35-9284-ab49af0c5b9f',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_7': {'time_circuit_generation': 13.147684812545776,
'time_submit': 0.16936397552490234,
'time_retrieve': 0.0003960132598876953,
'all_job_metadata': {'batch_job_1': {'job_id': '5582c842-0f07-46b6-96be-2fb3925b19d9',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_15': {'time_circuit_generation': 13.147684812545776,
'time_submit': 0.20774221420288086,
'time_retrieve': 0.0004191398620605469,
'all_job_metadata': {'batch_job_1': {'job_id': '6423b02b-8417-4300-b7ac-84d59f87a51f',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_31': {'time_circuit_generation': 13.147684812545776,
'time_submit': 0.0635080337524414,
'time_retrieve': 0.0004169940948486328,
'all_job_metadata': {'batch_job_1': {'job_id': '0b324804-44fe-4c16-83eb-08e5cd67aa79',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}},
'depth_63': {'time_circuit_generation': 13.147684812545776,
'time_submit': 0.20784401893615723,
'time_retrieve': 0.0004961490631103516,
'all_job_metadata': {'batch_job_1': {'job_id': '6c633640-d4b4-47de-a46d-d3ae4c84d212',
'backend': 'aer_simulator',
'status': 'job has successfully run',
'circuits_in_batch': None,
'shots': None,
'timestamps': None}}}}}
result_clifford_rb.observations
[BenchmarkObservation(name='avg_gate_fidelity', value=0.946844466999168, identifier=BenchmarkObservationIdentifier(qubit_indices=[0, 1]), uncertainty=0.0012220693932290373),
BenchmarkObservation(name='avg_gate_fidelity', value=0.9429197366921651, identifier=BenchmarkObservationIdentifier(qubit_indices=[3, 4]), uncertainty=0.001545469960991071)]
for plot in result_clifford_rb.plots.values():
display(plot)