pytket.architecture¶
The architecture module provides an API to interact with the
Architecture
class.
- class pytket.architecture.Architecture¶
Class describing the connectivity of qubits on a general device.
- __init__(self) None ¶
- __init__(self, connections: collections.abc.Sequence[tuple[int, int]]) None
- __init__(self, connections: collections.abc.Sequence[tuple[pytket.unit_id.Node, pytket.unit_id.Node]]) None
Overloaded function.
__init__(self) -> None
Produces an empty architecture
__init__(self, connections: collections.abc.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
__init__(self, connections: collections.abc.Sequence[tuple[pytket.unit_id.Node, pytket.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
- from_dict(arg: dict, /) pytket.architecture.Architecture ¶
Construct Architecture instance from JSON serializable dict representation of the Architecture.
- get_adjacent_nodes(self, node: pytket.unit_id.Node) set[pytket.unit_id.Node] ¶
given a node, returns adjacent nodes in Architecture.
- get_distance(self, node_0: pytket.unit_id.Node, node_1: pytket.unit_id.Node) int ¶
given two nodes in Architecture, returns distance between them
- to_dict(self) dict ¶
Return a JSON serializable dict representation of the Architecture.
- Returns:
dict containing nodes and links.
- valid_operation(self, uids: collections.abc.Sequence[pytket.unit_id.Node], bidirectional: bool = True) bool ¶
Checks if a given operation on the given nodes can be executed on the Architecture’s connectivity graph. The operation is considered valid if:
The operation acts on a single node that belongs to the Architecture.
The operation acts on two nodes, and either:
bidirectional is True and an edge exists between the two nodes in either direction.
bidirectional is False and an edge exists from uids[0] to uids[1].
The function always returns False if the number of nodes exceeds 2.
- Parameters:
uids – list of UnitIDs validity is being checked for.
bidirectional – If True, treats edges in the coupling graph as bidirectional. Defaults to True.
- 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, n: int, label: str = 'fcNode') None ¶
Construct a fully-connected architecture.
- Parameters:
n – number of qubits
label – Name for Node in FullyConnected Architecture
- from_dict(arg: dict, /) pytket.architecture.FullyConnected ¶
Construct FullyConnected instance from dict representation.
- to_dict(self) dict ¶
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.
- 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__(self, n_rows: int, n_columns: int, label: str = 'gridNode') None ¶
- __init__(self, n_rows: int, n_columns: int, n_layers: int = 1, label: str = 'gridNode') None
Overloaded function.
__init__(self, 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
__init__(self, 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