--- license: apache-2.0 --- # Permutation Quantum Synthesis Circuit Models ## Introduction This repository hosts models for permutation synthesis in quantum circuits trained with RL techniques. The models are specialized for different topologies and qubit counts. Permutation circuits rearrange computational basis states according to an n-element permutation (one per qubit in binary encoding) using SWAP gates constrained by the device topology. [More info about Permutation circuits in Qiskit](https://quantum.cloud.ibm.com/docs/en/api/qiskit/qiskit.circuit.library.Permutation) For each model, there is the environment config (`.json`) and the trained policy weights (`.safetensors`). ## Scope - Permutation synthesis models only. - Each model is tied to a specific qubit count and topology; use the matching pair for your target device/layout. To discover the specific topology for each model see the `gateset` property in the model's config. ## Contents - `permutation_*.json`: model configs for a given qubit count/topology. - Matching `.safetensors` files: trained policies for each JSON (same filename stem). ## Training Training data is entirely synthetic and generated internally at IBM Quantum using custom reinforcement learning environments built on [Qiskit-Gym](https://github.com/AI4quantum/qiskit-gym). **Data Collection:** Random permutation operators are generated by composing random SWAP sequences consistent with the target coupling map. The number of gates scales with the difficulty, which increase when the model learns to solve circuits at that difficulty. No external datasets or third-party circuit repositories are used. **PII:** No personal or sensitive data is present or used in any phase of training, as all data is synthetic and generated algorithmically. **Infrastructure:** We train the models using IBM's Cognitive Computing Cluster (CCC) using NVIDIA A100 40GB GPUs. The cluster provides a scalable and efficient infrastructure for training. ## Usage example Below is a snippet to synthesize a random 10-qubit permutation. We use `qiskit-gym` ([repo](https://github.com/AI4quantum/qiskit-gym)), `twisteRL` ([repo](https://github.com/AI4quantum/twisteRL)), and `qiskit`. Install dependencies via `pip install qiskit-gym` in your virtual environment. ```python from qiskit_gym.rl import RLSynthesis from twisterl.utils import pull_hub_algorithm from qiskit.circuit.library import Permutation import numpy as np local_path = pull_hub_algorithm( repo_id="Qiskit/ai-transpiler_permutations", model_path="./models", revision="main", validate=True, ) if not local_path: raise ValueError("Failed to download model from hub") num_qubits = 12 seed = 42 input_perm = np.random.default_rng(seed).permutation(num_qubits).tolist() rls = RLSynthesis.from_config_json( f"{local_path}/permutation_12qO.json", f"{local_path}/permutation_12qO.safetensors", ) qc_perm_output = rls.synth(input_perm, num_searches=10, num_mcts_searches=0, deterministic=False) print(qc_perm_output) ``` ## Models Below is the list of available models with qubit counts and topologies: | Model | Qubits | Topology | | --- | --- | --- | | [`permutation_8qL`](model_data/permutation_8qL.md) | 8 | L | | [`permutation_12qO`](model_data/permutation_12qO.md) | 12 | O | | [`permutation_27q`](model_data/permutation_27q.md) | 27 | HEX | | [`permutation_33q`](model_data/permutation_33q.md) | 33 | HEX | | [`permutation_65q`](model_data/permutation_65q.md) | 65 | HEX | ## Acknowledgements The authors acknowledge the IBM Research CCC Service for providing resources that have contributed to the production or processing of the data contained within this data collection.