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.4.0-cp314-cp314-win_amd64.whl (987.5 kB view details)

Uploaded CPython 3.14Windows x86-64

qiskit_gym-0.4.0-cp314-cp314-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

qiskit_gym-0.4.0-cp314-cp314-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

qiskit_gym-0.4.0-cp313-cp313-win_amd64.whl (986.7 kB view details)

Uploaded CPython 3.13Windows x86-64

qiskit_gym-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

qiskit_gym-0.4.0-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

qiskit_gym-0.4.0-cp312-cp312-win_amd64.whl (986.9 kB view details)

Uploaded CPython 3.12Windows x86-64

qiskit_gym-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

qiskit_gym-0.4.0-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

qiskit_gym-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

qiskit_gym-0.4.0-cp311-cp311-win_amd64.whl (987.7 kB view details)

Uploaded CPython 3.11Windows x86-64

qiskit_gym-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

qiskit_gym-0.4.0-cp311-cp311-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

qiskit_gym-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

qiskit_gym-0.4.0-cp310-cp310-win_amd64.whl (987.8 kB view details)

Uploaded CPython 3.10Windows x86-64

qiskit_gym-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

qiskit_gym-0.4.0-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

qiskit_gym-0.4.0-cp310-cp310-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file qiskit_gym-0.4.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: qiskit_gym-0.4.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 987.5 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for qiskit_gym-0.4.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 4f89407a3f860e7fbadef00eebe5e4c3af4fa515d75e3e1cb520cf4e03e2fedc
MD5 7538c8f09f4788aabf9dbc4cc7ebad12
BLAKE2b-256 6e64ef8c87b32275b035a49e64e1838f20ea2356cc3aba1457d3ac441e7806a4

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3bd12cc2cf1a431b788ddc85f030cacb2c2498877ee3ec810ae9e535e701e299
MD5 bfef013f38ca6aa73226014e88256765
BLAKE2b-256 6f2d692d18b3480103d97a97c9998854d22e3d0680491520e87caf757c5a32b8

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 caa9a341df41938d324928312bb99eb6ad95a0ee2fa06ce2dc6dd0d6b209f0fe
MD5 f0c0684b1af84cb03317f4c728e06b91
BLAKE2b-256 9159a28c7539c3612058221dfd9ab5f8b16e2aa4a1444e8e3ca04546b5e9f891

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: qiskit_gym-0.4.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 986.7 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for qiskit_gym-0.4.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 941785febae3df69ce78a0d2338a3abaca9ac7498ac8825c888fb824611d86d3
MD5 9a20cae4df2e51223c3b64ff3a0c9547
BLAKE2b-256 06eaca2a7cc1bf6411c7b1910316688ad215b370c2f0a67d8713b0b25d0b0efe

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 52563838d77703f52f5d84e9b7af874b8336f5be2f7e33b10b32e53f78653b37
MD5 b333216f8be14dd98a65ae67ddea30a7
BLAKE2b-256 b24af1509fd0de90ef2b985426b2033688e6b81b535f54e650559393823fc795

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3eb2a9417aa68c6228a69698608c98f4560b698b0e7b08a94e1b41a5d5e8289d
MD5 0006ba94b8146b2663dd90ccf9a4b2ae
BLAKE2b-256 cd5728bb956720ef008c28aecd641506f095e882e148c090caa3794ee33d18c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qiskit_gym-0.4.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 986.9 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.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e8f5f3f141d4fa361a9e49126cff68b8fd5c11c5c1466d8fd60242d1f642d53d
MD5 95e502e5d3952cea5a94703c59b208e9
BLAKE2b-256 68fb1b4c4242f16416edbbfb4731fbff16d897a35e8ab76477bcf498855f4519

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0eef7eea83eafe034fb3c0623b443fa8740591a03f712119adf5fbc2d2dfb23e
MD5 d76796c79c5b14b6597b2ec661188550
BLAKE2b-256 3cd1ce7a2bf942e336cbafceb3e17adf757ad5af5003a3cdd77fa9b92767e15c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac4c1ffa3cdfc712cc9c5f608de02e1d492987bb8040bcfc63b8262c5cd795c3
MD5 8040cbc4aa474f59d5ee2d7099f51d49
BLAKE2b-256 bbbacc1cee074650a99e7eb9c7648f905abaf691bc2c92dedfc9427d6dfb5352

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 51f6644b8b345a6217fbde2cec260fcbf1947ecb49710a40c0b978e46b1047be
MD5 5e2db3c209cd868b9089d6c634d6d533
BLAKE2b-256 a70dd406f63c84a4b9a8437c84dc17a50ac0ed85075df87d55973450c1843b57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qiskit_gym-0.4.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 987.7 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.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4de7811ea4c5ea4e7780b878954a96bf9d9665ed654bb703fc3639e19bd54734
MD5 87395313b565c0c4941448b504c78825
BLAKE2b-256 b8c3173d8566e5d7b91fa46ae37bdeef6efd70159fe661d86969008719d15caf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e1f7c82ed9cc48ae3d5ed32976644e5dca1334f6f21c5ab033e20dc61814b728
MD5 10ac4866e87e4f851f413f1c04d5fcf8
BLAKE2b-256 f9574f890d9da15422bac583f3538296f8513dd81146f1e740ee3d62f73cfaf1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06509dc4b40c6c53d551d253cd4a5adcb4ed1e6debe7c9889dda2ea33e2969be
MD5 4711f75ad897ec924f2fc568f9edcddf
BLAKE2b-256 180fd9e661b221ff2f8b0b21a06e34275eef62d8140959b0740785c1bba55608

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 947037caff33761fdb0c0badce4b04d196414f49c02fde645d4650e8eb4f6da4
MD5 d238a776c0a1109ace2fb6af0e6fb230
BLAKE2b-256 1035451066f765f3a957b4fdd75979750a64d9efbc8c21657c7d6d2e08da2010

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qiskit_gym-0.4.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 987.8 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.4.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 544f93d2d4abb2cad9ff1984a733f71df137627473c9ccf39eb3164033dd9350
MD5 6706230281c0381b3d33987dcd1f8f22
BLAKE2b-256 149096d281ae0f10b7093f80cf43e922e7e025925688244851f458ec8ce9c20d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dfe546fe6ebf3de8677af6d804f37da99006feb5738f591637f6fa8e34b2767c
MD5 5ed0ba39f19def8fe27880b09699a847
BLAKE2b-256 834beb1821331aea5d1078c90f8b596568a1f21b4d67ae638c08b3ff0d2f727a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92a853d5cd02bbf5ee42557d3308889fa9b43a771feaedfdd0539c9d4aefa856
MD5 ad55575d3458e30f8dac3021e9380c8e
BLAKE2b-256 f0c2b0867fcf94c5dc34dd3146d57e6f82a06adf89b64fca25b9dccc2a73d37c

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.4.0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.4.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1e109f5cefba6c0c032f6063743eb917f66a361deb803130f6eda35aa70d04ee
MD5 9911a9fac86de392b3b01842a112e37c
BLAKE2b-256 d67ce2736d30d2dc51934b6cb2a3e0d75c37d5a1d2cbc7d56ac29d122af995df

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