command#

MBQC commands

Classes

Correction(nodes[, basis, domain])

Correction command.

Entanglement(node1, node2)

Entanglement command.

Measurement(nodes[, angle, plane, s_domain, ...])

Measurement command.

Node(nodes)

Node (qubit) preparation command.

class Correction(nodes: int | list[int], basis: str = 'x', domain: int | Iterable[int] | None = None)[source]#

Bases: Command

Correction command.

Parameters:
  • nodes (int | list[int]) – The indices of the nodes to correct.

  • basis (str) – The type of correction ('x' or 'z'). Default: 'x'

  • domain (int | Iterable[int] | None) – The indices of the nodes that contribute to signal domain s. Default: None

extra_repr() str[source]#
forward(x: GraphState) GraphState[source]#

Perform a forward pass by correcting the GraphState.

class Entanglement(node1: int, node2: int)[source]#

Bases: Command

Entanglement command.

Parameters:
  • node1 (int) – The first node index.

  • node2 (int) – The second node index.

forward(x: GraphState) GraphState[source]#

Perform a forward pass by adding an edge in the GraphState.

class Measurement(nodes: int | list[int], angle: Any = 0.0, plane: str = 'xy', s_domain: int | Iterable[int] | None = None, t_domain: int | Iterable[int] | None = None, requires_grad: bool = False)[source]#

Bases: Command

Measurement command.

Parameters:
  • nodes (int | list[int]) – The indices of the nodes to measure.

  • angle (Any) – The measurement angle in radians. Default: 0.

  • plane (str) – The measurement plane ('xy', 'yz' or 'zx'). Default: 'xy'

  • s_domain (int | Iterable[int] | None) – The indices of the nodes that contribute to signal domain s. Default: None

  • t_domain (int | Iterable[int] | None) – The indices of the nodes that contribute to signal domain t. Default: None

  • requires_grad (bool) – Whether the parameter is nn.Parameter or buffer. Default: False (which means buffer)

extra_repr() str[source]#
forward(x: GraphState) GraphState[source]#

Perform a forward pass by measuring the GraphState.

init_para(angle: Any = None) None[source]#

Initialize the parameters.

inputs_to_tensor(inputs: Any = None) Tensor[source]#

Convert inputs to torch.Tensor.

class Node(nodes: int | list[int])[source]#

Bases: Command

Node (qubit) preparation command.

Parameters:

nodes (int | list[int]) – The indices of the nodes to prepare.

forward(x: GraphState) GraphState[source]#

Perform a forward pass by adding SubGraphState in the GraphState.