Skip to content

Commit 4535959

Browse files
committed
slo plot
1 parent f5552d5 commit 4535959

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

tools/simulator/cli/start_simulator.py

+26-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,25 @@
99
from simulator.ui import make_table
1010
from rich.console import Console
1111
from huggingface_hub import login
12+
import matplotlib.pyplot as plt # Add this import for plotting
1213

1314

1415
console = Console()
1516

17+
def plot_slo_pass_rate(server, slo, output_path):
18+
slo_scales = [round(x, 2) for x in [0.3 + 0.1 * i for i in range(18)]] # 0.3 to 2.0
19+
pass_rates = [server.SLO_pass_rate(slo * scale) for scale in slo_scales]
20+
21+
plt.figure(figsize=(10, 6))
22+
plt.plot(slo_scales, pass_rates, marker='o', label="SLO Pass Rate")
23+
plt.title("SLO Pass Rate vs SLO Scale")
24+
plt.xlabel("SLO Scale")
25+
plt.ylabel("Pass Rate")
26+
plt.grid(True)
27+
plt.legend()
28+
plt.savefig(output_path)
29+
plt.close()
30+
1631
def run_simulation(args):
1732
print(args)
1833
server = LLMGlobalEngine(args.input, float(args.arrival_rate))
@@ -39,7 +54,10 @@ def run_simulation(args):
3954
print(f"--" * 10 + " Simulation Done " + "--" * 10)
4055

4156
console.print(make_table("Summary", server.summary))
42-
print(f"Pass rate: {server.SLO_pass_rate(float(args.SLO))}")
57+
# print(f"Pass rate: {server.SLO_pass_rate(float(args.SLO))}")
58+
59+
# Generate and save the SLO pass plot
60+
plot_slo_pass_rate(server, float(args.SLO), args.slo_plot_output)
4361

4462
if __name__ == "__main__":
4563
import argparse
@@ -48,7 +66,7 @@ def run_simulation(args):
4866
parser.add_argument("--input", type=str, help="Input file")
4967
parser.add_argument("--n-engines", type=int, help="Number of engines")
5068
parser.add_argument("--arrival-rate", help="Arrival rate", default=None)
51-
parser.add_argument("--SLO", help="Text2SQL Request SLO", default=35.28*1.5)
69+
parser.add_argument("--SLO", help="Text2SQL Request SLO", default=35.28)
5270

5371
parser.add_argument(
5472
"--trace-output",
@@ -62,5 +80,11 @@ def run_simulation(args):
6280
help="Stats file",
6381
default=".cache/replay_results/stats.json",
6482
)
83+
parser.add_argument(
84+
"--slo-plot-output",
85+
type=str,
86+
help="Output path for SLO pass plot",
87+
default="./result/slo_pass_plot.png",
88+
)
6589
args = parser.parse_args()
6690
run_simulation(args)

0 commit comments

Comments
 (0)