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.1-cp313-cp313-win_amd64.whl (374.8 kB view details)

Uploaded CPython 3.13Windows x86-64

qiskit_gym-0.2.1-cp313-cp313-manylinux_2_34_x86_64.whl (514.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (465.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

qiskit_gym-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl (489.3 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

qiskit_gym-0.2.1-cp312-cp312-win_amd64.whl (375.4 kB view details)

Uploaded CPython 3.12Windows x86-64

qiskit_gym-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl (516.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (466.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

qiskit_gym-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl (489.8 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

qiskit_gym-0.2.1-cp311-cp311-win_amd64.whl (372.1 kB view details)

Uploaded CPython 3.11Windows x86-64

qiskit_gym-0.2.1-cp311-cp311-manylinux_2_34_x86_64.whl (514.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (465.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

qiskit_gym-0.2.1-cp311-cp311-macosx_10_12_x86_64.whl (489.7 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

qiskit_gym-0.2.1-cp310-cp310-win_amd64.whl (371.9 kB view details)

Uploaded CPython 3.10Windows x86-64

qiskit_gym-0.2.1-cp310-cp310-manylinux_2_34_x86_64.whl (514.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.1-cp310-cp310-macosx_11_0_arm64.whl (467.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

qiskit_gym-0.2.1-cp310-cp310-macosx_10_12_x86_64.whl (490.6 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

qiskit_gym-0.2.1-cp39-cp39-win_amd64.whl (373.9 kB view details)

Uploaded CPython 3.9Windows x86-64

qiskit_gym-0.2.1-cp39-cp39-manylinux_2_34_x86_64.whl (515.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

qiskit_gym-0.2.1-cp39-cp39-macosx_11_0_arm64.whl (469.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

qiskit_gym-0.2.1-cp39-cp39-macosx_10_12_x86_64.whl (492.4 kB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for qiskit_gym-0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 caff3e5c4f7902d58aafce977fcad15c7e9cfe465f72ed7b381a23a525d509ef
MD5 73be4bf2b6ba3434f246561a63bba6dd
BLAKE2b-256 ed02ffb19e360fe5be8630826f33a8b8da44cb12d23fb8264b11859fa681ba90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 86e00bfa06bb7cc12d21cbd11770d7df41eee807747f70d2b13724b5f9f32925
MD5 b2a16c3d26a20aff83c42ebabebdb103
BLAKE2b-256 b184a0b85e5a4c7d8e9d4112740028b43a2395968722aaf1dbce7ea3d2a4fa8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be8db8374082f42f411baf5a81b073b1610f697d74ae4584f4118b069f91aa07
MD5 126916e74f40021d4badfe24acf01dc1
BLAKE2b-256 e1a8b68c912e9c107926a9dbd65d08c2edae98e4dd4c623c00dac426776f3cd2

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6828ec091678859ff0c7c19f3217cf444b28df83eec3c08fd0fcda53ad34e8a3
MD5 53a40296b904d32176e99e7a6160049c
BLAKE2b-256 66b44d8f178ddd52693c31bc627453450d1740dae71ae1108b80360f638de890

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qiskit_gym-0.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 375.4 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c1e9f908da1598cb7b4f9b6e65bafe7bc80dc492bfbcd76395ac1d6470b12d4e
MD5 32e4c8921d00f3fde04caedced019060
BLAKE2b-256 bdcf53cf74326283b38d1b0db002e9659e1c55c20c384d41c1d0d21f5f095ba2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 050191a776a3ede4003cc2555bee3f6bcffbc87738b1630e382dd9660dab7395
MD5 669f1df49bb414fa21130b05e14df35f
BLAKE2b-256 d86074826afa45d7adbdf8af5bf95924c0ee3a5a6f5f9036c9e25300b7888e50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 914c04652ea4daeb4973e7e990cceabc144b3718a2b4891d76c76b479502b4f5
MD5 636cee39d5015c2d3e03ae6ede32e0f2
BLAKE2b-256 4554546a6a1fdefd0748fd41daec7803e5346fbc4175c61afb9535b406fcb629

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9ddfe8de39b550cf7507b2faee7b3c005e9b594c7eb54673f5494000b9d3fb78
MD5 97c88fd034600cf56bfc7636d6175c79
BLAKE2b-256 114c0c8473e226dc0a09fc0c2d39e4e9bc4c6a36004f8761e8f7dbbe747d11d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qiskit_gym-0.2.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 372.1 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e443489e8d5614595b2d812bc2fdddd7999e684757ff22627c3ce1d9dab0b49a
MD5 491933e6d5e670a96e676670290fb25b
BLAKE2b-256 2c552bce89f9dcf208e247f7a3e3c0fcb4a8a64703cc61524a830b3487cb1610

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7fa24c9ff5665c883d9603f5b67f4364a7c6984e28d1e530f1cca8c9f19a764a
MD5 e7ded7e20714e7c82b6705181d3dd97a
BLAKE2b-256 cef0100d735b79511ddbbc85de8032ad1cfa9dce8b90bf01a0f9917624793ff3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1bc617057cb2271e19b9109213729b540888d011785ba4a24a4a05e6060bc32d
MD5 0c05060862024dcdcb9c0ea27ba7b2db
BLAKE2b-256 339ec8ae1ba3a2932fe384ecdd8090ff867541e61f38fb6d5c18efc80038129f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c130a03db6304341764f571b08b8c20bda5357d49623b01711f9c5e4b5c4cbde
MD5 8c3342569621d4bbc54ad7c5d4cb1816
BLAKE2b-256 683bcaf48a2ecfcce6b3e2a0a4b61b1cfb5fde91d64f31fdcfaa049d3e977bf5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qiskit_gym-0.2.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 371.9 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6a87409f846c5ab91ce406a18a51aec323b79e6e407c2af822d18404b1947f13
MD5 61c0781946c4fb528fc7e03ea71fe36c
BLAKE2b-256 790bd138a87612bb82b61dfe0976e93eb22bad025077a372cc173c2196101cc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3e043a211240932d24c20e13ab46cb65b86afab6dd8f1189874a9ed80e5fdee6
MD5 6d87b6237d591063d7005390e69d12f5
BLAKE2b-256 e214b911b936f62ada3e7daeb2060748a8e345e6afbc340a614863e8dc80c271

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b2f5bcfbff8b9a23df3b0fbadfe23de438ebdebf559c56d2af496a8dc1277231
MD5 cfa665b3f8d9d1498871acd2befaa3e1
BLAKE2b-256 b95079dafe0845ea37cf440e2be8be5e9200bf5633a0fbd4330cd03e8017db64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dbbde00c25d2dbf63a7aa6ed2f6a3f240ef4ca95dc71712309d6b1c9e7693b0b
MD5 156268d45b344ff41b03e18d809bf5c3
BLAKE2b-256 b957b57f5f355c31ece0fbf2a409dcfad209da186fe40ac90f5c5f56d223d624

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qiskit_gym-0.2.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 373.9 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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ca54cf9c3326fb7eaaa4aeeb162af6e876a78008997ede7a89482e2e6ff803cb
MD5 c094fae5818d06356a78b22c6c654abe
BLAKE2b-256 d31b699ecb73f7e6d01364d8c669ec7865746ca40ecb6dc495ae019f975b6fa4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b911c09962eeb629601d0be8dc06e8a0bf804fbc9ebc230852b931be2f6f82dd
MD5 84a2e64c9c8f9676afd46d20776e496e
BLAKE2b-256 29545486574e10a69964773147301e043a4c7063aeeac4241dc9dfdc8b67c048

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cd5efdd21c7e72a18ef4955f026881497eefd885cc41cd21a753068638e096a
MD5 867e15f6d20dd530223f1ca61ac84930
BLAKE2b-256 7c728b7efbde42b95f1e8e37525b8d8394717ddfc993cc57b465105a29735b13

See more details on using hashes here.

File details

Details for the file qiskit_gym-0.2.1-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_gym-0.2.1-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fffd3d12a639fecc7e9b38197b236f6eae2614e34c46df2a065633077929c9b8
MD5 6be0cef99368a2906d90fc1345e1d654
BLAKE2b-256 c87ae6d468182a32b23d105a3b37c27773ad70d7fcbfeadb9c1916458d8b324d

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