pytket.architecture

class pytket._tket.architecture.Architecture

Class describing the connectivity of qubits on a general device.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pytket._tket.architecture.Architecture) -> None

Produces an empty architecture

  1. __init__(self: pytket._tket.architecture.Architecture, connections: Sequence[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._tket.architecture.Architecture, connections: Sequence[tuple[pytket._tket.unit_id.Node, pytket._tket.unit_id.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: dict) pytket._tket.architecture.Architecture

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

get_adjacent_nodes(self: pytket._tket.architecture.Architecture, node: pytket._tket.unit_id.Node) set[pytket._tket.unit_id.Node]

given a node, returns adjacent nodes in Architecture.

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

given two nodes in Architecture, returns distance between them

to_dict(self: pytket._tket.architecture.Architecture) dict

Return a JSON serializable dict representation of the Architecture.

Returns:

dict containing nodes and links.

valid_operation(self: pytket._tket.architecture.Architecture, uids: Sequence[pytket._tket.unit_id.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._tket.architecture.FullyConnected

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

__init__(self: pytket._tket.architecture.FullyConnected, n: int, label: str = 'fcNode') None

Construct a fully-connected architecture.

Parameters:
  • n – number of qubits

  • label – Name for Node in FullyConnected Architecture

static from_dict(arg0: dict) pytket._tket.architecture.FullyConnected

Construct FullyConnected instance from dict representation.

to_dict(self: pytket._tket.architecture.FullyConnected) dict

JSON-serializable dict representation of the architecture.

Returns:

dict containing nodes

property nodes

All nodes of the architecture as Node objects.

class pytket._tket.architecture.RingArch

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

__init__(self: pytket._tket.architecture.RingArch, nodes: int, label: str = 'ringNode') None

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

Parameters:
  • qubits (number of)

  • label – Name for Node in RingArch Architecture

class pytket._tket.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._tket.architecture.SquareGrid, n_rows: int, n_columns: int, label: str = ‘gridNode’) -> 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

  • label – Name for Node in SquareGrid Architecture

  1. __init__(self: pytket._tket.architecture.SquareGrid, n_rows: int, n_columns: int, n_layers: int = 1, label: str = ‘gridNode’) -> 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

  • label – Name for Node in SquareGrid Architecture

qind_to_squind(self: pytket._tket.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._tket.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