pytket.placement

class pytket.placement.GraphPlacement

The GraphPlacement class, contains methods for getting maps between Circuit Qubits and Architecture Nodes and for relabelling Circuit Qubits.

__init__(self: pytket.placement.GraphPlacement, arc: pytket.architecture.Architecture) None

The constructor for a GraphPlacement object. The Architecture object describes the connectivity between qubits.

Parameters

arc – An Architecture object.

modify_config(self: pytket.placement.GraphPlacement, **kwargs) None

Overides default Placement parameters to given values. Timeout is in milliseconds :param **kwargs: Parameters for placement: (int)depth_limit=5, (int)max_interaction_edges=edges in the device graph, (int)max_matches=10000, (int)contraction_ratio=10, (int)timeout=60000.

class pytket.placement.LinePlacement

The LinePlacement class, contains methods for getting maps between Circuit Qubits and Architecture Nodes and for relabelling Circuit Qubits.

__init__(self: pytket.placement.LinePlacement, arc: pytket.architecture.Architecture) None

The constructor for a LinePlacement object. The Architecture object describes the connectivity between qubits.

Parameters

arc – An Architecture object.

class pytket.placement.NoiseAwarePlacement

The NoiseAwarePlacement class, contains methods for getting maps between Circuit Qubits and Architecture Nodes and for relabelling Circuit Qubits. It uses gate error rates and readout errors to find the best placement map.

__init__(self: pytket.placement.NoiseAwarePlacement, arc: pytket.architecture.Architecture, node_errors: Dict[pytket.circuit.Node, float] = {}, link_errors: Dict[Tuple[pytket.circuit.Node, pytket.circuit.Node], float] = {}, readout_errors: Dict[pytket.circuit.Node, float] = {}) None

The constructor for a NoiseAwarePlacement object. The Architecture object describes the connectivity between qubits. The dictionaries passed as parameters indicate the average gate errors for single- and two-qubit gates as well as readout errors. If no error is given for a given node or pair of nodes, the fidelity is assumed to be 1.

Parameters
  • arc – An Architecture object

  • node_errors – a dictionary mapping nodes in the architecture to average single-qubit gate errors

  • link_errors – a dictionary mapping pairs of nodes in the architecture to average two-qubit gate errors

  • readout_errors – a dictionary mapping nodes in the architecture to average measurement readout errors.

modify_config(self: pytket.placement.NoiseAwarePlacement, **kwargs) None

Overides default Placement parameters to given values. Timeout is in milliseconds :param **kwargs: Parameters for placement: (int)depth_limit=5, (int)max_interaction_edges=edges in the device graph, (int)max_matches=10000, (int)contraction_ratio=10, (int)timeout=60000.

class pytket.placement.Placement

The base Placement class, contains methods for getting maps between Circuit Qubits and Architecture Nodes and for relabelling Circuit Qubits.

__init__(self: pytket.placement.Placement, arc: pytket.architecture.Architecture) None

The constructor for a Placement object. The Architecture object describes the connectivity between qubits.

Parameters

arc – An Architecture object.

static from_dict(arg0: json) pytket.placement.Placement

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

get_placement_map(self: pytket.placement.Placement, circuit: pytket.circuit.Circuit) Dict[pytket.circuit.Qubit, pytket.circuit.Node]

Returns a map from logical to physical qubits that is Architecture appropriate for the given Circuit.

Parameters

circuit – The circuit a map is designed for.

Returns

dictionary mapping Qubit s to Node s

get_placement_maps(self: pytket.placement.Placement, circuit: pytket.circuit.Circuit) List[Dict[pytket.circuit.Qubit, pytket.circuit.Node]]

Returns a list of maps from logical to physical qubits that are Architecture appropriate for the given Circuit. Each map is estimated to given a similar SWAP overheard after routing.

Parameters

circuit – The circuit the maps are designed for.

Returns

list of dictionaries mapping Qubit s to Node s

place(self: pytket.placement.Placement, circuit: pytket.circuit.Circuit) bool

Relabels Circuit Qubits to Architecture Nodes and ‘unplaced’. For base Placement, all Qubits and labelled ‘unplaced’.

Parameters

circuit – The Circuit being relabelled.

static place_with_map(circuit: pytket.circuit.Circuit, qmap: Dict[pytket.circuit.Qubit, pytket.circuit.Node]) bool

Relabels Circuit Qubits to Architecture Nodes using given map.

Parameters
  • circuit – The circuit being relabelled

  • qmap – The map from logical to physical qubits to apply.

to_dict(self: pytket.placement.Placement) json

Return a JSON serializable dict representation of the Placement. :return: dict representing the Placement.

pytket.placement.place_fully_connected(circuit: pytket.circuit.Circuit, fully_connected: pytket.architecture.FullyConnected) None

Relabels all Circuit Qubits to the Node objects of a FullyConnected object.

Parameters
  • circuit – The Circuit being relabelled.

  • fully_connected – FullyConnected object Qubits being relabelled to match.

pytket.placement.place_with_map(circuit: pytket.circuit.Circuit, qmap: Dict[pytket.circuit.Qubit, pytket.circuit.Node]) None

Relabels Circuit Qubits according to a map. If provided map is partial, remaining Circuit Qubits are left ‘unplaced’.

Parameters
  • circuit – The Circuit being relabelled.

  • qmap – The map from logical to physical qubits to apply.