metriq-gym

metriq-gym is a framework for implementing and running standard quantum benchmarks on different quantum devices by different providers

https://github.com/unitaryfoundation/metriq-gym

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.6%) to scientific vocabulary

Keywords

benchmarking quantum-benchmarks quantum-computing
Last synced: 6 months ago · JSON representation ·

Repository

metriq-gym is a framework for implementing and running standard quantum benchmarks on different quantum devices by different providers

Basic Info
Statistics
  • Stars: 15
  • Watchers: 3
  • Forks: 11
  • Open Issues: 50
  • Releases: 9
Topics
benchmarking quantum-benchmarks quantum-computing
Created over 1 year ago · Last pushed 6 months ago
Metadata Files
Readme License Code of conduct Citation

README.md

metriq-gym logo

metriq-gym

Unitary Foundation PyPI version Downloads Doc Status Discord Chat Contributor Covenant

metriq-gym is a Python framework for implementing and running standard quantum benchmarks on different quantum devices by different providers.

  • Open – Open-source since its inception and fully developed in public.
  • Transparent – All benchmark parameters are defined in a schema file and the benchmark code is reviewable by the community.
  • Cross-platform – Supports running benchmarks on multiple quantum hardware providers (integration powered by qBraid-SDK)
  • User-friendly – Provides a simple command-line interface for dispatching, monitoring, and polling benchmark jobs (you can go on with your life while your job waits in the queue).

Data generated by metriq-gym is intended to be published on https://metriq.info.

Join the conversation! - For code, repo, or theory questions, especially those requiring more detailed responses, submit a Discussion. - For casual or time sensitive questions, chat with us on Discord's #metriq channel.

Quick Start (Recommended)

Four easy steps to get started with metriq-gym!

  1. Install metriq-gym directly in your Python environment using pip:

sh pip install metriq-gym

  1. Download a benchmark configuration file from the schemas/examples/ directory

    sh curl -O https://raw.githubusercontent.com/unitaryfoundation/metriq-gym/refs/heads/main/metriq_gym/schemas/examples/wormhole.example.json

  2. Dispatch it to a quantum device or simulator.

    sh mgym job dispatch wormhole.example.json -p local -d aer_simulator

  3. Poll the job to get the results.

    sh mgym job poll latest

You will see the results of the benchmark printed in your terminal. E.g. sh {'device': 'aer_simulator', 'job_type': 'Wormhole', 'provider': 'local', 'results': {'expectation_value': 0.99658203125}, 'timestamp': '2025-07-29T20:31:17.978851', 'version': '0.1.3.dev0'}

Prerequisites

  • Python (version 3.12 or newer)

Developer Setup

These instructions are for setting up a development environment if you plan to contribute to metriq-gym or run the latest version from source.

Prerequisites

Before you begin, ensure you have the following installed: * Python (version 3.12 or newer) * Poetry for managing dependencies

Cloning the Repository

First, clone the repository and navigate to the project directory:

sh git clone --recurse-submodules https://github.com/unitaryfoundation/metriq-gym.git cd metriq-gym

If you've already cloned the repo (with or without submodules), run:

bash git pull --recurse-submodules to keep it up to date.

Installation

Once you have poetry installed and the repository cloned, run:

sh poetry install from the root folder of the project, in order to install the project dependencies.

We recommend doing this in an isolated virtual environment. See Poetry documentation for more information on managing virtual environments.

If you use pyenv, here is a quick start guide to set up the environment and install all dependencies:

sh pyenv install 3.13 pyenv local 3.13 poetry install eval $(poetry env activate) All Python commands below should be run in the virtual environment.

Workflow

metriq-gym supports two type of resources: benchmarks and suites of benchmarks.

Single benchmarks

You can dispatch benchmark jobs by specifying a configuration file for the benchmark you wish to run.

sh mgym job dispatch <BENCHMARK_CONFIG> --provider <PROVIDER> --device <DEVICE>

Refer to the schemas/examples/ directory for example configuration files for supported benchmarks.

If running on quantum cloud hardware, the jobs will be added to a polling queue. The status of the queue can be checked with

sh mgym job poll <METRIQ_GYM_JOB_ID>

where <METRIQ_GYM_JOB_ID> is the assigned job ID of the job that was dispatched as provided by metriq-gym.

Alternatively, the poll action can be used without any argument to view all dispatched jobs, and select the one that is of interest.

sh mgym job poll

In order to export results to a JSON file, you can use the --json flag with the poll action. sh mgym job poll <METRIQ_GYM_JOB_ID> --json This will create a JSON file with the results and the metadata of the job identified by <METRIQ_GYM_JOB_ID>. By default, the JSON file will be saved in the current working directory with the name <METRIQ_GYM_JOB_ID>.json.

Using local simulators

For quick testing without access to cloud hardware, metriq-gym can dispatch jobs to a local simulator. At the moment the Qiskit Aer simulator is supported. Specify the local provider and the aer_simulator device. Example (from the project root directory):

sh mgym job dispatch metriq_gym/schemas/examples/qml_kernel.example.json --provider local --device aer_simulator

You can also create a noisy simulator based on an IBM backend by passing the backend name as the device:

sh mgym job dispatch metriq_gym/schemas/examples/qml_kernel.example.json --provider local --device ibm_<BACKEND>

Polling local simulator jobs works the same way:

sh mgym job poll <METRIQ_GYM_JOB_ID>

Suites of benchmarks

A suite is a collection of benchmarks that can be dispatched together. This is useful for running multiple benchmarks on the same device or provider. To dispatch a suite, create a JSON file suite.json that contains an array of benchmark configurations. For example:

json { "name": "test_suite", "description": "Just a test suite for the README", "benchmarks": [ { "name": "BSEQ", "config": { "benchmark_name": "BSEQ", "shots": 10 } }, { "name": "wormhole_7_qubits", "config": { "benchmark_name": "Wormhole", "num_qubits": 7, "shots": 1000 } }, } You can then dispatch the suite using the suite dispatch action:

sh mgym suite dispatch suite.json --provider <PROVIDER> --device <DEVICE> This will create a set of jobs for each benchmark in the suite and return a suite ID. You can poll the suite results using the suite poll action:

sh mgym suite poll <METRIQ_GYM_SUITE_ID>

Credential management

To run on hardware, each hardware provider offers API tokens that are required to interact with their quantum devices. In order to run on these devices, you will need to follow the instructions on the respective pages of the providers and obtain API keys from them.

The .env.example file illustrates how to specify the API keys once you have acquired them. You will need to create a .env file in the same directory as .env.example and populate the values of these variables accordingly.

View jobs

You can view all the jobs that have been dispatched by using the view action. This will display basic information about each job, including its ID, backend, job type, provider, and device.

sh mgym job view In order to view the details of a specific job (e.g., the parameters the job was launched with), you can use the view action and pass the job's id as argument, or select the job by index from the list of all dispatched jobs.

sh mgym job view <METRIQ_GYM_JOB_ID>

Example: Benchmarking Bell state effective qubits (BSEQ) on IBM hardware

The following example is for IBM, but the general workflow is applicable to any of the supported providers and benchmarks.

To run on IBM hardware, you will also require an IBM token. To obtain this, please visit the IBM Quantum Platform and include the API token in the local .env file as previously described.

The schemas/examples/ directory houses example JSON configuration files that define the benchmark to run. In this case, we use the bseq.example.json file as we want to run a BSEQ job. The following dispatches a job on the ibm-sherbrooke device for BSEQ.

sh mgym job dispatch metriq_gym/schemas/examples/bseq.example.json --provider ibm --device ibm_sherbrooke

We should see logging information in our terminal to indicate that the dispatch action is taking place:

sh INFO - Starting job dispatch... INFO - Dispatching BSEQ benchmark from metriq_gym/schemas/examples/bseq.example.json on ibm_sherbrooke... ... INFO - Job dispatched with ID: 93a06a18-41d8-475a-a030-339fbf3accb9

We can confirm that the job has indeed been dispatched and retrieve the associated metriq-gym job ID (along with other pieces of metadata).

sh +--------------------------------------+------------+------------------------------------------------------+----------------+----------------------------+ | Metriq-gym Job Id | Provider | Device | Type | Dispatch time (UTC) | +======================================+============+======================================================+================+============================+ | 93a06a18-41d8-475a-a030-339fbf3accb9 | ibm | ibm_sherbrooke | BSEQ | 2025-03-05T10:21:18.333703 | +--------------------------------------+------------+------------------------------------------------------+----------------+----------------------------+

We can use the "poll" action to check the status of our job:

sh mgym job poll 93a06a18-41d8-475a-a030-339fbf3accb9

Doing so gives us the results of our job (if it has completed):

sh INFO - Polling job... BSEQResult(largest_connected_size=100, fraction_connected=0.7874015748031497)

In the event where the job has not completed, we would receive the following message instead

sh INFO - Polling job... INFO - Job is not yet completed. Current status: INFO - - d0wtyfhvx7bg008203b0: QUEUED (position 3) INFO - Please try again later.

As a convenience, while we could supply the metriq-gym job ID, we can also poll the job by running mgym job poll and then selecting the job to poll by index from our local metriq-gym jobs database.

sh Available jobs: +----+--------------------------------------+------------+------------------------------------------------------+----------------+-----------------------------+ | | Metriq-gym Job Id | Provider | Device | Type | Dispatch time (UTC) | +====+======================================+============+======================================================+================+=============================+ | 0 | 93a06a18-41d8-475a-a030-339fbf3accb9 | ibm | ibm_sherbrooke | BSEQ | 2025-03-05T10:21:18.333703 | +----+--------------------------------------+------------+------------------------------------------------------+----------------+-----------------------------+ Select a job index:

Entering the index (in this case, 0), polls the same job.

sh Select a job index: 0 INFO - Polling job...

Contributing

First, follow the Developer Setup instructions above.

Style guide

We don't have a style guide per se, but we recommend that both linter and formatter are run before each commit. In order to guarantee that, please install the pre-commit hook with

sh poetry run pre-commit install immediately upon cloning the repository.

Tests

The entire suite of tests can be run with sh poetry run pytest

Unit tests only can be run with sh poetry run pytest -m "not e2e"

End-to-end tests only can be run with sh poetry run pytest -m e2e

Type checking

The project uses mypy for static type checking. To run mypy, use the following command: sh poetry run mypy

Documentation

The project uses Sphinx to generate documentation. To build the HTML documentation:

  1. Navigate to the docs/ directory: sh cd docs/

Run the following command to build the HTML files: sh make html

Open the generated index.html file located in the _build/html/ directory to view the documentation.

Owner

  • Name: Unitary Foundation
  • Login: unitaryfoundation
  • Kind: organization
  • Email: info@unitary.foundation

Unitary Foundation is a non-profit working to create a quantum technology ecosystem that benefits the most people.

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Please do not update this file manually. Use https://bit.ly/cffinit instead!

cff-version: 1.2.0
title: metriq-gym
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - name: Unitary Foundation
    city: San Francisco
    post-code: '94104'
    region: California
    country: US
    website: 'https://unitary.foundation/'
repository-code: 'https://github.com/unitaryfoundation/metriq-gym'
abstract: >-
  metriq-gym is a Python framework for implementing and
  running standard quantum benchmarks on different quantum
  devices by different providers.
keywords:
  - quantum-computing
  - quantum-computing-benchmarks
license: GPL-3.0-or-later

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 56
  • Total pull requests: 121
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 3 days
  • Total issue authors: 6
  • Total pull request authors: 11
  • Average comments per issue: 0.54
  • Average comments per pull request: 0.36
  • Merged pull requests: 76
  • Bot issues: 0
  • Bot pull requests: 65
Past Year
  • Issues: 56
  • Pull requests: 121
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 3 days
  • Issue authors: 6
  • Pull request authors: 11
  • Average comments per issue: 0.54
  • Average comments per pull request: 0.36
  • Merged pull requests: 76
  • Bot issues: 0
  • Bot pull requests: 65
Top Authors
Issue Authors
  • vprusso (27)
  • cosenal (17)
  • Changhao-Li (4)
  • nonhermitian (3)
  • Neerpatel125 (2)
  • nathanshammah (1)
Pull Request Authors
  • dependabot[bot] (65)
  • cosenal (21)
  • vprusso (21)
  • Neerpatel125 (3)
  • Kitsunp (3)
  • lavanya-m-k (2)
  • luffy-orf (1)
  • natestemen (1)
  • alejomonbar (1)
  • sandaru-sdm (1)
  • Changhao-Li (1)
Top Labels
Issue Labels
qedc-integration (13) good first issue (3) new benchmark (3) devops (2) feature (2) documentation (2) refactor (1) minor (1) github_actions (1) non-quantum (1) unitaryHACK2025 (1) enhancement (1)
Pull Request Labels
dependencies (65) python (53) minor (19) github_actions (12)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 253 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 7
pypi.org: metriq-gym

Framework for implementing and running standard quantum benchmarks on different quantum devices by different providers.

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 253 Last month
Rankings
Dependent packages count: 8.9%
Average: 29.7%
Dependent repos count: 50.4%
Last synced: 6 months ago

Dependencies

poetry.lock pypi
  • annotated-types 0.7.0
  • anyio 4.6.2.post1
  • certifi 2024.8.30
  • cffi 1.17.1
  • charset-normalizer 3.4.0
  • click 8.1.7
  • colorama 0.4.6
  • cryptography 43.0.1
  • dill 0.3.9
  • h11 0.14.0
  • httpcore 1.0.6
  • httpx 0.27.2
  • ibm-cloud-sdk-core 3.22.0
  • ibm-platform-services 0.57.2
  • idna 3.10
  • markdown-it-py 3.0.0
  • mdurl 0.1.2
  • metriq-client 0.1.2
  • mpmath 1.3.0
  • numpy 2.1.2
  • pbr 6.1.0
  • psutil 6.1.0
  • pycparser 2.22
  • pydantic 2.9.2
  • pydantic-core 2.23.4
  • pygments 2.18.0
  • pyjwt 2.9.0
  • pyqrack 1.31.1
  • pyspnego 0.11.1
  • python-dateutil 2.9.0.post0
  • pytz 2024.2
  • qiskit 1.2.4
  • qiskit-aer 0.15.1
  • qiskit-ibm-runtime 0.30.0
  • requests 2.32.3
  • requests-ntlm 1.3.0
  • rich 13.9.2
  • rustworkx 0.15.1
  • scipy 1.14.1
  • shellingham 1.5.4
  • six 1.16.0
  • sniffio 1.3.1
  • sspilib 0.2.0
  • stevedore 5.3.0
  • symengine 0.13.0
  • sympy 1.13.3
  • tea 0.1.0
  • tea-client 0.1.0
  • tea-console 0.1.0
  • typer 0.12.5
  • typing-extensions 4.12.2
  • tzdata 2024.2
  • tzlocal 5.2
  • urllib3 2.2.3
  • websocket-client 1.8.0
pyproject.toml pypi
.github/workflows/dependabot-automerge.yml actions
  • dependabot/fetch-metadata v2 composite
.github/workflows/test.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite