Table of Contents
Fetching ...

TensorFlow Quantum: A Software Framework for Quantum Machine Learning

Michael Broughton, Guillaume Verdon, Trevor McCourt, Antonio J. Martinez, Jae Hyeon Yoo, Sergei V. Isakov, Philip Massey, Ramin Halavati, Murphy Yuezhen Niu, Alexander Zlokapa, Evan Peters, Owen Lockwood, Andrea Skolik, Sofiene Jerbi, Vedran Dunjko, Martin Leib, Michael Streif, David Von Dollen, Hongxiang Chen, Shuxiang Cao, Roeland Wiersema, Hsin-Yuan Huang, Jarrod R. McClean, Ryan Babbush, Sergio Boixo, Dave Bacon, Alan K. Ho, Hartmut Neven, Masoud Mohseni

TL;DR

TensorFlow Quantum (TFQ) presents an integrated software stack that unites Cirq with TensorFlow to enable rapid prototyping and training of hybrid quantum-classical models on quantum data. It provides differentiable quantum circuit execution, batched processing, and a high-performance qsim backend to scale simulations, along with a rich set of building blocks (tensors, sampling, differentiation layers, and datasets) for end-to-end quantum ML pipelines. The paper details both the software architecture and a broad spectrum of applications, from basic quantum classifiers and QAOA to advanced topics like meta-learning, Hamiltonian learning, quantum generative models, and quantum RL, illustrating TFQ’s potential to drive practical QML on near-term devices. The work emphasizes methodology for backpropagation through quantum circuits, toolchains for hybrid graphs, and robust training under noise, positioning TFQ as a versatile framework for exploring quantum algorithms and discovering quantum advantages. Overall, TFQ aims to accelerate quantum ML research by providing accessible, differentiable, and scalable tooling that can operate across simulators and real quantum hardware.

Abstract

We introduce TensorFlow Quantum (TFQ), an open source library for the rapid prototyping of hybrid quantum-classical models for classical or quantum data. This framework offers high-level abstractions for the design and training of both discriminative and generative quantum models under TensorFlow and supports high-performance quantum circuit simulators. We provide an overview of the software architecture and building blocks through several examples and review the theory of hybrid quantum-classical neural networks. We illustrate TFQ functionalities via several basic applications including supervised learning for quantum classification, quantum control, simulating noisy quantum circuits, and quantum approximate optimization. Moreover, we demonstrate how one can apply TFQ to tackle advanced quantum learning tasks including meta-learning, layerwise learning, Hamiltonian learning, sampling thermal states, variational quantum eigensolvers, classification of quantum phase transitions, generative adversarial networks, and reinforcement learning. We hope this framework provides the necessary tools for the quantum computing and machine learning research communities to explore models of both natural and artificial quantum systems, and ultimately discover new quantum algorithms which could potentially yield a quantum advantage.

TensorFlow Quantum: A Software Framework for Quantum Machine Learning

TL;DR

TensorFlow Quantum (TFQ) presents an integrated software stack that unites Cirq with TensorFlow to enable rapid prototyping and training of hybrid quantum-classical models on quantum data. It provides differentiable quantum circuit execution, batched processing, and a high-performance qsim backend to scale simulations, along with a rich set of building blocks (tensors, sampling, differentiation layers, and datasets) for end-to-end quantum ML pipelines. The paper details both the software architecture and a broad spectrum of applications, from basic quantum classifiers and QAOA to advanced topics like meta-learning, Hamiltonian learning, quantum generative models, and quantum RL, illustrating TFQ’s potential to drive practical QML on near-term devices. The work emphasizes methodology for backpropagation through quantum circuits, toolchains for hybrid graphs, and robust training under noise, positioning TFQ as a versatile framework for exploring quantum algorithms and discovering quantum advantages. Overall, TFQ aims to accelerate quantum ML research by providing accessible, differentiable, and scalable tooling that can operate across simulators and real quantum hardware.

Abstract

We introduce TensorFlow Quantum (TFQ), an open source library for the rapid prototyping of hybrid quantum-classical models for classical or quantum data. This framework offers high-level abstractions for the design and training of both discriminative and generative quantum models under TensorFlow and supports high-performance quantum circuit simulators. We provide an overview of the software architecture and building blocks through several examples and review the theory of hybrid quantum-classical neural networks. We illustrate TFQ functionalities via several basic applications including supervised learning for quantum classification, quantum control, simulating noisy quantum circuits, and quantum approximate optimization. Moreover, we demonstrate how one can apply TFQ to tackle advanced quantum learning tasks including meta-learning, layerwise learning, Hamiltonian learning, sampling thermal states, variational quantum eigensolvers, classification of quantum phase transitions, generative adversarial networks, and reinforcement learning. We hope this framework provides the necessary tools for the quantum computing and machine learning research communities to explore models of both natural and artificial quantum systems, and ultimately discover new quantum algorithms which could potentially yield a quantum advantage.

Paper Structure

This paper contains 82 sections, 89 equations, 34 figures.

Figures (34)

  • Figure 1: A simple example of the TensorFlow computational model. Two tensor inputs $A$ and $B$ are added and then multiplied against a third tensor input $C$, before flowing on to further nodes in the graph. Blue nodes are tensor injections (ops), arrows are tensors flowing through the computational graph, and orange nodes are tensor transformations (ops). Tensor injections are ops in the sense that they are functions which take in zero tensors and output one tensor.
  • Figure 2: The states-as-edges approach to embedding quantum computation in TensorFlow. Blue nodes are input tensors, arrows are tensors flowing through the graph, and orange nodes are TF Ops transforming the simulated quantum state. Note that the above is not the architecture used in TFQ but rather an alternative which was considered, see Fig. \ref{['fig:expectation_graph']} for the equivalent diagram for the true TFQ architecture.
  • Figure 3: The TensorFlow graph generated to calculate the expectation value of a parameterized circuit. The symbol values can come from other TensorFlow ops, such as from the outputs of a classical neural network. The output can be passed on to other ops in the graph; here, for illustration, the output is passed to the absolute value op.
  • Figure 4: The software stack of TFQ, showing its interactions with TensorFlow, Cirq, and computational hardware. At the top of the stack is the data to be processed. Classical data is natively processed by TensorFlow; TFQ adds the ability to process quantum data, consisting of both quantum circuits and quantum operators. The next level down the stack is the Keras API in TensorFlow. Since a core principle of TFQ is native integration with core TensorFlow, in particular with Keras models and optimizers, this level spans the full width of the stack. Underneath the Keras model abstractions are our quantum layers and differentiators, which enable hybrid quantum-classical automatic differentiation when connected with classical TensorFlow layers. Underneath the layers and differentiators, we have TensorFlow ops, which instantiate the dataflow graph. Our custom ops control quantum circuit execution. The circuits can be run in simulation mode, by invoking qsim or Cirq, or eventually will be executed on QPU hardware.
  • Figure 5: Abstract pipeline for inference and training of a hybrid discriminative model in TFQ. Here, $\bm{\Phi}$ represents the quantum model parameters and $\bm{\theta}$ represents the classical model parameters.
  • ...and 29 more figures