Compilation and routing

Whenever implementing a quantum circuit on an given quantum device, there are two limitations of any real device that have to be taken into account:

  1. The device cannot implement arbitrary 1-qubit and 2-qubit gates. Thus, the gates in the circuit have to be compiled into a circuit that only containts native gates.

  2. The device has a limited connectivity. That is, we cannot implement gates between arbitrary 2-qubits, but only those specified by some connectivity graph.

Both of these points increase the physical depth of a circuit when implementing it on near-term devices. Although both of these points only incur in a polynomial increase of the depth of the circuit and, thus, is not a major issue for fault-tolerant quantum computation, they can make a significant difference in the absence of error correction.

The functions in this module allow for both compling a given circuit into a native gate set and to perform the routing of the qubits in efficient ways. To perform the compilation we will resort to Cirq and to perform the routing we will resort to TKET (see also this tutorial for a discussion on how to use tket with cirq).

This first version will mostly focus on QAOA circuits and we will use some of the functions developed in the `Recirq package.<https://github.com/quantumlib/ReCirq>`_

Unfortunately, some of the functions of Recirq are not compatible with Cirq 13.0, which we use for this package. Furthermore, installing it using pip seems to break other packages required to run KnowYourLimits. In order to circumvent these issues, we have included a minimally modified version of the code directly in the repository.

circuit_compiler.compiled_routed_qaoa(problem_graph, gammas, betas, tk_device)

Returns a compiled and routed QAOA circuit given the target problem, the parameters of the QAOA circuit and a tket device which models the connectivity graph of the quantum device.

Returns

returns the (noiseless) routed circuit.

Return type

routed_circuit (cirq circuit)

Parameters
  • problem_graph (networkx graph) – the (weighted) graph describing the target problem.

  • gammas (vector of floats) – the parameters of the unitary corresponding to the target Hamiltonian.

  • betas (vector of floats) – the parameters of the unitary corresponding to the mixer Hamiltonian.

  • tk_device (tket device) – the connectivity graph of the quantum device we wish to route the circuit to.

circuit_compiler.rzz(rads)

Returns a gate with the matrix exp(-i Z⊗Z rads).