Refiners

class pytket_dqc.refiners.Refiner

Abstract base class defining the behaviors of Refiners, which perform in place processing on a Distribution.

abstract refine(distribution: Distribution, **kwargs) bool

Perform in place refinement of a Distribution.

Parameters:

distribution (Distribution) – Distribution to be refined.

Returns:

True if a refinement has been performed. False otherwise.

Return type:

bool

class pytket_dqc.refiners.RepeatRefiner(refiner: Refiner)

Repeats given Refiner until no refinement is made.

__init__(refiner: Refiner)

RepeatRefiner is initialised with Refiner to repeat.

Parameters:

refiner (Refiner) – Refiner to repeat.

refine(distribution: Distribution, **kwargs) bool

Repeat given Refiner until it makes no more refinements.

Parameters:

distribution (Distribution) – Distribution to be refined.

Returns:

True if at least one action of the repeated Refiner makes a refinement. False otherwise.

Return type:

bool

class pytket_dqc.refiners.SequenceRefiner(refiner_list: list[pytket_dqc.refiners.refiner.Refiner])

Performs sequence of Refiner as provided by the user.

__init__(refiner_list: list[pytket_dqc.refiners.refiner.Refiner])

SequenceRefiner is initialised with a list of Refiner to be run in sequence.

Parameters:

refiner_list (list[Refiner]) – List of Refiners to be run in sequence.

refine(distribution: Distribution, **kwargs) bool

Perform each of the refinements in the provided sequence.

Parameters:

distribution (Distribution) – Distribution to be refined.

Returns:

True if if any of the Refiners in the sequence makes a refinement. False otherwise.

Return type:

bool

class pytket_dqc.refiners.VertexCover

Refiner that leaves qubit allocation unchanged and decides gate placement from scratch. It uses a vertex cover approach compatible with embeddings and that prevents H-embedding conflicts.

NOTE: Any prior gate placement is ignored.

refine(distribution: Distribution, **kwargs) bool

Updates the given distribution with a chosen allocation of qubits to choose a gate placement that minimises ebit count. Any prior gate placement is ignored.

Parameters:

distribution (Distribution) – The distribution to be updated

Key vertex_cover_alg:

The choice of algorithm to be used to find the vertex covers that decide the placement of gates. Either: “all_brute_force” to do an exhaustive search of all minimum vertex covers or “networkx” to use NetworkX to find a single min cover.

class pytket_dqc.refiners.BoundaryReallocation

Refiner that considers reallocations of the vertices on the boundary of the partition, attempting to improve the solution. It is greedy and it is not capable of escaping local optima. The justification is that we assume that the Allocator used already grouped qubits efficiently and that our network has short average distance, so that we only need to refine the allocation of vertices in the boundary.

refine(distribution: Distribution, **kwargs) bool

The refinement algorithm proceeds in rounds. In each round, all of the vertices in the boundary are visited in random order and we we calculate the gain achieved by moving the vertex to other servers. The best move is applied, with ties broken randomly. If all possible moves have negative gains, the vertex is not moved.

The algorithm continues until the proportion of vertices moved in a round (i.e. #moved / #boundary) is smaller than stop_parameter or the maximum num_rounds is reached.

This refinement algorithm is taken from the discussion of the “label propagation” algorithm in https://arxiv.org/abs/1402.3281. However, we do not consider any coarsening.

Parameters:

distribution (Distribution) – Distribution to refine.

Key fixed_vertices:

A list of vertices that cannot be reallocated. Default is [].

Key num_rounds:

Max number of refinement rounds. Default is 10.

Key stop_parameter:

Real number in [0,1]. If proportion of moves in a round is smaller than this number, do no more rounds. Default is 0.05.

Key seed:

Seed for randomness. Default is None.

Key cache_limit:

The maximum size of the set of servers whose cost is stored in cache. Default value is 5.

Returns:

Distribution where the placement updated.

Return type:

Distribution

class pytket_dqc.refiners.DetachedGates

An alias for BoundaryReallocation with fixed_vertices set to the list of qubit-vertices and embedded gate-vertices. This refiner can optimise gate distribution so that detached gates may be used.

refine(distribution: Distribution, **kwargs) bool

An alias for boundary reallocation with no movements of qubit vertices or embedded gates. Key arguments (kwargs) are passed directly to BoundaryReallocation the arguments it accepts are described in its documentation.

Parameters:

distribution (Distribution) – Distribution to refine.

Returns:

Distribution where the placement updated.

Return type:

Distribution

class pytket_dqc.refiners.NeighbouringDTypeMerge

Refiner merging neighbouring packets when no Hadamard act between them. For each qubit in the circuit, and given the packets ordered as they appear in the corresponding hypergraph, this refiner will attempt to merge packets appearing consecutively in that ordering.

refine(distribution: Distribution, **kwargs) bool

Merges neighbouring packets when no Hadamard acts between them.

Parameters:

distribution (Distribution) – Distribution whose packets should be merged.

Returns:

True if a refinement has been performed. False otherwise.

Return type:

bool

class pytket_dqc.refiners.IntertwinedDTypeMerge

Refiner merging packets when they are intertwined. A packet is intertwined with another if the second packet contains gates which are intermittent between gates in the first.

refine(distribution: Distribution, **kwargs) bool

Merge intertwined packets.

Parameters:

distribution (Distribution) – Distribution whose intertwined packets should be merged.

Returns:

True if a refinement has been performed. False otherwise.

Return type:

bool

class pytket_dqc.refiners.EagerHTypeMerge

Refiner that scans circuit, merging hyperedges as it finds ones that are able to do so. To scan through the hyperedges it looks at each qubit and for each qubit it scans from the start to the end of the circuit for hoppings.

In the case of conflicts, the first found hopping is the one that is used, and no calculation is made as to which might be better to implement.

refine(distribution: Distribution, **kwargs) bool

Merge hopping packets.

Parameters:

distribution (Distribution) – Distribution whose hopping packable packets should be merged.

Returns:

True if a refinement has been performed. False otherwise.

Return type:

bool