Framework for Quantum Computing Application Benchmarking
Project description
QUARK-framework
A modular benchmarking framework for quantum computing applications
QUARK-framework lets you configure, execute, and compare modular computational problems, with a focus on quantum optimization and qml use cases.
Benchmarking Pipelines
Benchmarking runs are seperated into pipelines, consisting of swappable modules. Each module is given data from its upstream module, performs some preprocessing work, and passes the result to its downstream module. After the data was passed through the pipeline it is passed back up, triggering a postprocessing step in each module passed.
QUARK-framework does not provide any module, but can be extended by any number of plugins, each providing one or more modules. In most cases this is done by installing each plugin via pip before running QUARK-framework.
Config Files
To tell QUARK-framework which plugins to use and how to construct its pipelines, a config file must be provided.
example_config.yaml
plugins: ["plugin_1", "plugin_2"]
pipeline: ["module_1", "module_2", "module_3"]
A config must specify the plugins that should be loaded and a description of the pipelines to run.
In the example above, plugin_1 and plugin_2 each provide one or more modules.
All specified plugins must be available to be imported.
All modules that are part of the pipeline must be among the modules provided by the loaded plugins.
The order the pipeline modules will be the order they are run in.
The respective interface types of each module must match for a pipeline to be valid, i.e. the downstream type of module_1 must match the upstream type of module_2.
Module Parameters
A module can either be specified by its name, or as a dict containing only one key, where the key is its name and the value is a dict or paramters. These paramters will be passed to the module when it is created.
parameter_config.yaml
plugins: ["plugin_1", "plugin_2"]
pipeline: [
"module_1": {param1: value1, param2: value2},
"module_2",
"module_3": {param: value},
]
Pipeline Layers
Each element in the pipeline array is actually a pipeline layer, which itself can be an array, containing one or more modules making up that layer.
Each of those modules is interpreted as being swappable with every other module in its layer.
The set of all pipelines is equal to all possible permutations of modules inside all pipeline layers.
Modules inside module layers can be provided as a string or dict, as explained in Module Parameters.
layers_config.yaml
plugins: ["plugin_1", "plugin_2"]
pipeline: [
["module_1a", "module_1b"],
"module_2",
["module_3": {param: value1}, "module_3": {param: value2}],
]
This config file would result in a total of $2\cdot1\cdot2=4$ pipelines to be constructed and executed.
Comparing Incompatible Modules
Modules can only be swapped if their upstream and downstream types match.
However, sometimes it might be necessary to compare one benchmarking pipeline with another where only some of their module share common interfaces.
In such cases, it is possible to specify the pipelines value, an array of pipeline specifications.
Each pipeline specification can still use the layered format introduced in Pipeline Layers.
multiple_pipelines_config.yaml
plugins: ["plugin_1", "plugin_2"]
pipeline1: &pipeline1 [
["module_1a", "module_1b"],
"module_2",
"module_3",
]
pipeline2: &pipeline2 [
["module_1a", "module_1b"],
"module_4",
]
pipelines: [*pipeline1, *pipeline2]
This config file would result in a total of $2\cdot1\cdot1+2\cdot1=4$ pipelines to be executed.
Example
A common pipeline pattern is to first pose some optimization problem like a TSP graph, then mapping the problem to a QUBO formulation, and finally solving it on a quantum annealer. Such a pipeline could look like this:
To evaluate the performance of the quantum annealer module, it could be exchanged with a simulated annealer module with the same interface types. Additionally, the TSP problem can be solved directly by a classical solver. To perform such a comparison for different graph sizes, the following config file can be used:
real_config.yaml
plugins: ["quark_plugin_tsp", "quark_plugin_dwave"]
first_layer:
&first_layer [
"tsp_graph_provider": { nodes: 4, seed: 42 },
"tsp_graph_provider": { nodes: 5, seed: 42 },
"tsp_graph_provider": { nodes: 6, seed: 42 },
]
second_layer: &second_layer "tsp_qubo_mapping_dnx"
third_layer: &third_layer [
"simulated_annealer_dwave": {num_reads: 1},
"simulated_annealer_dwave": {num_reads: 1000},
]
pipeline1: &pipeline1 [
*first_layer,
*second_layer,
*third_layer,
]
pipeline2: &pipeline2 [
*first_layer,
"classical_tsp_solver",
]
pipelines: [*pipeline1, *pipeline2]
This example uses the two plugins quark-plugin-tsp and quark-plugin-dwave, both available as pip packages.
To run this config file, install all necessary dependencies and run QUARK-framework, passing the path to this config file:
pip install quark-framework quark-plugin-tsp quark-plugin-dwave
python -m quark -c path/to/config/file
This results in $3\cdot1\cdot2+3\cdot1=9$ pipelines to be created and executed.
Plugins
A QUARK plugin is a python package that provides one or more modules to be used in a benchmarking pipeline. The structure of a valid plugin is showcased in the QUARK-plugin-template.
Registering modules
A valid plugin must provide a register function at the top level.
This function will be called by QUARK-framework for each plugin specified in plugins in the config file.
As part of the register function, a plugin must call the register function of the QUARK-framework factory for each of its modules.
__init__.py
from quark.plugin_manager import factory
from example_plugin.example_module1 import ExampleModule1
from example_plugin.example_module2 import ExampleModule2
def register() -> None:
"""
Register all modules exposed to quark by this plugin.
For each module, add a line of the form:
factory.register("module_name", Module)
The "module_name" will later be used to refer to the module in the configuration file.
"""
factory.register("example_module1", ExampleModule1)
factory.register("example_module2", ExampleModule2)
The first parameter to the factory.register function is the name of the module. This name should be used to refer to the module in a config file.
The second parameter is a callable that returns an instance of the respective module.
Module Structure
A valid QUARK module must implement the preprocess and postprocess functions, which are abstract functions specified in quark.core.Core.
example_module.py
from dataclasses import dataclass
from typing import override, Any
from quark.core import Core
@dataclass
class ExampleModule(Core):
"""
This is an example module following the recommended structure for a quark module.
A module must have a preprocess and postprocess method, as required by the Core abstract base class.
A module's interface is defined by the type of data parameter those methods receive and return, dictating which other modules it can be connected to.
Types defining interfaces should be chosen form QUARKs predefined set of types to ensure compatibility with other modules.
"""
@override
def preprocess(self, data: Any) -> Any:
# Do some preprocessing work
@override
def postprocess(self, data: Any) -> Any:
# Do some postprocessing work
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quark_framework-0.4.5.tar.gz.
File metadata
- Download URL: quark_framework-0.4.5.tar.gz
- Upload date:
- Size: 45.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
280383383031e5e1db0e53c7ded2b8a6e9720fc606ec5d47be6a4d63c5f651c7
|
|
| MD5 |
2c50f9e6ff7628d615ae29ee11a54d5c
|
|
| BLAKE2b-256 |
680a9defc3074a12d5bd971ba3d1a132a7f91badd16d431364bcb3a497a4a086
|
Provenance
The following attestation bundles were made for quark_framework-0.4.5.tar.gz:
Publisher:
release.yml on QUARK-framework/QUARK-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quark_framework-0.4.5.tar.gz -
Subject digest:
280383383031e5e1db0e53c7ded2b8a6e9720fc606ec5d47be6a4d63c5f651c7 - Sigstore transparency entry: 634155570
- Sigstore integration time:
-
Permalink:
QUARK-framework/QUARK-framework@7aa948508db23f74555d24cb9d7dc01a4d22360c -
Branch / Tag:
refs/tags/0.4.5 - Owner: https://github.com/QUARK-framework
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aa948508db23f74555d24cb9d7dc01a4d22360c -
Trigger Event:
push
-
Statement type:
File details
Details for the file quark_framework-0.4.5-py3-none-any.whl.
File metadata
- Download URL: quark_framework-0.4.5-py3-none-any.whl
- Upload date:
- Size: 28.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9a997bda6226e7aa9111faa94cbe28f37ff4ac1df2bc37572fe623737c89575
|
|
| MD5 |
90d2c01d84d4a0a9269f5e6b2f09cca7
|
|
| BLAKE2b-256 |
bec3288d7c72253777b00959b8c8b5c277016520ae7de493e9b5b4018b882fc8
|
Provenance
The following attestation bundles were made for quark_framework-0.4.5-py3-none-any.whl:
Publisher:
release.yml on QUARK-framework/QUARK-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quark_framework-0.4.5-py3-none-any.whl -
Subject digest:
d9a997bda6226e7aa9111faa94cbe28f37ff4ac1df2bc37572fe623737c89575 - Sigstore transparency entry: 634155586
- Sigstore integration time:
-
Permalink:
QUARK-framework/QUARK-framework@7aa948508db23f74555d24cb9d7dc01a4d22360c -
Branch / Tag:
refs/tags/0.4.5 - Owner: https://github.com/QUARK-framework
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aa948508db23f74555d24cb9d7dc01a4d22360c -
Trigger Event:
push
-
Statement type: