Usage of CNOT in a circuit (as a component?)

Hi

I would like to ask if it is possible to use cnot in a circuit directly.

All I can see in the doc is Cnot being used from catalog, and in all examples they are always directly imported as_processor() and added to an instance of pcvl.Processor(…).

I understand that LOQC’s CNOT is different from deterministic cnot we see in Qiskit, but it still implement a unitary, so in theory it can be added to a circuit, right? So, is there a way to build the LO circuit gradually with Cnot? I don’t see any cnot functions compatible with type components.linear_circuit.Circuit

Thanks

Hi,

It is indeed possible to use a CNOT gate directly in a Circuit (rather than in a Processor). However, pay attention that a Perceval Circuit has no knowledge of post-selection whatsoever, so you’ll have to handle it yourself with some code.

Here’s a minimal example of how to insert a CNOT in a Circuit:

from perceval.components import catalog, Circuit

any_circuit = Circuit(12)

# ... add other components before the CNOT gate ...

cnot = catalog['postprocessed cnot'].as_circuit().build()
# or cnot = catalog['heralded cnot'].as_circuit().build()
any_circuit.add(0, cnot)

# ... add other components after the CNOT gate ...

Best wishes,
Eric

2 Likes