iqm-benchmarks 1.3__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.
- iqm/benchmarks/__init__.py +31 -0
- iqm/benchmarks/benchmark.py +109 -0
- iqm/benchmarks/benchmark_definition.py +264 -0
- iqm/benchmarks/benchmark_experiment.py +163 -0
- iqm/benchmarks/compressive_gst/__init__.py +20 -0
- iqm/benchmarks/compressive_gst/compressive_gst.py +1029 -0
- iqm/benchmarks/entanglement/__init__.py +18 -0
- iqm/benchmarks/entanglement/ghz.py +802 -0
- iqm/benchmarks/logging_config.py +29 -0
- iqm/benchmarks/optimization/__init__.py +18 -0
- iqm/benchmarks/optimization/qscore.py +719 -0
- iqm/benchmarks/quantum_volume/__init__.py +21 -0
- iqm/benchmarks/quantum_volume/clops.py +726 -0
- iqm/benchmarks/quantum_volume/quantum_volume.py +854 -0
- iqm/benchmarks/randomized_benchmarking/__init__.py +18 -0
- iqm/benchmarks/randomized_benchmarking/clifford_1q.pkl +0 -0
- iqm/benchmarks/randomized_benchmarking/clifford_2q.pkl +0 -0
- iqm/benchmarks/randomized_benchmarking/clifford_rb/__init__.py +19 -0
- iqm/benchmarks/randomized_benchmarking/clifford_rb/clifford_rb.py +386 -0
- iqm/benchmarks/randomized_benchmarking/interleaved_rb/__init__.py +19 -0
- iqm/benchmarks/randomized_benchmarking/interleaved_rb/interleaved_rb.py +555 -0
- iqm/benchmarks/randomized_benchmarking/mirror_rb/__init__.py +19 -0
- iqm/benchmarks/randomized_benchmarking/mirror_rb/mirror_rb.py +810 -0
- iqm/benchmarks/randomized_benchmarking/multi_lmfit.py +86 -0
- iqm/benchmarks/randomized_benchmarking/randomized_benchmarking_common.py +892 -0
- iqm/benchmarks/readout_mitigation.py +290 -0
- iqm/benchmarks/utils.py +521 -0
- iqm_benchmarks-1.3.dist-info/LICENSE +205 -0
- iqm_benchmarks-1.3.dist-info/METADATA +190 -0
- iqm_benchmarks-1.3.dist-info/RECORD +42 -0
- iqm_benchmarks-1.3.dist-info/WHEEL +5 -0
- iqm_benchmarks-1.3.dist-info/top_level.txt +2 -0
- mGST/LICENSE +21 -0
- mGST/README.md +54 -0
- mGST/additional_fns.py +962 -0
- mGST/algorithm.py +733 -0
- mGST/compatibility.py +238 -0
- mGST/low_level_jit.py +694 -0
- mGST/optimization.py +349 -0
- mGST/qiskit_interface.py +282 -0
- mGST/reporting/figure_gen.py +334 -0
- mGST/reporting/reporting.py +710 -0
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
Lmfit for multiple datasets, generalized and extended version of the shown example in the lmfit documentation:
|
|
16
|
+
https://lmfit.github.io/lmfit-py/examples/example_fit_multi_datasets.html#sphx-glr-examples-example-fit-multi-datasets-py
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from inspect import signature
|
|
21
|
+
|
|
22
|
+
from lmfit import Parameters
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def eval_func_single_dataset(func, params, i, x):
|
|
26
|
+
"""Returns the evaluation of the fit function for a single dataset"""
|
|
27
|
+
|
|
28
|
+
_, fit_param_names = get_param_names_from_func_signature(func)
|
|
29
|
+
|
|
30
|
+
# assume parameter object has existing parameter names with a suffix _{i}
|
|
31
|
+
args = [params[f"{name}_{i + 1}"] for name in fit_param_names]
|
|
32
|
+
|
|
33
|
+
return func(x, *args)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def get_param_names_from_func_signature(func):
|
|
37
|
+
"""Gets the function parameter names from its signature"""
|
|
38
|
+
param_names = list(signature(func).parameters.keys())
|
|
39
|
+
independent_param_name = param_names[0]
|
|
40
|
+
fit_param_names = param_names[1:]
|
|
41
|
+
return independent_param_name, fit_param_names
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# use model .post_fit= to calculate fidelities.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def multi_dataset_residual(params, x, data, func):
|
|
48
|
+
"""Calculate total residual for fits of func to several data sets."""
|
|
49
|
+
ndata, _ = data.shape
|
|
50
|
+
resid = 0.0 * data[:]
|
|
51
|
+
|
|
52
|
+
# make residual per line
|
|
53
|
+
for i in range(ndata):
|
|
54
|
+
resid[i, :] = data[i, :] - eval_func_single_dataset(func, params, i, x)
|
|
55
|
+
|
|
56
|
+
# now flatten this to a 1D array; this will be needed by minimize()
|
|
57
|
+
return resid.flatten()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def create_multi_dataset_params(func, data, initial_guesses=None, constraints=None, simultaneously_fit_vars=None):
|
|
61
|
+
"""Generates lmfit Parameter object with parameters for each line to fit"""
|
|
62
|
+
fit_params = Parameters()
|
|
63
|
+
|
|
64
|
+
_, fit_param_names = get_param_names_from_func_signature(func)
|
|
65
|
+
|
|
66
|
+
for i, _ in enumerate(data):
|
|
67
|
+
for name in fit_param_names:
|
|
68
|
+
fit_params.add(f"{name}_{i + 1}")
|
|
69
|
+
|
|
70
|
+
# set initial guesses if provided
|
|
71
|
+
if initial_guesses is not None:
|
|
72
|
+
if name in initial_guesses:
|
|
73
|
+
fit_params[f"{name}_{i + 1}"].value = initial_guesses[name]
|
|
74
|
+
# set constraints if provided
|
|
75
|
+
if constraints is not None:
|
|
76
|
+
if name in constraints:
|
|
77
|
+
fit_params[f"{name}_{i + 1}"].max = constraints[name]["max"]
|
|
78
|
+
fit_params[f"{name}_{i + 1}"].min = constraints[name]["min"]
|
|
79
|
+
|
|
80
|
+
# force params to be fit as a single parameter across datasets
|
|
81
|
+
if simultaneously_fit_vars is not None:
|
|
82
|
+
if name in simultaneously_fit_vars:
|
|
83
|
+
if i > 0:
|
|
84
|
+
fit_params[f"{name}_{i + 1}"].expr = f"{name}_{1}"
|
|
85
|
+
|
|
86
|
+
return fit_params
|