TwoQAll#

class torchquantum.layer.TwoQAll(n_gate: int, op: Operator)[source]#

Bases: QuantumModule

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

Parameters:
  • n_gate (int) – Number of adjacent pairs of wires.

  • op (tq.Operator) – Two-qubit quantum operation to be applied.

n_gate#

Number of adjacent pairs of wires.

Type:

int

op#

Two-qubit quantum operation.

Type:

tq.Operator

__init__(n_gate: int, op: Operator)[source]#

Initialize the QuantumModule.

Returns:

None.

Examples

>>> qmodule = QuantumModule()

Methods

forward(q_device: QuantumDevice)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Attributes

training: bool#