Skip to content

Double CNOTs in the CX block generated by the annealer #23

@Aerylia

Description

@Aerylia

Occasionally, the annealer finds CX blocks where two of the same CNOTs are added together. This is inefficient.

This is because the line of code that checks whether the CNOTs are preceding or not only checks the surrounding layers.
So suppose I have 5 layers in the CX block with only CNOT(1,2) in the first layer, then the third layer might also obtain CNOT(1,2).

In OptimizedCircuit.random_flip_cx() :

if layer_idx < len(self._cx_block)-1 and self._cx_block[layer_idx+1].has_cx(ctrl, trgt):
    # Try again if CX gate already present in layer above (to avoid redundancy)
    continue
if layer_idx > 0 and self._cx_block[layer_idx-1].has_cx(ctrl, trgt):
    # Try again if CX gate already present in layer below (to avoid redundancy)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions