Skip to content

Commit e6e2ddc

Browse files
Bugfixes
1 parent 1346479 commit e6e2ddc

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

accelforge/frontend/mapping/mapping.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ def _propagate_backing_reservations_between_splits(self) -> None:
806806
return
807807

808808
for i, node1 in enumerate(self.nodes):
809+
# + 2 because if it's in back-to-back branches, then there's nothing in
810+
# between to add the reservation to.
809811
for j in range(i + 2, len(self.nodes)):
810812
node2 = self.nodes[j]
811813
reservations1 = node1.get_nodes_of_type(Reservation)
@@ -1542,11 +1544,10 @@ def split_reservations(self):
15421544

15431545
def split_loop_with_multiple_rank_variables(self, stride_and_halo: dict[str, tuple[int, int]]):
15441546
new_nodes = []
1547+
my_rank_variables = set(x[1] for x in stride_and_halo)
15451548
for node in self.nodes:
15461549
if isinstance(node, Loop) and isinstance(node.rank_variable, set):
1547-
ranks_in_stride_and_halo = {
1548-
r for r in node.rank_variable if r in stride_and_halo
1549-
}
1550+
ranks_in_stride_and_halo = node.rank_variable & my_rank_variables
15501551
assert len(ranks_in_stride_and_halo) == 1, f"Expected 1 rank in stride and halo, got {len(ranks_in_stride_and_halo)}"
15511552
new_node = copy.copy(node)
15521553
new_node.rank_variable = ranks_in_stride_and_halo.pop()

accelforge/model/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def evaluate_mapping(
113113
)
114114

115115
pmapping.split_reservations()
116-
pmapping.split_loop_with_multiple_rank_variables(job.stride_and_halo)
116+
pmapping.split_loop_with_multiple_rank_variables(
117+
job.stride_and_halo[einsum_name]
118+
)
117119
pmapping.split_tensor_holders_with_multiple_tensors()
118120
_add_backing_to_tensor_holders(pmapping)
119121

@@ -140,7 +142,9 @@ def evaluate_mapping(
140142
t.name: t.rank_variable2ranks for t in einsum.tensor_accesses
141143
}
142144

143-
_, df, _, _, tensor2mapping = run_model(job, add_reservations=needs_reservations)
145+
_, df, _, _, tensor2mapping = run_model(
146+
job, add_reservations=needs_reservations
147+
)
144148

145149
# Calculate iteration counts and rank columns
146150
_calculate_iterations_and_rank_columns(

0 commit comments

Comments
 (0)