How qilimanjaro-tech/circopt-rl-zxcalc works
Project type and purpose
• This is a research‐grade, full‐stack Python tool for “Reinforcement Learning Based Quantum Circuit Optimization via ZX‐Calculus.”
• It provides:
• A custom OpenAI‐Gym environment for ZX‐calculus circuit transformations
• An RL agent that learns optimization policies
• Experiment scripts that run the agent on benchmark circuits and produce JSON results
• Jupyter notebooks to generate figures and tables for the paper
File structure
• Top‐level files:
• README.md, requirements.txt, installation.py
• rl_agent.py: the core agent architecture
• agent_test.py & benchmark.py: entry points that run experiments and gather stats
• Jupyter notebooks (benchmark.ipynb, results.ipynb) for data processing and visualization
• “rl-zx/gym-zx” is a pip‐installable Python package defining the Gym environment:
• gym_zx/envs/zx_env.py implements the ZX‐calculus environment
• setup.py makes it installable as gym-zx
• “rl-zx/results” stores:
• Raw circuits (Original, gflow-cflow-opt, NRSCM, rl-zx-opt) in subfolders
• JSON statistics under results/data (random_stats, rl_stats)
• Figures and time‐depth JSON within results/5x60_non_clifford
README for additional insights
• The README explicitly points to:
• Agent code in rl_agent.py
• Environment in gym_zx/envs/zx_env.py
• Scripts that generate data for figures (agent_test.py, benchmark.py, results.ipynb)
• It describes four optimization backends:
Original, Staudacher+Holker (gflow-cflow-opt), Nam et al. (NRSCM), and the new RL agent (rl-zx-opt).
Detail
• Four optimization backends as distinct flows
• How installation.py and setup.py fit into packaging/install
• Which modules import from which (e.g., agent_test.py imports rl_agent and gym_zx)
• Agent–environment interface via standard Gym methods (reset(), step(), render())