# qml.templates.state_preparations.BasisStatePreparation¶

BasisStatePreparation(basis_state, wires)[source]

Prepares a basis state on the given wires using a sequence of Pauli X gates.

Warning

basis_state influences the circuit architecture and is therefore incompatible with gradient computations. Ensure that basis_state is not passed to the qnode by positional arguments.

Parameters
• basis_state (array) – Input array of shape (N,), where N is the number of wires the state preparation acts on. N must be smaller or equal to the total number of wires of the device.

• wires (Sequence[int]) – sequence of qubit indices that the template acts on

Raises

ValueError – if inputs do not have the correct format