pytket.architecture

class pytket.architecture.Architecture

Class describing the connectivity of qubits on a general device.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pytket.architecture.Architecture, connections: List[Tuple[int, int]]) -> None

The constructor for an architecture with connectivity between qubits.

Parameters

connections – A list of pairs representing qubit indices that can perform two-qubit operations

  1. __init__(self: pytket.architecture.Architecture, connections: List[Tuple[pytket.circuit.Node, pytket.circuit.Node]]) -> None

The constructor for an architecture with connectivity between qubits.

Parameters

connections – A list of pairs representing Nodes that can perform two-qubit operations

static from_dict(arg0: json) pytket.architecture.Architecture

Construct Architecture instance from JSON serializable dict representation of the Architecture.

get_adjacent_nodes(self: pytket.architecture.Architecture, node: pytket.circuit.Node) Set[pytket.circuit.Node]

given a node, returns adjacent nodes in Architecture.

get_distance(self: pytket.architecture.Architecture, node_0: pytket.circuit.Node, node_1: pytket.circuit.Node) int

given two nodes in Architecture, returns distance between them

to_dict(self: pytket.architecture.Architecture) json

Return a JSON serializable dict representation of the Architecture. :return: dict containing nodes and links.

valid_operation(self: pytket.architecture.Architecture, uids: List[pytket.circuit.Node]) bool

nodes can be executed on the Architecture connectivity graph.

Parameters

uids – list of UnitIDs validity is being checked for

property coupling

Returns the coupling map of the Architecture as UnitIDs.

property nodes

Returns all nodes of architecture as Node objects.

class pytket.architecture.FullyConnected

A specialised non-Architecture object emulating an architecture with all qubits connected. Not compatible with Routing or Placement methods.

__init__(self: pytket.architecture.FullyConnected, n: int) None

Construct a fully-connected architecture.

Parameters

n – number of qubits

static from_dict(arg0: json) pytket.architecture.FullyConnected

Construct FullyConnected instance from dict representation.

to_dict(self: pytket.architecture.FullyConnected) json

JSON-serializable dict representation of the architecture.

Returns

dict containing nodes

property nodes

All nodes of the architecture as Node objects.

class pytket.architecture.RingArch

Inherited Architecture class for number of qubits arranged in a ring.

__init__(self: pytket.architecture.RingArch, nodes: int) None

The constructor for a RingArchitecture with some undirected connectivity between qubits.

:param number of qubits

class pytket.architecture.SquareGrid

Inherited Architecture class for qubits arranged in a square lattice of given number of rows and columns. Qubits are arranged with qubits values increasing first along rows then along columns i.e. for a 3 x 3 grid:

0 1 2

3 4 5

6 7 8

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pytket.architecture.SquareGrid, n_rows: int, n_columns: int) -> None

The constructor for a Square Grid architecture with some undirected connectivity between qubits.

Parameters
  • n_rows – The number of rows in the grid

  • n_columns – The number of columns in the grid

  1. __init__(self: pytket.architecture.SquareGrid, n_rows: int, n_columns: int, n_layers: int) -> None

The constructor for a Square Grid architecture with some undirected connectivity between qubits.

Parameters
  • n_rows – The number of rows in the grid

  • n_columns – The number of columns in the grid

  • n_layers – The number of layers of grids

qind_to_squind(self: pytket.architecture.SquareGrid, index: int) Tuple[int, int]

Converts a single qubit index to a (row,column) index for a square grid.

Parameters

index – The global qubit index

Returns

the corresponding grid index as a pair (row,column)

squind_to_qind(self: pytket.architecture.SquareGrid, row: int, column: int) int

Converts a (row,column) index for a square grid to a single qubit index

Parameters
  • row – The given row index

  • column – The given column index

Returns

the corresponding global qubit index