# Diagrammatic Differentiation for Quantum Machine Learning

arXiv: https://arxiv.org/abs/2103.07960 · HTML: https://mlsanity.com/paper/2103.07960/

## Key facts

- Cited by 5 papers in the map (data through 14 Oct 2026).
- Builds on 10 of its 44 references that are in the map.
- First posted on arXiv 14 Mar 2021.

## Builds on (most cited first, 10 of 10)

- [Supervised learning with quantum enhanced feature spaces](https://mlsanity.com/paper/1804.11326/) (2018)
- [Parameterized quantum circuits as machine learning models](https://mlsanity.com/paper/1906.07682/) (2019)
- [Foundations for Near-Term Quantum Natural Language Processing](https://mlsanity.com/paper/2012.03755/) (2020)
- [Categorical Foundations of Gradient-Based Learning](https://mlsanity.com/paper/2103.01931/) (2021)
- [Quantum Natural Language Processing on Near-Term Quantum Computers](https://mlsanity.com/paper/2005.04147/) (2020)
- [Analyzing the barren plateau phenomenon in training quantum neural networks with the ZX-calculus](https://mlsanity.com/paper/2102.01828/) (2021)
- [Graph-theoretic Simplification of Quantum Circuits with the ZX-calculus](https://mlsanity.com/paper/1902.03178/) (2019)
- [Reverse derivative categories](https://mlsanity.com/paper/1910.07065/) (2019)
- [Phase Gadget Synthesis for Shallow Circuits](https://mlsanity.com/paper/1906.01734/) (2019)
- [Diagrammatic Design and Study of Ans"atze for Quantum Machine Learning](https://mlsanity.com/paper/2011.11073/) (2020)

## Built on by (most cited first, 5 of 5)

- [lambeq: An Efficient High-Level Python Library for Quantum NLP](https://mlsanity.com/paper/2110.04236/) (2021)
- [A Quantum Natural Language Processing Approach to Musical Intelligence](https://mlsanity.com/paper/2111.06741/) (2021)
- [How to make qubits speak](https://mlsanity.com/paper/2107.06776/) (2021)
- [Functorial Language Models](https://mlsanity.com/paper/2103.14411/) (2021)
- [Differentiating and Integrating ZX Diagrams with Applications to Quantum Machine Learning](https://mlsanity.com/paper/2201.13250/) (2022)

## Abstract (arXiv)

We introduce diagrammatic differentiation for tensor calculus by generalising the dual number construction from rigs to monoidal categories. Applying this to ZX diagrams, we show how to calculate diagrammatically the gradient of a linear map with respect to a phase parameter. For diagrams of parametrised quantum circuits, we get the well-known parameter-shift rule at the basis of many variational quantum algorithms. We then extend our method to the automatic differentation of hybrid classical-quantum circuits, using diagrams with bubbles to encode arbitrary non-linear operators. Moreover, diagrammatic differentiation comes with an open-source implementation in DisCoPy, the Python library for monoidal categories. Diagrammatic gradients of classical-quantum circuits can then be simplified using the PyZX library and executed on quantum hardware via the tket compiler. This opens the door to many practical applications harnessing both the structure of string diagrams and the computational power of quantum machine learning.
