Views
No views yet

.json) and the trained policy weights (.safetensors).gateset property in the model's config.linear_function_*.json: model configs for a given qubit count/topology..safetensors files: trained policies for each JSON (same filename stem).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.1from qiskit_gym.rl import RLSynthesis
2
3from twisterl.utils import pull_hub_algorithm
4
5from qiskit.circuit.library import LinearFunction
6from qiskit.synthesis.linear.linear_matrix_utils import random_invertible_binary_matrix
7
8local_path = pull_hub_algorithm(
9 repo_id="Qiskit/ai-transpiler_linear-functions",
10 model_path="./models",
11 revision="main",
12 validate=True
13)
14
15if not local_path:
16 raise ValueError("Failed to download model from hub")
17
18num_qubits = 10
19matrix = random_invertible_binary_matrix(num_qubits, seed=42)
20input_lf = LinearFunction(matrix)
21rls = RLSynthesis.from_config_json(f"{local_path}/linear_function_10qL.json", f"{local_path}/linear_function_10qL.safetensors")
22qc_lf_output = rls.synth(input_lf, num_searches=10, num_mcts_searches=0, deterministic=False)
23print(qc_lf_output)