17.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 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

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]

Some transposes cannot be represented with just a stride and group size and therefore cannot be created. For example for num_replicas=8, stride=2 and group_size=2, the assignments are [0, 1, 0, 1, 2, 3, 2, 3] and the transpose is [0, 0, 1, 1, 0, 0, 1, 1].

Raises

ValueError – If the transpose cannot be represented with a replica grouping.

Returns

A “transpose” replica grouping of self.

Return type

ReplicaGrouping