Skip to content

Commit

Permalink
[BUG] Fix issue when parent task does not have a valid ChooseExpression.
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Jan 31, 2024
1 parent 8fd8302 commit d2868da
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion schedulers/tetrisched_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,9 @@ def construct_task_strl(
)
continue

# Validate that a hint was provided if required.
was_hint_provided = False

if not self._use_windowed_choose or len(time_discretizations) == 1:
# We now construct the Choose expressions for each possible placement
# choice of this Task, and collate them under a MaxExpression.
Expand Down Expand Up @@ -1232,12 +1235,13 @@ def construct_task_strl(
self._logger.debug(
"[%s] Hinting the placement of %s in state %s for time "
"%s with the previous placement %s.",
current_time,
current_time.to(EventTime.Unit.US).time,
task.unique_name,
task.state,
placement_time,
placement_hint,
)
was_hint_provided = True

# Construct a ChooseExpression for placement at this time.
# TODO (Sukrit): We just assume for now that all Slots are the same
Expand Down Expand Up @@ -1322,6 +1326,26 @@ def construct_task_strl(
)
task_execution_strategy_strls.append(task_windowed_choose)

if (
task.state == TaskState.SCHEDULED
and not was_hint_provided
and task.current_placement.execution_strategy == execution_strategy
):
self._logger.error(
"[%s] Task %s was in state %s with the prior placement "
"time %s, but no corresponding hint was provided. The "
"ChooseExpressions were generated for times: %s.",
current_time.to(EventTime.Unit.US).time,
task.unique_name,
task.state,
task.current_placement.placement_time,
[t.time for t, _ in time_discretizations],
)
raise RuntimeError(
f"No hint was provided for {task.unique_name}, but one "
f"was expected at {task.current_placement.placement_time}."
)

# Construct the STRL MAX expression for this Task.
# This enforces the choice of only one placement for this Task.
if len(task_execution_strategy_strls) == 0:
Expand Down Expand Up @@ -1400,6 +1424,13 @@ def _construct_task_graph_strl(
task_expression = self.construct_task_strl(
current_time, task, partitions, placement_times_and_rewards
)
if not task_expression:
self._logger.warn(
f"[{current_time.time}] Could not construct the STRL for "
f"Task {task.unique_name}. Failing the construction of STRL "
f"for the TaskGraph {task_graph.name} rooted at {task.unique_name}."
)
return None
else:
# If this Task is not in the set of Tasks that we are required to schedule,
# then we just return a None expression.
Expand Down

0 comments on commit d2868da

Please sign in to comment.