diffqcQubitDevice#

class diffqc.pennylane.diffqcQubitDevice(wires: ~typing.Union[int, ~typing.Iterable[~typing.Union[int, str]]], shots: ~typing.Union[None, int, ~typing.List[int]] = None, mode: ~typing.Literal['dense', 'sparse'] = 'dense', dtype: ~numpy.dtype = <class 'jax.numpy.complex64'>)#

Bases: QubitDevice

Attributes Summary

Methods Summary

analytic_probability([wires])

Return the (marginal) probability of each computational basis state from the last run of the device.

apply(operations, **kwargs)

Apply quantum operations, rotate the circuit into the measurement basis, and compile and execute the quantum circuit.

capability()

Attributes Documentation

author = 'ymd-h'#
name = 'PennyLane plugin for diffqc'#
observables = {'PauliX', 'PauliY', 'PauliZ'}#
operations = {'CNOT', 'CPhase', 'CPhaseShift', 'CRX', 'CRY', 'CRZ', 'CRot', 'CSWAP', 'CY', 'CZ', 'ControlledPhaseShift', 'ECR', 'Hadamard', 'ISWAP', 'Identity', 'IsingXX', 'IsingYY', 'IsingZZ', 'PSWAP', 'PauliX', 'PauliY', 'PauliZ', 'PhaseShift', 'RX', 'RY', 'RZ', 'Rot', 'S', 'SISWAP', 'SQISWAP', 'SWAP', 'SX', 'T', 'Toffoli', 'U1', 'U2', 'U3'}#
pennylane_requires = '>=0.20.0'#
short_name = 'diffqc.qubit'#
version = '0.0.0'#

Methods Documentation

analytic_probability(wires: Union[None, Iterable[Union[int, str]], int, str, Wires] = None)#

Return the (marginal) probability of each computational basis state from the last run of the device.

PennyLane uses the convention \(|q_0,q_1,\dots,q_{N-1}\rangle\) where \(q_0\) is the most significant bit.

If no wires are specified, then all the basis states representable by the device are considered and no marginalization takes place.

Note

marginal_prob() may be used as a utility method to calculate the marginal probability distribution.

Parameters

wires (Iterable[Number, str], Number, str, Wires) – wires to return marginal probabilities for. Wires not provided are traced out of the system.

Returns

list of the probabilities

Return type

array[float]

apply(operations: List[Operation], **kwargs)#

Apply quantum operations, rotate the circuit into the measurement basis, and compile and execute the quantum circuit.

This method receives a list of quantum operations queued by the QNode, and should be responsible for:

  • Constructing the quantum program

  • (Optional) Rotating the quantum circuit using the rotation operations provided. This diagonalizes the circuit so that arbitrary observables can be measured in the computational basis.

  • Compile the circuit

  • Execute the quantum circuit

Both arguments are provided as lists of PennyLane Operation instances. Useful properties include name, wires, and parameters, and inverse:

>>> op = qml.RX(0.2, wires=[0])
>>> op.name # returns the operation name
"RX"
>>> op.wires # returns a Wires object representing the wires that the operation acts on
<Wires = [0]>
>>> op.parameters # returns a list of parameters
[0.2]
>>> op.inverse # check if the operation should be inverted
False
>>> op = qml.RX(0.2, wires=[0]).inv
>>> op.inverse
True
Parameters

operations (list[Operation]) – operations to apply to the device

Keyword Arguments
  • rotations (list[Operation]) – operations that rotate the circuit pre-measurement into the eigenbasis of the observables.

  • hash (int) – the hash value of the circuit constructed by CircuitGraph.hash

classmethod capability() Dict[str, Any]#