Skip to main content

A collection of quantum information science problems formulated as reinforcement learning environments

Project description

Qiskit Gym 🏋️‍♀️

Python Qiskit

Qiskit Gym is a collection of quantum information science problems formulated as reinforcement learning environments.

🚀 Key Features

Train AI agents to discover efficient and near-optimal quantum circuit implementations for various quantum computing tasks.

  • 🎯 Purpose-Built RL Environments: Specialized Gymnasium-compatible environments for quantum circuit synthesis problems
  • 🔧 Hardware-Aware Environments: Design environments matching real quantum hardware coupling maps
  • 🔄 Flexible Gate Sets: Define custom gate sets as part of your environments
  • 🧠 State-of-the-Art RL Integration: Built-in support for PPO, Alpha Zero, and custom policy configurations
  • ⚡ High-Performance Backend: Rust-powered core for lightning-fast quantum circuit operations
  • 💾 Model Persistence: Save and load trained models for deployment
  • ⚖️ Scalable Training: Efficient parallel environment execution
  • 📊 Built-in TensorBoard Integration: For training visualization and performance tracking
  • 🔌 Qiskit integration: You can use Qiksit seamlessly to define your problem and use your trained models.

🎲 Supported Problem Types

🔄 Permutation Synthesis

Learn to implement arbitrary qubit permutations using minimal SWAP gates on constrained coupling maps.

🔢 Linear Function Synthesis

Decompose linear Boolean functions into efficient quantum circuits using CNOT gates.

🌊 Clifford Synthesis

Generate optimal implementations of Clifford group elements with customizable gate sets.

🔭 Roadmap and Vision

There are lots of interesting quantum computing problems that can be addressed with RL. We hope to centralize the problem formulations here to make it easier for Quantum and AI researchers to collaborate in taclikng them.

For future releases we plan to include envs for:

  • Pauli Network synthesis
  • Qubit routing
  • Clifford+T synthesis

We are also open to env requests and contributions!

Stay tuned!

🏃‍♂️ Quick Start

Get started with quantum circuit synthesis RL in minutes! Check out our comprehensive tutorial:

👉 examples/intro.ipynb - Interactive Introduction Notebook

This Jupyter notebook walks you through:

  • Setting up different synthesis environments
  • Training RL agents from scratch
  • Evaluating and using trained models
  • Visualizing quantum circuits and training progress

🛠️ Installation

git clone https://github.com/AI4quantum/qiskit-gym.git
cd qiskit-gym
pip install -e .

💡 Example Usage

Here's how to set up a permutation synthesis environment and train an RL agent:

from qiskit_gym.envs import PermutationGym
from qiskit_gym.rl import RLSynthesis, PPOConfig, BasicPolicyConfig
from qiskit.transpiler import CouplingMap

# Create a 3x3 grid coupling map environment
cmap = CouplingMap.from_grid(3, 3, bidirectional=False)
env = PermutationGym.from_coupling_map(cmap)

# Set up RL synthesis with PPO
rls = RLSynthesis(env, PPOConfig(), BasicPolicyConfig())

# Train the agent
rls.learn(num_iterations=100, tb_path="runs/my_experiment/")

# Use the trained model to synthesize circuits
import numpy as np
random_permutation = np.random.permutation(9)
optimized_circuit = rls.synth(random_permutation, num_searches=1000)

🏅 Reward and Gate Penalties (at a glance)

  • Each step returns reward = (1.0 if solved else 0.0) - penalty.
  • penalty is the weighted increase in cost metrics after the chosen gate: CNOT count, CNOT layers, total layers, and total gates.
  • Default weights (MetricsWeights) are n_cnots=0.01, n_layers_cnots=0.0, n_layers=0.0, n_gates=0.0001; configure per env via metrics_weights.
  • Metrics accumulate over the episode; once the target is solved, the positive reward is offset by the penalties from any extra cost incurred.

🤝 Contributing

We welcome contributions! Whether you're adding new synthesis problems, improving RL algorithms, or enhancing documentation - every contribution helps advance quantum computing research.

📝 License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

🧪 Relevant Papers

  • Kremer, D., Villar, V., Paik, H., Duran, I., Faro, I., & Cruz-Benito, J. (2024). Practical and efficient quantum circuit synthesis and transpiling with reinforcement learning. arXiv preprint arXiv:2405.13196.

  • Dubal, A., Kremer, D., Martiel, S., Villar, V., Wang, D., & Cruz-Benito, J. (2025). Pauli Network Circuit Synthesis with Reinforcement Learning. arXiv preprint arXiv:2503.14448.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qiskit_gym-0.2.0-cp312-cp312-win_amd64.whl (374.8 kB view details)

Uploaded CPython 3.12Windows x86-64

qiskit_gym-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl (516.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (466.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

qiskit_gym-0.2.0-cp311-cp311-win_amd64.whl (372.5 kB view details)

Uploaded CPython 3.11Windows x86-64

qiskit_gym-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl (513.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (466.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

qiskit_gym-0.2.0-cp310-cp310-win_amd64.whl (371.4 kB view details)

Uploaded CPython 3.10Windows x86-64

qiskit_gym-0.2.0-cp310-cp310-manylinux_2_34_x86_64.whl (514.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (468.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

qiskit_gym-0.2.0-cp39-cp39-win_amd64.whl (373.4 kB view details)

Uploaded CPython 3.9Windows x86-64

qiskit_gym-0.2.0-cp39-cp39-manylinux_2_34_x86_64.whl (515.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (470.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file qiskit_gym-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: qiskit_gym-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 374.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for qiskit_gym-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f90854fcc65595b9811a84ddf32aaa3e0c2ee6114792cf08d4b65f1fa6a3e7ff
MD5 c86516e29b08be59a385563b6062d81b
BLAKE2b-256 895974e4efd1ab3f1e70a504be1120aac5e3a9169f02f60ba4621e86a0e8656b

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 45aad4ca46cce28dbd47f325970a7f36ddc3ae74dc628ae1a1570a25df7d24e5
MD5 2dc10c495be2fb41deedf8cd9ef32100
BLAKE2b-256 daea74414da3720028f66e6db48f7a9d57f4ea0b24fcfe643cc39571584730eb

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a126fab6c62c409dc76ec846d3e71a383c16e3d5ee4a07581b3b11f507c2231a
MD5 096ec4cc7f79d1626d277b4d60269047
BLAKE2b-256 88f1100e8e1659d240aa64467810a502711e239c8915313efc0698b502cd8d45

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: qiskit_gym-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 372.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for qiskit_gym-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e71c1cb9af6e7259aadd906ea8fdde85ca29d9fb6d7a0f8f4622348a44f06590
MD5 44a33aa547554db448243275db01f1d5
BLAKE2b-256 9910ae6705dccdd3e7a36d56527101f48936538e34141020be5a5b82e5401628

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4c1efe76a4a0fb119c26244068bd72d025835a63be9037612116eca510d5f673
MD5 d85a1924fec44f286ec1735fa3d6d8db
BLAKE2b-256 c8e60c03e594d0267808c944f94bc46cf364b072f6f2a20a17ea1af346ad6982

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5071a947c65bbaa37b2bdd700f55649407331f0dfdcd57da6d93459e2ad90a11
MD5 840f96b8949090a8bd90fbd3147db358
BLAKE2b-256 69aacf589518a0b230521e58a54ee8fa5a00e8cf8721887672ed2d04bf41c24e

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: qiskit_gym-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 371.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for qiskit_gym-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e74b07c8e75920189f800deec0b1494884b4e76d694a262442df5ce821842601
MD5 16838669901dd9e3c53ca42693e17053
BLAKE2b-256 d0d2230ca55830ea6de63b2ff6fdf496b761e8da0953c8a72f360dd2d1f3eaf5

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c147ce32b8b395e57020dc10feb09879ea64a48088220d886462f0b4d8fe91a1
MD5 63db046442fb1ba0a300f08db924a006
BLAKE2b-256 042b91cbbf846e9ac6acc29583e9795374e7157c122c4ce6a1d90166e9b6215c

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e14ac79fbb4de2267881b320a3a87a28188c6fa92353a9c08e5d7b51ec20af9
MD5 de738c10fa5296687a94a2218c269de4
BLAKE2b-256 7b8e6d386f4c467f42651e88f7f8507d33a03f9c5000a36ede3ee4f71a36363b

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: qiskit_gym-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 373.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for qiskit_gym-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e22de82332b221bcaa602ed85f4e56edd3b4598020b0afb84f8e92f17decfcf9
MD5 e4f62814f61605e46565a07c842573e1
BLAKE2b-256 29d7758a32812c7b50bc51ef064ab447acf3ed4b56bd6e02aa3d7abcd11e0896

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0ade538bb821201ea718f4478f6bebe37cb4f364ae424202e27c2cedfd42258f
MD5 078aa30a383801f71b65aaf25ef2caca
BLAKE2b-256 1c312c2989e7463b310e0ded54b4f14a3e0be25c8152ed2987f09f8df81757a0

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a762a425e3f13d96465e1dbbcff839bafa0b3bbe4acfe01c28c637ec8fc4b1a8
MD5 f9c2cae8abcd3d1483bcbdfd7159d201
BLAKE2b-256 2520ffee7f21b60d7c78df68eaf48338b8878c460255f9b421e235b40d99169b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page