iqm.benchmarks.benchmark_definition.Benchmark#
- class iqm.benchmarks.benchmark_definition.Benchmark(backend: str | IQMBackendBase, configuration: BenchmarkConfigurationBase, **kwargs: dict[str, Any])#
Bases:
ABCA base class for running cortex-based Benchmark experiments.
In order to write a new benchmark, it is recommended to derive a class from this baseclass. A new benchmark is defined by deriving from this base class and implementing the execute method. Additionally, a custom analysis for the benchmark can be implemented by giving the pointer to the analysis method in
analysis_functionfield. The given analysis_function should acceptAnalysisResultas its input and return the final result.Attributes
default_optionsoptionsMethods
analysis_function(result)The default analysis that only pass the result through.
analyze([run_index])The default analysis for the benchmark.
execute(backend)Executes the benchmark.
name()Return the name of the benchmark.
run()Runs the benchmark using the given backend.
- Parameters:
backend (str | IQMBackendBase)
configuration (BenchmarkConfigurationBase)
- static analysis_function(result: BenchmarkRunResult) BenchmarkAnalysisResult#
The default analysis that only pass the result through.
- Parameters:
result (BenchmarkRunResult)
- Return type:
- abstractmethod execute(backend: IQMBackend | IQMFacadeBackend) Dataset#
Executes the benchmark.
This method should be overridden by deriving classes.
- Parameters:
backend (IQMBackend | IQMFacadeBackend) – Qiskit backend used to execute benchmarks.
- Returns:
An xarray dataset which contains to results of the benchmark execution. The dataset should contain all the information necessary for analysing the benchmark results.
- Return type:
- run() BenchmarkRunResult#
Runs the benchmark using the given backend.
- Returns:
The result of the benchmark run.
- Return type:
RunResult
- analyze(run_index: int = -1) BenchmarkAnalysisResult#
The default analysis for the benchmark.
Internally uses the function defined by the attribute
analysis_functionto perform the analysis. This function makes a shallow copy of the dataset produced by run. Therefore, it is recommended to not make changes to the data of the dataset but just the structure of the array.- Parameters:
run_index (int) – Index for the run to analyze.
- Returns:
An analysis result constructed from the run and updated by the analysis method defined by the
analysis_functionfield.- Return type: