CNOTLadderAnsatz#

class pyqit.ansatzes.CNOTLadderAnsatz(n_qubits: int, n_layers: int = 6)[source]#

Bases: BaseAnsatz

The variational block of Mari et al. (2020): a CNOT ladder, then RY.

Each layer applies CNOT to the wire pairs (0, 1), (2, 3), ..., then to (1, 2), (3, 4), ..., then one RY per wire.

Parameters:
  • n_qubits (int)

  • n_layers (int, default 6) – q_depth in the paper.

References

Mari, Bromley, Izaac, Schuld, Killoran, “Transfer learning in hybrid classical-quantum neural networks”, Quantum 4, 340 (2020). PennyLane’s “Quantum transfer learning” demo is the reference implementation.

build_circuit(weights)[source]#

Apply the layers. Expects weights[“weights”] of shape (n_layers, n_qubits).

get_circuit_func()#

Returns the bound method to be passed to a QNode.

classmethod get_test_params()[source]#

List constructor kwargs used to parametrize this class in the test suite.

get_weight_shapes() → dict[source]#

Return {“weights”: (n_layers, n_qubits)}.