You're reading the documentation of the v0.6. For the latest released version, please have a look at v0.11.
Convertors
The convertor
package contain classes aimed at converting circuits and data from and to perceval standards.
Qiskit Convertor
Overview
Note
Qiskit is not listed as a Perceval dependency. Users wishing to use Qiskit shall install it by themselves.
Qiskit is an opensource quantum development library. A Qiskit QuantumCircuit
can be
converted to an equivalent photonic circuit using Perceval QiskitConverter
.
>>> import qiskit
>>> from perceval.converters import QiskitConverter
>>> import perceval.lib.phys as phys
Create a Quantum Circuit (the following is pure Qiskit syntax):
>>> qc = qiskit.QuantumCircuit(2)
>>> qc.h(0)
>>> qc.cx(0, 1)
>>> print(qc.draw())
┌───┐
q_0: ┤ H ├──■──
└───┘┌─┴─┐
q_1: ─────┤ X ├
└───┘
Then convert the Quantum Circuit with Perceval QiskitConvertor:
>>> qiskit_convertor = QiskitConverter(phys)
>>> perceval_processor = qiskit_convertor.convert(qc)
See also:
Parameters
QiskitConverter
constructor usage:
>>> converter = QiskitConverter(library, source=None)
With:
library
: any Perceval component library such asphys
orsymb
source
: a Perceval Source object representing a photonic source (default is a perfect source)
convert
method usage:
>>> processor = qiskit_convertor.convert(qc: qiskit.QuantumCircuit, heralded: bool = None)
With:
qc
: the qiskit.QuantumCircuit to be convertedheralded
: bool (default = None)True => use only heralded CNOT
False => use only post-processed CNOT
None (not set) => use heralded CNOT for all gates except the last one (which is post-processed)
Returns: a
Processor
containing theqiskit.QuantumCircuit
equivalent, heralds and post selection function.