Coverage for tests/simulator/test_simulator_plotutils.py: 100%
41 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-09 04:47 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-09 04:47 +0000
1import sys
2import os
4# Add current path
5sys.path.append(os.getcwd())
7from tests.test_utils import temp_sys_path
9with temp_sys_path("simulator", "streamwise"):
10 from plot_utils import plot_ttff_vs_cost
11 from plot_utils import plot_ttff_vs_energy
12 from plot_utils import plot_adaptive_quality
13 from plot_utils import plot_policies_ttff_vs_cost
14 from plot_utils import plot_cost_vs_qpm
15 from plot_utils import _get_time_ticklabels
17 from sim_types import ProvisioningResult
18 from sim_types import GPUType
19 from sim_types import QualityLevel
20 from sim_types import Model
23def test_plot_ttff_vs_cost() -> None:
24 """Dummy testing."""
25 plot_ttff_vs_cost(
26 ttffs=[10, 20, 30],
27 costs=[10, 20, 30],
28 provisions=[
29 {GPUType.A100: 8},
30 {GPUType.H100: 8},
31 {GPUType.H200: 8},
32 ],
33 verbose=True,
34 )
37def test_plot_ttff_vs_energy() -> None:
38 """Dummy testing."""
39 plot_ttff_vs_energy(
40 ttff_list=[10, 20, 30],
41 energy_list=[100, 200, 300],
42 actual_provision=[
43 {GPUType.A100: 8},
44 {GPUType.H100: 8},
45 {GPUType.H200: 8},
46 ],
47 verbose=True,
48 )
51def test_plot_adaptive_quality() -> None:
52 """Dummy testing."""
53 provisioning_result_adaptive = ProvisioningResult(
54 latencies=[10, 20, 30],
55 costs=[100, 200, 300],
56 ttffs=[50, 100, 150],
57 tbfs=[0.5, 1.0, 1.5],
58 actual_provision=[
59 {GPUType.A100: 8},
60 {GPUType.H100: 8},
61 {GPUType.H200: 8},
62 ],
63 config_provision=[
64 {GPUType.A100: 8},
65 {GPUType.H100: 8},
66 {GPUType.H200: 8},
67 ],
68 model_provision=[
69 {GPUType.A100: {}},
70 {GPUType.H100: {}},
71 {GPUType.H200: {}},
72 ],
73 )
75 # TODO
76 provisioning_result_low = ProvisioningResult(
77 latencies=[15, 25, 35],
78 costs=[110, 210, 310],
79 ttffs=[60, 110, 160],
80 tbfs=[0.6, 1.1, 1.6],
81 actual_provision=[
82 {GPUType.A100: 8},
83 {GPUType.H100: 8},
84 {GPUType.H200: 8},
85 ],
86 config_provision=[
87 {GPUType.A100: 8},
88 {GPUType.H100: 8},
89 {GPUType.H200: 8},
90 ],
91 model_provision=[
92 {GPUType.A100: {}},
93 {GPUType.H100: {}},
94 {GPUType.H200: {}},
95 ],
96 )
97 provisioning_result_medium = provisioning_result_low
98 provisioning_result_high = provisioning_result_medium
100 plot_adaptive_quality(
101 provisioning_result_adaptive=provisioning_result_adaptive,
102 provisioning_qualities={
103 QualityLevel.LOW: provisioning_result_low,
104 QualityLevel.MEDIUM: provisioning_result_medium,
105 QualityLevel.HIGH: provisioning_result_high,
106 }
107 )
110def test_plot_policies_ttff_vs_cost() -> None:
111 plot_policies_ttff_vs_cost(
112 provision_results={},
113 )
115 plot_policies_ttff_vs_cost(
116 provision_results={
117 "naive": ProvisioningResult(
118 latencies=[10, 20, 30],
119 costs=[100, 200, 300],
120 ttffs=[50, 100, 150],
121 tbfs=[0.5, 1.0, 1.5],
122 actual_provision=[
123 {GPUType.A100: 8},
124 {GPUType.H100: 8},
125 {GPUType.H200: 8},
126 ],
127 config_provision=[
128 {GPUType.A100: 8},
129 {GPUType.H100: 8},
130 {GPUType.H200: 8},
131 ],
132 model_provision=[
133 {GPUType.A100: {}},
134 {GPUType.H100: {}},
135 {GPUType.H200: {}},
136 ],
137 ),
138 },
139 )
142def test_plot_cost_vs_qpm() -> None:
143 plot_cost_vs_qpm(
144 costs={},
145 qpms=[],
146 )
148 plot_cost_vs_qpm(
149 costs={
150 GPUType.A100: {
151 Model.GEMMA: [10, 20, 30],
152 Model.FT: [15, 25, 35],
153 },
154 GPUType.H100: {
155 Model.FLUX: [18, 28, 38],
156 },
157 },
158 qpms=[1, 2, 5],
159 )
162def test_get_time_ticklabels() -> None:
163 ticks, tick_labels = _get_time_ticklabels()
164 assert 18 == len(ticks) == len(tick_labels)
165 assert tick_labels == [
166 "1s", "2s", "5s", "10s", "15s", "30s",
167 "1m", "2m", "5m", "10m", "20m", "40m",
168 "1h", "3h", "5h", "8h", "12h", "1d"]
170 ticks, tick_labels = _get_time_ticklabels(exclude_x=[17])
171 assert 18 == len(ticks) == len(tick_labels)
172 assert "5m" in tick_labels
174 ticks, tick_labels = _get_time_ticklabels(exclude_x=[300])
175 assert 17 == len(ticks) == len(tick_labels)
176 assert "5m" not in tick_labels