# Library overview¶

The PennyLane codebase contains a number of complementary components. These can be roughly separated into a user-interface, supported core operations, and a developer API.

## Software components¶

User interface

The main user-interface to PennyLane. These are the functions and classes that will be used by a majority of users. For a good introduction on the user-interface of PennyLane, have a look at our tutorials.

Core operations

The main operations and expectations supported by PennyLane. Each of these operations/expectations supports a method of automatic differentiation (either analytically or numerically).

The conventions used in defining these operations are also provided here.

Developer API

Used to develop new plugins for PennyLane - providing new devices for QNodes, or supporting new operations and expectations. For more details, see Overview of the developer API.

## Summary¶

 Configuration(name) Configuration class. Device([wires, shots]) Abstract base class for PennyLane devices. DeviceError Exception raised by a Device when it encounters an illegal operation in the quantum circuit. device(name[, wires]) Load a plugin Device and return the instance. expval Submodule containing core quantum expectation values supported by PennyLane. grad(func, argnum) Returns the gradient (as a callable function) of functions accessible within PennyLane. jacobian(func, argnum) Returns the Jacobian (as a callable function) of vector-valued functions accessible within PennyLane. numpy NumPy with automatic differentiation support, provided by Autograd. ops Submodule containing core quantum operations supported by PennyLane. optimize Submodule containing PennyLane optimizers. QNode(func, device) Quantum node in the hybrid computational graph. qnode(device[, interface]) QNode decorator. QuantumFunctionError Exception raised when an illegal operation is defined in a quantum function. version() Returns the PennyLane version number.

Note

All individual operations (contained in ops) and optimizers (contained in optimize) may also be imported directly from PennyLane. Expectation values, however, must be accessed via the expval module.

### Code details¶

device(name, wires=1, *args, **kwargs)[source]

Load a plugin Device and return the instance.

This function is used to load a particular quantum device, which can then be used to construct QNodes.

PennyLane comes with support for the following two devices:

In addition, additional devices are supported through plugins — see Plugins and ecosystem for more details.

All devices must be loaded by specifying their short-name as listed above, followed by the number of wires (subsystems) you wish to initialize.

Some devices may accept additional arguments. For instance, default.gaussian accepts the keyword argument hbar, to set the convention used in the commutation relation $$[\x,\p]=i\hbar$$ (by default set to 2).

Please refer to the documentation for the individual devices to see any additional arguments that might be required or supported.

Parameters: Keyword Arguments: name (str) – the name of the device to load wires (int) – the number of wires (subsystems) to initialise the device with config (pennylane.Configuration) – an PennyLane configuration object that contains global and/or device specific configurations.
grad(func, argnum)[source]

Returns the gradient (as a callable function) of functions accessible within PennyLane.

This is a wrapper around the autograd.grad function.

Parameters: func (function) – a Python function or QNode that contains a combination of quantum and classical nodes argnum (int or list(int)) – which argument(s) to take the gradient with respect to the function that returns the gradient of the input function with respect to the arguments in argnum function
jacobian(func, argnum)[source]

Returns the Jacobian (as a callable function) of vector-valued functions accessible within PennyLane.

This is a wrapper around the autograd.jacobian function.

Parameters: func (function) – a vector-valued Python function or QNode that contains a combination of quantum and classical nodes. The output of the computation must consist of a single NumPy array (if classical) or a tuple of expectation values (if a quantum node) argnum (int) – which argument to take the gradient with respect to. If the argument is a NumPy array, then the Jacobian corresponding to all input elements and all output elements is returned. the function that returns the Jacobian of the input function with respect to the arguments in argnum function
version()[source]

Returns the PennyLane version number.