9
9
from simulator .ui import make_table
10
10
from rich .console import Console
11
11
from huggingface_hub import login
12
+ import matplotlib .pyplot as plt # Add this import for plotting
12
13
13
14
14
15
console = Console ()
15
16
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
+
16
31
def run_simulation (args ):
17
32
print (args )
18
33
server = LLMGlobalEngine (args .input , float (args .arrival_rate ))
@@ -39,7 +54,10 @@ def run_simulation(args):
39
54
print (f"--" * 10 + " Simulation Done " + "--" * 10 )
40
55
41
56
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 )
43
61
44
62
if __name__ == "__main__" :
45
63
import argparse
@@ -48,7 +66,7 @@ def run_simulation(args):
48
66
parser .add_argument ("--input" , type = str , help = "Input file" )
49
67
parser .add_argument ("--n-engines" , type = int , help = "Number of engines" )
50
68
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 )
52
70
53
71
parser .add_argument (
54
72
"--trace-output" ,
@@ -62,5 +80,11 @@ def run_simulation(args):
62
80
help = "Stats file" ,
63
81
default = ".cache/replay_results/stats.json" ,
64
82
)
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
+ )
65
89
args = parser .parse_args ()
66
90
run_simulation (args )
0 commit comments