# Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus

ZX-계산법을 활용한 강화학습 기반 양자 회로 최적화

Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · arXiv · 2023년 12월 18일

- **연구 문제** ZX-다이어그램 간략화에서 어떤 규칙을 적용할지 고르는 문제를 RL로 개선할 수 있는지 다룹니다.
- **연구 방법** PPO로 학습되고 GATv2 그래프 신경망을 쓰는 rl-zx 에이전트가 ZX 그래프 규칙을 선택합니다.
- **주요 결과** 큰 무작위 Clifford+T 회로에서 gflow-zx 기준보다 나은 결과를 보고하며, 구조화된 회로에서는 cflow-zx와 결합해 일부 회로의 2-qubit 게이트 수를 줄입니다.

## ZX-다이어그램 간략화에서 규칙 선택의 어려움

양자 회로 최적화에서 ZX-Calculus는 회로를 그래프 형태의 ZX-다이어그램으로 바꾸어 간략화할 수 있게 합니다. 기존의 대수적 항등식 기반 최적화는 RL 에이전트가 다뤄야 할 행동 공간이 빠르게 커진다는 문제가 있습니다. 이에 비해 ZX 규칙은 종류가 적고 단순하여 행동 공간을 작게 유지할 수 있습니다. 그러나 간략화 후 다이어그램을 다시 회로로 추출하는 과정은 비효율적일 수 있으며, 어떤 규칙 순서가 최적 회로를 주는지 알려진 전략이 없습니다. 이 논문은 규칙 발견이 아니라 이미 주어진 규칙 중 무엇을 적용할지 고르는 과정을 RL로 개선하는 문제를 다룹니다.

## PPO와 GATv2로 구성한 규칙 선택 에이전트

제안된 rl-zx 방법은 무작위 회로를 그래프 형태의 ZX-다이어그램으로 변환한 뒤, 에이전트가 가능한 그래프 변환 중 하나를 골라 적용합니다. 행동 공간은 국소 보완, 피벗, 게이지 융합, 항등 규칙과 종료 행동 STOP으로 제한됩니다. 정책 네트워크와 가치 네트워크는 GATv2 메시지 전달 층으로 구성되며, 각 초록 노드는 다이어그램의 녹색 스파이더에 대응하고 행동 노드는 해당 규칙이 정의하는 노드들과 연결됩니다. 학습은 PPO로 수행되며, 보상은 행동 전후의 게이트 수 차이를 기대 압축량으로 정규화한 값입니다. 두 목표는 전체 게이트 수와 2-qubit 게이트 수이며, 기본 최적화와 teleport reduce를 학습 전에 적용합니다.

또한 에피소드 종료 시 cflow-zx 결과와의 차이를 반영하는 단일 보상을 추가합니다.

![Figure 4: Schematic Overview of the Actor and Pol- icy Networks: The policy network, denoted by π(a\|s), is visualized with each green spider from the diagram c…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-fb0b86ae5d680871df5ab4e90ad4f8cb.png?thumb=512)

**Figure 4** : Schematic Overview of the Actor and Pol- icy Networks: The policy network, denoted by π(a\|s), is visualized with each green spider from the diagram corresponding to a silver node, while the blue wires are depicted as purple connections. Action nodes are high- lighted in orange, with connections to silver nodes and node STOP, which provide a complete description of the actions. The critic network shares a similar architecture; however, the orange node, representing theV (s) output, is not part of the message passing layers. Instead, it is obtained after applying the global attention layer to the outputs of such layers. The self loops are not included for clarity.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 10쪽에서 그림 영역을 추출했습니다.

## 무작위 회로에서의 일반화 검증

무작위 Clifford+T 회로에 대한 실험에서 저자들은 5 qubit, 60 또는 70 게이트 회로로 학습한 에이전트를 최대 80 qubit, 2100 게이트 회로까지 시험합니다. 2-qubit 게이트 수 기준으로 rl-zx의 최선 결과는 gflow-zx와 비교되며, 실험 조건상 각 설정마다 1000 에피소드가 사용되었습니다. 원문은 큰 회로에서 rl-zx가 기준보다 나은 결과를 80% 이상의 경우에 얻는다고 보고합니다. 다만 같은 무작위 분포의 회로에서는 cflow-zx 결과보다 거의 100%의 평가 회로에서 나쁘다고 보고되어, 이 결과는 gflow 기준 비교와 cflow 기준 비교를 구분해서 읽어야 합니다.

![Figure 5: Box plot of the number of gates reduced by the rl-zx agent once trained. The initial value for comparison corresponds to the amount of gates af- ter…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-e1df948c5fa024d0bb0795dc6e1cad67.png?thumb=512)

**Figure 5** : Box plot of the number of gates reduced by the rl-zx agent once trained. The initial value for comparison corresponds to the amount of gates af- ter basic optimization and teleport reduce algo- rithms are applied to the circuit. Tests are performed for two-different tasks and across several circuit sizes, both in terms of number of qubits and average circuit depth. Statistics are drawn from one-thousand execu- tions of random circuits for each circuit size and task. (a) Reduced single-qubit and two-qubit gates. Different shades of green depict different amount of qubits. (b) Number of two-qubit gates reduced. Different shades of blue depict different amount of qubits.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 12쪽에서 그림 영역을 추출했습니다.

![Figure 8: Percentage of test instances for which each optimizer achieves the best two-qubit gate compression, denoted as ”Win Probability” for brevity. Results…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-faa5c0758753b4fb14c69e0ab69bde9f.png?thumb=512)

**Figure 8** : Percentage of test instances for which each optimizer achieves the best two-qubit gate compression, denoted as ”Win Probability” for brevity. Results are shown for the same 1000 instances per circuit size and task. Our approach, rl-zx, is depicted in orange. ’gate-based’ (dark blue) refers to the results after basic optimization and teleport reduce are applied to the initial random circuit, and gflow-zx is depicted in yellow. Circuits for which rl-zx ties with either of its competitors are represented as ”draw” (light blue).

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 14쪽에서 그림 영역을 추출했습니다.

![Figure 9: Distribution of the difference in 2-qubit gates between gflow-zx and our approach for both optimizations tasks and all tested circuit sizes. A positi…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-b140abc23ebded92c006dd201b55d0db.png?thumb=512)

**Figure 9** : Distribution of the difference in 2-qubit gates between gflow-zx and our approach for both optimizations tasks and all tested circuit sizes. A positive gate difference implies that rl-zx achieves a better compression. Vertical lines, in red, signal a tie between both algorithms. Coloured dashed lines mark the quartiles of the distribution.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 14쪽에서 그림 영역을 추출했습니다.

## 구조화된 회로 실험과 cflow-zx 결합

구조화된 회로 실험에서는 보상과 워크플로를 바꾼 뒤 rl-zx를 cflow-zx와 결합합니다. 이 설정에서 Table 2의 일부 회로는 rl-zx와 cflow-zx를 함께 사용했을 때 cflow-zx 단독보다 2-qubit 게이트 수가 줄어든 것으로 보고됩니다. 저자들은 이 결과를 gflow 기반 행동 선택이 cflow 최적화와 결합될 때 유용할 수 있다고 해석합니다. 확률적 정책은 여러 시도를 허용하므로, 결정적 정책 rl-zx-det와 cflow-zx를 비교한 Table 3에서는 13개 회로에서만 개선이 확인됩니다. 이 결과는 1000회 시도라는 조건과 결정적 정책이라는 조건을 함께 고려해야 합니다.

![Figure 11: Comparison of the two qubit gates distribution obtained for the for rl-zx + cflow-zx (orange) and the random-zx (in blue) for different circuits. In…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-fe6bf84a780c8150691ae8be281bdc50.png?thumb=512)

**Figure 11** : Comparison of the two qubit gates distribution obtained for the for rl-zx + cflow-zx (orange) and the random-zx (in blue) for different circuits. In a dashed black line is depicted the two qubit gates obtained by the cflow-zx. a) First two columns. Circuits for which an execution of the random policy achieved the optimal result. (b) Last two columns. Circuits for which an execution of the rl-zx + cflow-zx achieved the optimal result.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 18쪽에서 그림 영역을 추출했습니다.

![Table 2: Comparison between the results obtained by several optimizers on structure quantum circuits for relevant applications. Results in bold show the minimu…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-1e83e8a457be8204dc7cd3651101f19e.png?thumb=512)

**Table 2** : Comparison between the results obtained by several optimizers on structure quantum circuits for relevant applications. Results in bold show the minimum amount of 2-qubit gates observed for each circuit. Additionally, circuits for which the rl-zx optimizer improves on cflow-zx alone are referenced with an asterisk. The equivalence between initial and final circuits has been validated for all circuits excepting QFT16, QFT32 and QFTAdd8, due to limitations in computational resources. However, cflow and gflow preservation should guarantee its validity.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 19쪽에서 그림 영역을 추출했습니다.

![Table 3: Comparison between the two-qubit gates ob- tained by the deterministic rl-zx policy, rl-zx-det, and the cflow-zx, only including those circuits for wh…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-afe0aaedbf4e0382d403b5307721b5a0.png?thumb=512)

**Table 3** : Comparison between the two-qubit gates ob- tained by the deterministic rl-zx policy, rl-zx-det, and the cflow-zx, only including those circuits for which there is a gain.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 19쪽에서 그림 영역을 추출했습니다.

## 계산 비용과 적용 범위의 한계

저자들은 에이전트가 gflow-zx보다 약 4배에서 10배 느리다고 보고합니다. 또한 STOP 행동을 언제 선택할지가 가장 어려운 문제로 제시되며, 큰 회로에서는 가능한 행동 수가 늘어나 잘못된 피벗 선택이 2-qubit 게이트 수를 크게 바꿀 수 있습니다. 학습은 약 16시간이 걸리며, 무작위 회로 학습만으로 구조화된 회로의 모든 경우에 우위가 있다고 보장되지 않습니다. 일부 구조화된 회로에서는 cflow-zx보다 결과가 나쁠 수 있으므로, 이 방법의 개선은 특정 워크플로와 보상 설계에 종속된 결과로 이해해야 합니다.

![Figure 6: Box plot of the number of actions taken dur- ing an episode by the rl-zx once trained. Results are drawn from the same tests used to depict the amoun…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-712fad68ce130d2f24ab34678af04fff.png?thumb=512)

**Figure 6** : Box plot of the number of actions taken dur- ing an episode by the rl-zx once trained. Results are drawn from the same tests used to depict the amount of gates reduced. Different shades of green and blue depict different amount of qubits. (a) Actions performed when trying to reduce both single-qubit and two-qubit gates. (b) Actions performed when trying to reduce two-qubit gates.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 13쪽에서 그림 영역을 추출했습니다.

![Figure 7: Average number of actions of each type performed per episode by the agent. For clarity, only pivotings ( p (orange), local complementations ( lc) (bl…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-437bd8d5bf5289ac7092db54e4fbb4b7.png?thumb=512)

**Figure 7** : Average number of actions of each type performed per episode by the agent. For clarity, only pivotings ( p (orange), local complementations ( lc) (blue), and identity rules ( id) (purple) are considered. The non-represented actions are scarcely selected by the agent. Shaded regions represent the interval between percentile 15 and 85 of the distribution. Results are drawn from the same instances. (a) Policy learnt for single-qubit and two-qubit gate reduction. (b) Policy learnt for only two-qubit gate reduction.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 14쪽에서 그림 영역을 추출했습니다.

![Figure 10: Comparison of the average episode execution time, in seconds, for the gflow-zx and our approach (dashed lines), with color code dependent on each re…](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513/figures/figure-47b91199613a9388de7f210cfb96e4e6.png?thumb=512)

**Figure 10** : Comparison of the average episode execution time, in seconds, for the gflow-zx and our approach (dashed lines), with color code dependent on each relevant circuit dimension. (a) Scaling with respect to the average circuit depth. (b) Scaling with respect to the amount of qubits.

[원문](https://arxiv.org/abs/2312.11597v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas · Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus · 원문 그림 인용 · 원본 PDF 16쪽에서 그림 영역을 추출했습니다.

## 논문 정보

- **저자**: Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2023년 12월 18일
- **등록일**: 2026년 11월 6일
- **수정일**: 2025년 5월 22일
- **버전**: v4
- **arXiv**: 2312.11597
- **DOI**: 10.22331/q-2025-05-28-1758
- **분류**: quant-ph
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2312.11597v4) · [원문 PDF ↗](https://arxiv.org/pdf/2312.11597v4)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

We propose a novel Reinforcement Learning (RL) method for optimizing quantum circuits using graph-theoretic simplification rules of ZX-diagrams. The agent, trained using the Proximal Policy Optimization (PPO) algorithm, employs Graph Neural Networks to approximate the policy and value functions. We demonstrate the capacity of our approach by comparing it against the best performing ZX-Calculus-based algorithm for the problem in hand. After training on small Clifford+T circuits of 5-qubits and few tenths of gates, the agent consistently improves the state-of-the-art for this type of circuits, for at least up to 80-qubit and 2100 gates, whilst remaining competitive in terms of computational performance. Additionally, we illustrate the versatility of the agent by incorporating additional optimization routines on the workflow during training, improving the two-qubit gate count state-of-the-art on multiple structured quantum circuits for relevant applications of much larger dimension and different gate distributions than the circuits the agent trains on. This conveys the potential of tailoring the reward function to the specific characteristics of each application and hardware backend. Our approach is a valuable tool for the implementation of quantum algorithms in the near-term intermediate-scale range (NISQ).

## 원문 인용

Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, Marta P. Estarellas (2023). Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus. arXiv:2312.11597v4. https://doi.org/10.22331/q-2025-05-28-1758

**BibTeX**

```
@article{riu2023reinforcement,
  title = {{Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus}},
  author = {Jordi Riu and Jan Nogué and Gerard Vilaplana and Artur Garcia-Saez and Marta P. Estarellas},
  year = {2023},
  eprint = {2312.11597},
  archivePrefix = {arXiv},
  doi = {10.22331/q-2025-05-28-1758},
  url = {https://arxiv.org/abs/2312.11597v4}
}
```

## 이 논문의 용어

- [Proximal Policy Optimization](https://refivu.com/terms/59b59e5d0f9d-proximal-policy-optimization)
- [Graph Neural Networks](https://refivu.com/terms/0650d076a410-graph-neural-networks)
- [GATv2](https://refivu.com/terms/91a38a2e1069-gatv2)
- [Win Probability](https://refivu.com/terms/9eb2393b3c06-win-probability)
- [ZX-Calculus](https://refivu.com/terms/b7ed413f8fb9-zx-calculus)

## 다른 논문 해설

- [Reinforcement Learning Enables Autonomous Microrobot Navigation and Intervention in Simulated Blood Capillaries](https://refivu.com/papers/b9ae767b-8329-4e10-b4ff-ff861e429084-reinforcement-learning-enables-autonomous-microrobot.md)
- [Multiagent Reinforcement Learning in Enhancing Resilience of Microgrids under Extreme Weather Events](https://refivu.com/papers/c58dc10c-5e05-4c09-86c1-8b6189cb1f80-multiagent-reinforcement-learning-in-enhancing-resilience-of.md)
- [Safety-aware Causal Representation for Trustworthy Offline Reinforcement Learning in Autonomous Driving](https://refivu.com/papers/405e85e8-5f04-4315-a8f3-fb9bf2c907d9-safety-aware-causal-representation-for-trustworthy-offline.md)
- [Subgoal-based Reward Shaping to Improve Efficiency in Reinforcement Learning](https://refivu.com/papers/7cfae1a0-d6ce-434e-9208-ba670a0a87d0-subgoal-based-reward-shaping-to-improve-efficiency-in.md)
- [HumanLight: Incentivizing Ridesharing via Human-centric Deep Reinforcement Learning in Traffic Signal Control](https://refivu.com/papers/e2d488b7-f8ef-4b13-bcd8-ed7fdeab5df5-humanlight-incentivizing-ridesharing-via-human-centric-deep.md)
- [AR3n: A Reinforcement Learning-based Assist-As-Needed Controller for Robotic Rehabilitation](https://refivu.com/papers/9baf7e20-8ddc-405a-84ce-beae1469aefa-ar3n-a-reinforcement-learning-based-assist-as-needed.md)
- [Sub-Character Tokenization for Chinese Pretrained Language Models](https://refivu.com/papers/a75de90a-ad7d-45cd-bc9d-49a90497b87d-sub-character-tokenization-for-chinese-pretrained-language.md)
- [Assessing Text Classification Methods for Cyberbullying Detection on Social Media Platforms](https://refivu.com/papers/7faefd2d-5919-41ff-8a98-9f4d1c5bfc04-assessing-text-classification-methods-for-cyberbullying.md)
- [StretchBot: A Neuro-Symbolic Framework for Adaptive Guidance with Assistive Robots](https://refivu.com/papers/1f4b72e7-879e-4dae-9cdc-89e5395dd7dc-stretchbot-a-neuro-symbolic-framework-for-adaptive-guidance.md)
- [Semiautomatic dimensional screening of plastic scintillator cubes using image analysis and robotics](https://refivu.com/papers/da6a016f-0839-4544-9dcf-2c97f57e25fe-semiautomatic-dimensional-screening-of-plastic-scintillator.md)
- [AttentionViz: A Global View of Transformer Attention](https://refivu.com/papers/070e8eaa-a548-44ca-8077-3ab478512ec5-attentionviz-a-global-view-of-transformer-attention.md)
- [V3D: Video Diffusion Models are Effective 3D Generators](https://refivu.com/papers/7ac7016e-0685-4edf-a818-3baccf2777ee-v3d-video-diffusion-models-are-effective-3d-generators.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/9c8e6aa3-4291-4395-9813-828baebb2513-reinforcement-learning-based-quantum-circuit-optimization)
