Linear Function Quantum Synthesis Circuit Models
Introduction
This repository hosts models for linear function synthesis in quantum circuits trained with RL techniques. The models are specialized for different topologies up to 10 qubits.
A linear function over n qubits is an n×n binary transformation on X/Z operators (the reversible linear part of a Clifford). Implementing it means finding CX/SWAP-based circuits whose action matches that binary map. More information about Linear Funtion circuits
For each model, there is the environment configs (.json) and the trained policy weights (.safetensors).
Scope
- Linear-function synthesis models.
- 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
gatesetproperty in the model's config.
Contents
linear_function_*.json: model configs for a given qubit count/topology.- Matching
.safetensorsfiles: 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.
Data Collection: Target operators are generated by sampling random linear-reversible circuits with CNOT gates 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
Here we provide a code snippet to synthesis a random 10qL linear function. In addition to the model we use the qiskit-gym (repo) and twisteRL (repo) libraries, as well as qiskit. You can install all needed libraries running pip install qiskit-gym in your python virutal environment.
from qiskit_gym.rl import RLSynthesis
from twisterl.utils import pull_hub_algorithm
from qiskit.circuit.library import LinearFunction
from qiskit.synthesis.linear.linear_matrix_utils import random_invertible_binary_matrix
local_path = pull_hub_algorithm(
repo_id="Qiskit/ai-transpiler_linear-functions",
model_path="./models",
revision="main",
validate=True
)
if not local_path:
raise ValueError("Failed to download model from hub")
num_qubits = 10
matrix = random_invertible_binary_matrix(num_qubits, seed=42)
input_lf = LinearFunction(matrix)
rls = RLSynthesis.from_config_json(f"{local_path}/linear_function_10qL.json", f"{local_path}/linear_function_10qL.safetensors")
qc_lf_output = rls.synth(input_lf, num_searches=10, num_mcts_searches=0, deterministic=False)
print(qc_lf_output)
Models
Below is the list of available models with qubit counts and topologies:
| Model | Qubits | Topology |
|---|---|---|
linear_function_2qL |
2 | L |
linear_function_3qL |
3 | L |
linear_function_4qL |
4 | L |
linear_function_4qY |
4 | Y |
linear_function_5qL |
5 | L |
linear_function_5qT |
5 | T |
linear_function_6qL |
6 | L |
linear_function_6qT |
6 | T |
linear_function_6qY |
6 | Y |
linear_function_7qF |
7 | F |
linear_function_7qH |
7 | H |
linear_function_7qL |
7 | L |
linear_function_7qT |
7 | T |
linear_function_7qY |
7 | Y |
linear_function_8qF |
8 | F |
linear_function_8qJ |
8 | J |
linear_function_8qL |
8 | L |
linear_function_8qT1 |
8 | T1 |
linear_function_8qT2 |
8 | T2 |
linear_function_8qY |
8 | Y |
linear_function_9qF1 |
9 | F1 |
linear_function_9qF2 |
9 | F2 |
linear_function_9qH1 |
9 | H1 |
linear_function_9qH2 |
9 | H2 |
linear_function_9qH3 |
9 | H3 |
linear_function_9qJ |
9 | J |
linear_function_9qL |
9 | L |
linear_function_9qT1 |
9 | T1 |
linear_function_9qT2 |
9 | T2 |
linear_function_9qY |
9 | Y |
linear_function_10qL |
10 | L |
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.