-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
203 lines (149 loc) · 5.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import argparse
import os
import pathlib
import runpy
import sys
results_path = pathlib.Path(__file__).parent / "results"
os.environ["FIGURE_PATH"] = str((results_path / "figures").absolute())
os.environ["DATA_PATH"] = str((results_path / "data").absolute())
src_path = (pathlib.Path(__file__).parent / "src").absolute()
plots_script_dir = str((src_path / "plots").absolute())
src_dir = str(src_path)
def add_plot_root():
sys.path.append(plots_script_dir)
sys.path.append(src_dir)
def add_run_root():
sys.path.append(src_dir)
def config_filepath(filename: str):
return str((src_path / "configs" / filename).absolute())
def refresh_experiment_data():
from distutils.dir_util import copy_tree, remove_tree
from_path = str(pathlib.Path(plots_script_dir) / "datas" / "reports")
to_path = os.environ["DATA_PATH"]
if os.path.exists(to_path):
remove_tree(to_path)
copy_tree(from_path, to_path)
def run_placement_experiment():
add_run_root()
from src.run import run
print("Running solver & partitioning & distributing experiment. This may take hours...")
run(config_filepath("Solver_config.json"))
def run_trace_experiment():
add_run_root()
from src.run import run
print("Running trace experiment. This may take hours...")
run(config_filepath("Trace_config.json"))
def plot_job_profiling_data():
print("Plotting job profiling data figures")
os.chdir(plots_script_dir)
add_plot_root()
runpy.run_path(str(pathlib.Path(plots_script_dir) / "mono_job_performance.py"))
def plot_solver_eval():
print("Plotting solver & part & dist evaluation figures")
os.chdir(plots_script_dir)
add_plot_root()
runpy.run_path(str(pathlib.Path(plots_script_dir) / "random_placement.py"))
def plot_trace_eval():
print("Plotting trace evaluation figures")
os.chdir(plots_script_dir)
add_plot_root()
runpy.run_path(str(pathlib.Path(plots_script_dir) / "time_series_profit.py"))
def plot_preemption_eval():
print("Plotting preemption evaluation figures")
os.chdir(plots_script_dir)
add_plot_root()
runpy.run_path(str(pathlib.Path(plots_script_dir) / "checkpoint.py"))
def plot_scalability_eval():
print("Plotting scalability evaluation figures")
os.chdir(plots_script_dir)
add_plot_root()
runpy.run_path(str(pathlib.Path(plots_script_dir) / "solver_latency.py"))
def plot_simulator_eval():
print("Plotting simulator evaluation figures")
os.chdir(plots_script_dir)
add_plot_root()
runpy.run_path(str(pathlib.Path(plots_script_dir) / "time_series_profit_small_scale.py"))
def plot_workloads():
print("Plotting workloads figures")
os.chdir(plots_script_dir)
add_plot_root()
runpy.run_path(str(pathlib.Path(plots_script_dir) / "workloads.py"))
with open(str(pathlib.Path(__file__).parent / "usage.md"), "r") as f:
usage = f.read()
parser = argparse.ArgumentParser(
description="SPREAD: Towards Optimal GPU sharing by Job Spreading for Lightweight Deep Learning Training Jobs. "
"This is a helper CLI program to run SPREAD simulator and draw all plots in the paper. Please refer to the flag descriptions to run experiment or ",
usage=usage)
group = parser.add_mutually_exclusive_group()
group.add_argument(
"--run-placement-experiment",
help="Run solver & partitioning & distributing experiment and collect data",
action="store_true"
)
group.add_argument(
"--run-trace-experiment",
help="Run trace experiment and collect data",
action="store_true"
)
group.add_argument(
"--plot-job-profiling-data",
help="Plot job profiling data figures",
action="store_true"
)
group.add_argument(
"--plot-solver-part-dist-eval",
help="Plot solver & partitioning & distributing evaluation figures",
action="store_true"
)
group.add_argument(
"--plot-trace-eval",
help="Plot trace evaluation figures",
action="store_true"
)
group.add_argument(
"--plot-preemption-eval",
help="Plot preemption evaluation figures",
action="store_true"
)
group.add_argument(
"--plot-scalability-eval",
help="Plot scalability evaluation figures",
action="store_true"
)
group.add_argument(
"--plot-simulator-eval",
help="Plot simulator evaluation figures",
action="store_true"
)
group.add_argument(
"--plot-workloads",
help="Plot workloads figures",
action="store_true"
)
group.add_argument(
"--refresh-data",
help="Replace all experiment data by the initial data",
action="store_true"
)
args = parser.parse_args()
if not any(vars(args).values()):
parser.print_help()
exit(0)
if args.run_placement_experiment:
run_placement_experiment()
if args.run_trace_experiment:
run_trace_experiment()
if args.plot_job_profiling_data:
plot_job_profiling_data()
if args.plot_solver_part_dist_eval:
plot_solver_eval()
if args.plot_trace_eval:
plot_trace_eval()
if args.plot_preemption_eval:
plot_preemption_eval()
if args.plot_scalability_eval:
plot_scalability_eval()
if args.plot_simulator_eval:
plot_simulator_eval()
if args.refresh_data:
refresh_experiment_data()