Module: pennylane

qnode(device, interface='numpy', cache=False)[source]

QNode decorator.

  • device (Device) – a PennyLane-compatible device
  • interface (str) –

    the interface that will be used for automatic differentiation and classical processing. This affects the types of objects that can be passed to/returned from the QNode:

    • interface='numpy': The QNode accepts default Python types (floats, ints, lists) as well as NumPy array arguments, and returns NumPy arrays.
    • interface='torch': The QNode accepts and returns Torch tensors.
    • interface='tfe': The QNode accepts and returns eager execution TensorFlow tfe.Variable objects.
  • cache (bool) – If True, the quantum function used to generate the QNode will only be called to construct the quantum circuit once, on first execution, and this circuit structure (i.e., the placement of templates, gates, measurements, etc.) will be cached for all further executions. The circuit parameters can still change with every call. Only activate this feature if your quantum circuit structure will never change.