Spaces:
Running
Running
Add bubble rate formula.
Browse files- src/execution_model.py +12 -2
src/execution_model.py
CHANGED
@@ -43,13 +43,13 @@ class ScheduleConfig:
|
|
43 |
self.num_batches = num_batches
|
44 |
self.p2p_latency = p2p_latency
|
45 |
self.placement_strategy = placement_strategy
|
46 |
-
|
47 |
# Initialize default operation times
|
48 |
self.op_times = {
|
49 |
"forward": 1.0,
|
50 |
"backward": 2.0,
|
51 |
}
|
52 |
-
|
53 |
# Update with user-provided operation times
|
54 |
if op_times:
|
55 |
for op_type, times in op_times.items():
|
@@ -215,3 +215,13 @@ class Schedule:
|
|
215 |
|
216 |
def get_total_execution_time(self):
|
217 |
return max(op.end_time for op in self.ops.values())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
self.num_batches = num_batches
|
44 |
self.p2p_latency = p2p_latency
|
45 |
self.placement_strategy = placement_strategy
|
46 |
+
|
47 |
# Initialize default operation times
|
48 |
self.op_times = {
|
49 |
"forward": 1.0,
|
50 |
"backward": 2.0,
|
51 |
}
|
52 |
+
|
53 |
# Update with user-provided operation times
|
54 |
if op_times:
|
55 |
for op_type, times in op_times.items():
|
|
|
215 |
|
216 |
def get_total_execution_time(self):
|
217 |
return max(op.end_time for op in self.ops.values())
|
218 |
+
|
219 |
+
def get_bubble_rate(self):
|
220 |
+
actual_time = self.get_total_execution_time()
|
221 |
+
ideal_time = 0
|
222 |
+
for stage_id in range(self.config.num_stages):
|
223 |
+
for op_type in ["forward", "backward"]:
|
224 |
+
ideal_time += self.config.get_op_time(op_type, stage_id)
|
225 |
+
ideal_time = ideal_time * self.config.num_batches / self.config.num_devices
|
226 |
+
|
227 |
+
return (actual_time - ideal_time) / ideal_time
|