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

Load a 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 devices:

  • 'default.qubit': a simple state simulator of qubit-based quantum circuit architectures.

  • 'default.gaussian': a simple simulator of Gaussian states and operations on continuous-variable circuit architectures.

  • 'default.qubit.tf': a state simulator of qubit-based quantum circuit architectures written in TensorFlow, which allows automatic differentiation through the simulation.

  • 'default.qubit.autograd': a state simulator of qubit-based quantum circuit architectures which allows automatic differentiation through the simulation via python’s autograd library.

In addition, additional devices are supported through plugins — see the available plugins for more details.

All devices must be loaded by specifying their short-name as listed above, followed by the wires (subsystems) you wish to initialize. The wires argument can be an integer, in which case the wires of the device are addressed by consecutive integers:

dev = qml.device('default.qubit', wires=5)

def circuit():
   qml.CNOT(wires=[3, 4])

The wires argument can also be a sequence of unique numbers or strings, specifying custom wire labels that the user employs to address the wires:

dev = qml.device('default.qubit', wires=['ancilla', 'q11', 'q12', -1, 1])

def circuit():
   qml.CNOT(wires=['q12', -1] )

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.

  • name (str) – the name of the device to load

  • wires (int) – the number of wires (subsystems) to initialise the device with

Keyword Arguments

config (pennylane.Configuration) – a PennyLane configuration object that contains global and/or device specific configurations.