latticesurgery-com / liblsqecc

A C++ Library implementing some tools for the Lattice Surgery Compiler
GNU General Public License v3.0
10 stars 10 forks source link

[Feature Request] More flexible implementation of CNOT gates #20

Closed SophLin closed 2 years ago

SophLin commented 2 years ago

When congestion results from simultaneous CNOT gates, besides reconsidering the allocation of ancilla (https://github.com/latticesurgery-com/liblsqecc/issues/15#issue-1216018964), one can also try flipping the MXX between ancilla and target, and the MZZ between ancilla and control. This requires a small change to the input format as well. One should specify which pair of MXX and MZZ belong to the same CNOT.

See this paper https://arxiv.org/abs/1704.08670 In ZX calculus, the 3 diagrams below all represent CNOT

Screen Shot 2022-08-16 at 3 49 30 PM
alexandrupaler commented 2 years ago

It is a nice feature request. We could get it very soon implemented. The main issue might be related to #15, but we can sort that out also pretty fast.

gwwatkin commented 2 years ago

Implementing a new kinds of cx gates, distinguishing with QASM comment annotations

Implementing in two steps. The first step should achieve the minimal viable functionality with existing LLI, enough for testing and unblock you on other things. The second step is to obtain the slice-optimal implementation of the CNOT with lattice surgery. Once I get there we can assess whether to prioritize that or other things.

1) Prepare routing and connectivity and parsing only using existing LLI

Pre-allocating the patch used by the third wire:

We already perform CNOTs in a very similar way in the Python interface repo things to add are:

2) Minimal ZX implmentation with new LLI

Add new LLI, so that a new patch needs not to be initialized and patches can be merged into a single one.

gwwatkin commented 2 years ago

After discussing with @SophLin, it turns out that approach 1 is as efficient as approach 2 because patch initialization and measuring in the Standard or Hadamard bases takes 0 code-distance-proportional time steps.

Will only implement approach 1 since it does not require any new instructions.

gwwatkin commented 2 years ago

Implemented most of the functionality in #20. Now have to work out corrective terms

gwwatkin commented 2 years ago

Corrective terms

File