catalyst.passes.disentangle_cnot

disentangle_cnot(qnode)[source]

A peephole optimization for replacing CNOT gates with single-qubit gates.

Note

This transform requires decorating the workflow with pennylane.qjit().

Args:

fn (QNode): the QNode to apply the pass to

Returns:

~.QNode:

Example

In the circuit below, the CNOT gate can be simplified to just a PauliX gate since the control qubit is always in the :math:`|1

angle` state.

import pennylane as qml

dev = qml.device("lightning.qubit", wires=2)

@qml.qjit(capture=True)
@qml.transforms.disentangle_cnot
@qml.qnode(dev)
def circuit():
    # first qubit in |1>
    qml.X(0)
    # second qubit in |0>
    # current state : |10>
    qml.CNOT([0, 1]) # state after CNOT : |11>
    return qml.state()

When inspecting the circuit resources, only PauliX gates are present.

>>> print(qml.specs(circuit, level=1)())
Device: lightning.qubit
Device wires: 2
Shots: Shots(total=None)
Level: disentangle-cnot

Wire allocations: 2
Total gates: 2
Gate counts:
- PauliX: 2
Measurements:
- state(all wires): 1
Depth: Not computed