alexandrupaler / fondq

10 stars 1 forks source link
fondqlogo

fondq

The code herein is a prototypical full-stack compiler from a high level algorithm to a NISQ device. For the purpose of this example, the algorithm is Grover's algorithm scripted in grover_algorithm.py.

The NISQ type device is expected to support the following:

Because the example is around a simple instance of Grover's algorithm, the herein scripted device supports the decomposition of Toffoli, CZ, and X gates.

Installation

Compile and optimize

The compilation for the FondqDevice takes place when the cirq.Circuit is constructed with the device parameter. Removing that parameter results in the undecomposed version of Grover.

After Toffoli decomposition, there are many gate-level optimisations which could be performed. In this version, two optimisations are implemented in cnotopt.py: a) removing Hadamard gates which appear in a sequence (H*H=I); b) reversing the direction of CNOTs surrounded by Hadamards. The optimizers are implemented for pedagogical reasons, and the results are not the best one could achieve.

2020. The fondq project is improved at the Google Cirq Tutorials

2019. The fondq project resulted from the Google Cirq Bootcamps