discopy.quantum.pennylane

Contents

discopy.quantum.pennylane#

Interface with PennyLane.

Summary#

PennyLaneCircuit

Implement a pennylane circuit with post-selection.

Functions

tk_op_to_pennylane

Extract the operation, parameters and wires from a pytket Op, and return the corresponding PennyLane operation.

extract_ops_from_tk

Extract the operations, and corresponding parameters and wires, from a pytket Circuit.

get_post_selection_dict

Return post-selections based on qubit indices.

to_pennylane

Return a PennyLaneCircuit equivalent to the input DisCoPy circuit.

Notes

If probabilities is set to False, the output states of the PennyLane circuit will be exactly equivalent to those of the DisCoPy circuit (for the same parameters).

If probabilities is set to True, the output states of the PennyLane circuit will be the probabilities of the output states, equivalent to appending discopy.quantum.circuit.Measure to all the open wires in the DisCoPy circuit.

Once a PennyLaneCircuit has been constructed, it can be evaluated with eval(). If the circuit contains only concrete parameters (i.e. no symbolic parameters), no arguments should be passed to eval(). If the circuit contains symbolic parameters, a list of the symbolic parameters and a list of their associated weights should be passed to eval() as symbols= and weights=.