There are plethora of ways one cloud imagine combining the capabilities of Cirq and TensorFlow. One of possible approach is to let graph edges represent quantum states and let ops represent transformations of the state, such as applying circuits and taking measurements. This approach is known as “State-as-edges” architecture. 🧑🏭
The state-as-edges approach embedding quantum operations in TensorFlow. As in above image Blue nodes are input tensors, arrows are tensors flowing through the graph, and orange nodes are TF Ops transforming the simulated quantum state. 🧑🎓 Note above architecture is not used in TFQ but rather an alternative which was considered.
This architecture may at first glance seem like an attractive option as it is direct transformation of quantum computation as a dataflow graph.👨💻 However, this approach is sub-optimal for several reasons.
First, in this architecture, the structure of the circuits being run is static in the computational graph, thus running a different circuits would require the 👩⚕️ different graph (rebuilt). In this approach we have to build circuits at each iterations.
Second, this problem is lack of a clear way to embed such a quantum dataflow graph on a real quantum processor, quantum states remain in quantum 🕵️♂ ️memory on the quantum device itself, and the high latency between classical and quantum processors makes sending transformations one-by-one prohibitive.
Lastly, we need to specify gates and measurements within TF. One may tempted to define these directly; however, Cirq already has the necessary tools and objects defined which are most relevant for the near-term quantum 🧑✈ ️computing era. Duplicating Cirq functionality in TF would be stupidity. This motivate our core design principles.👨🚀