Skip to content

Commit

Permalink
Fix bug where STRL generation fails if one child task is in TaskState…
Browse files Browse the repository at this point in the history
….COMPLETED.
  • Loading branch information
sukritkalra committed Jan 1, 2024
1 parent f1eead1 commit 6ca9935
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
32 changes: 18 additions & 14 deletions schedulers/tetrisched_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __init__(
max_occupancy_threshold,
)
self._use_task_graph_indicator_uility = True
self._previously_placed_reward_scale_factor = 1.0
self._previously_placed_reward_scale_factor = 2.0
self._enable_optimization_passes = (
_flags.scheduler_enable_optimization_pass if _flags else False
)
Expand Down Expand Up @@ -628,7 +628,7 @@ def schedule(
)
self._logger.warning(f"[{sim_time.time}] Failed to place any tasks.")

# if sim_time == EventTime(204, EventTime.Unit.US):
# if sim_time == EventTime(136, EventTime.Unit.US):
# raise RuntimeError("Stopping the Simulation.")

scheduler_end_time = time.time()
Expand Down Expand Up @@ -1061,8 +1061,8 @@ def _construct_task_graph_strl(
# If this Task is not in the set of Tasks that we are required to schedule,
# then we just return a None expression.
self._logger.debug(
f"[{current_time.time}] Task {task.unique_name} is not in the set of "
f"tasks to be scheduled."
f"[{current_time.time}] Task {task.unique_name} in state {task.state} "
f"is not in the set of tasks to be scheduled."
)
task_expression = None

Expand All @@ -1080,16 +1080,20 @@ def _construct_task_graph_strl(
)
if child_expression:
child_expressions[child_expression.id] = child_expression
elif child.state != TaskState.COMPLETED:
raise RuntimeError(
f"Could not construct the STRL for all the children of "
f"{task.unique_name}."
)

# If the number of children does not equal the number of children in the
# TaskGraph, then we have not been able to construct the STRL for all the
# children. Return None.
if len(child_expressions) != len(task_graph.get_children(task)):
self._logger.warn(
f"[{current_time.time}] Could not construct the STRL for all the "
f"children of {task.unique_name}."
)
return None
# TaskGraph that haven't completed, then we have not been able to construct the
# STRL for all the children. Return None.
# if len(child_expressions) != num_enforceable_children:
# self._logger.warn(
# f"[{current_time.time}] Could not construct the STRL for all the "
# f"children of {task.unique_name}."
# )

# If there are no children, cache and return the expression for this Task.
if len(child_expressions) == 0:
Expand Down Expand Up @@ -1221,7 +1225,7 @@ def construct_task_graph_strl(
# utilities to be scaled, or if we are using the indicator from the topmost
# TaskGraph expression to scale the utility.
should_scale = (
self._previously_placed_reward_scale_factor > 1.0
self._previously_placed_reward_scale_factor > 1.0 and previously_placed
) or self._use_task_graph_indicator_uility

if should_scale:
Expand All @@ -1234,7 +1238,7 @@ def construct_task_graph_strl(
)
scale_expression = tetrisched.strl.ScaleExpression(
f"{task_graph.name}_scale",
self._previously_placed_reward_scale_factor,
self._previously_placed_reward_scale_factor if previously_placed else 1,
self._use_task_graph_indicator_uility,
)
scale_expression.addChild(task_graph_strl)
Expand Down
5 changes: 1 addition & 4 deletions simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,13 +1059,10 @@ def __handle_task_cancellation(self, event: Event) -> None:
self._cancelled_tasks,
event.task,
)
slowest_strategy = (
event.task.available_execution_strategies.get_slowest_strategy()
)
self._csv_logger.debug(
f"{event.time.to(EventTime.Unit.US).time},TASK_CANCEL,{event.task.name},"
f"{event.task.timestamp},{event.task.id},{event.task.task_graph},"
f"{slowest_strategy.runtime.time}"
f"{event.task.slowest_execution_strategy.runtime.time}"
)

# If the task already had a placement, we remove the placement from our queue.
Expand Down

0 comments on commit 6ca9935

Please sign in to comment.