Interfaces

PennyLane offers seamless integration between classical and quantum computations. Code up quantum circuits in PennyLane, and connect them easily to the top scientific computing and machine learning libraries.

The bridge between the quantum and classical worlds is provided in PennyLane via interfaces. Currently, there are three built-in interfaces: NumPy, PyTorch, and TensorFlow. These interfaces make each of these libraries quantum-aware, allowing quantum circuits to be treated just like any other operation.

In PennyLane, an interface is declared when creating a QNode, e.g.,

@qml.qnode(dev, interface="tf")
def my_quantum_circuit(...):
    ...

Note

If no interface is specified, PennyLane will default to the NumPy interface (powered by the autograd library).

This will allow native numerical objects of the specified library (NumPy arrays, Torch Tensors, or TensorFlow Tensors) to be passed as parameters to the quantum circuit. It also makes the gradients of the quantum circuit accessible to the classical library, enabling the optimization of arbitrary hybrid circuits.

See the links below for walkthroughs of each specific interface: