torchquantum.layers#

Layers#

QuantumModuleFromOps(ops)

Initializes a QuantumModuleFromOps instance.

TrainableOpAll(n_gate, op)

Rotation rx on all qubits The rotation angle is a parameter of each rotation gate One potential optimization is to compute the unitary of all gates together.

ClassicalInOpAll(n_gate, op)

Quantum module that applies the same quantum operation to all wires of a quantum device, where the parameters of the operation are obtained from a classical input.

FixedOpAll(n_gate, op)

Quantum module that applies the same fixed quantum operation to all wires of a quantum device.

TwoQAll(n_gate, op)

Quantum module that applies a two-qubit quantum operation to adjacent pairs of wires in a quantum device.

RandomLayer(wires[, n_ops, n_params, ...])

Quantum module that represents a random layer of quantum operations applied to specified wires.

RandomLayerAllTypes(wires[, n_ops, ...])

Random layer with a wide range of quantum gate types.

Op1QAllLayer(op, n_wires[, has_params, ...])

Quantum layer applying the same single-qubit operation to all wires.

RandomOp1All(n_wires[, op_types, op_ratios, ...])

Op2QAllLayer(op, n_wires[, has_params, ...])

Quantum layer applying the same two-qubit operation to all pairs of adjacent wires.

Op2QButterflyLayer(op, n_wires[, ...])

Quantum layer applying the same two-qubit operation in a butterfly pattern.

Op2QDenseLayer

alias of EntangleFull

CXLayer(n_wires)

Quantum layer with a controlled-X (CX) gate applied to two specified wires.

CXCXCXLayer(n_wires)

Quantum layer with a sequence of CX gates applied to three specified wires.

SWAPSWAPLayer(n_wires)

Quantum layer with a sequence of SWAP gates applied to two specified pairs of wires.

RXYZCXLayer0([arch])

Layer template with RXYZCX blocks.

QFTLayer([n_wires, wires, do_swaps, inverse])