19.8. Replica grouping

class popxl.ReplicaGrouping
__init__()

Not intended to be called directly, use replica_grouping() instead.

property assignment: List[int]

Obtain the group each replica is assigned to.

Examples (with ir.replication_factor = 8):

ir.replica_grouping(stride=1, group_size=8).assignment
[0, 0, 0, 0, 0, 0, 0, 0]

ir.replica_grouping(stride=1, group_size=1).assignment
[0, 1, 2, 3, 4, 5, 6, 7]

ir.replica_grouping(stride=1, group_size=2).assignment
[0, 0, 1, 1, 2, 2, 3, 3]

ir.replica_grouping(stride=2, group_size=2).assignment
[0, 1, 0, 1, 2, 3, 2, 3]

ir.replica_grouping(stride=1, group_size=4).assignment
[0, 0, 0, 0, 1, 1, 1, 1]

ir.replica_grouping(stride=2, group_size=4).assignment
[0, 1, 0, 1, 0, 1, 0, 1]
Returns

A list where the index is the replica and value is the group index

Return type

List[int]

property group_size: int

Get the group size.

Returns

The number of replicas in each replica group.

Return type

int

property is_const: bool

Return True if has a constant stride and group size, and therefore can be represented using a PopART C++ ReplicaGrouping.

property num_groups: int

Get the number of groups.

Returns

The number of replica groups.

Return type

int

property stride: int

Get the stride.

Returns

The offset between elements in a replica group.

Return type

int

Raises

NotImplementedError – if non-constant stride

transpose()

Return the transpose of this replica grouping.

A replica grouping whereby the first element of each group is the first new group, the second element of each group is the second group etc.

Examples:

[0, 0, 0, 0] -> [0, 1, 2, 3]
[0, 1, 0, 1] -> [0, 0, 1, 1]
[0, 0, 1, 1] -> [0, 1, 0, 1]
[0, 1, 2, 3] -> [0, 0, 0, 0]

A good way to visualise the transpose is by considering the group matrix. For example, for the assignment [0, 1, 0, 1, 2, 3, 2, 3] the group matrix is: [[0, 2],

[1, 3], [4, 6], [5, 7]]

Whereby the first axis is the group index and the values are the replica index. The transpose of this matrix is: [[0, 1, 4, 5],

2, 3, 6, 7]]

Which converts back to the assignments [0, 0, 1, 1, 0, 0, 1, 1].

Returns

A “transpose” replica grouping of self.

Return type

ReplicaGrouping