pytket.phir.sharding package#

Submodules#

pytket.phir.sharding.shard module#

class pytket.phir.sharding.shard.Shard(primary_command: Command, sub_commands: dict[UnitID, list[Command]], qubits_used: set[Qubit], bits_written: set[Bit], bits_read: set[Bit], depends_upon: set[int])#

Bases: object

The Shard class.

A shard is a logical grouping of operations that represents the unit by which we actually do placement of qubits.

ID: int#
bits_read: set[Bit]#
bits_written: set[Bit]#
depends_upon: set[int]#
pretty_print() str#

Returns the shard in a human-friendly format.

primary_command: Command#
qubits_used: set[Qubit]#
sub_commands: dict[UnitID, list[Command]]#

pytket.phir.sharding.sharder module#

class pytket.phir.sharding.sharder.Sharder(circuit: Circuit)#

Bases: object

The Sharder class.

Responsible for taking in a circuit in TKET representation and converting it into shards that can be subsequently handled in the compilation pipeline.

shard() list[Shard]#

Performs sharding algorithm on the circuit the Sharder was initialized with.

Returns:

list of Shards needed to schedule

static should_op_create_shard(op: Op) bool#

Decide whether to create a shard.

This includes non-gate operations like measure/reset as well as 2-qubit gates.

Parameters:

op – operation

Returns:

True if the operation is one that should result in shard creation

pytket.phir.sharding.shards2ops module#

pytket.phir.sharding.shards2ops.get_qid(qubit: UnitID, qubits2ids: dict[UnitID, int], qid_count: int) tuple[int, int]#

Get qubit ID even if it is missing in the dict.

pytket.phir.sharding.shards2ops.parse_shards_naive(shards: set[Shard]) tuple[list[list[list[int]]], list[ShardLayer]]#

Parse a set of shards and return a circuit representation for placement.

Module contents#