Skip to content

Commit ec6c916

Browse files
committed
updates from review for more thourough comments and typo fixes
Signed-off-by: Mark Kurtz <mark.kurtz@neuralmagic.com>
1 parent bec8896 commit ec6c916

File tree

1 file changed

+21
-4
lines changed
  • src/guidellm/benchmark/schemas

1 file changed

+21
-4
lines changed

src/guidellm/benchmark/schemas/base.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,37 +175,54 @@ def compute_transition_time(
175175
duration_transition_time: float | None = None
176176
request_transition_time: float | None = None
177177

178+
# Calculate transition times for the phase based on phase limits and period
179+
# Potential phases: start (warmup) -> active -> end (cooldown)
180+
# Warmup transition times: (start, start + duration)
181+
# Active transition times: (start + duration, end - duration)
182+
# Cooldown transition times: (end - duration, end)
178183
if period == "start":
179184
if phase_duration is not None:
185+
# Duration was set and caculating for "warmup" / start phase
186+
# Phase is active for [start, start + duration]
180187
duration_transition_time = state.start_time + phase_duration
181188
if phase_requests is not None:
189+
# Requests was set and calculating for "warmup" / start phase
190+
# Phase is active for requests [0, phase_requests]
191+
# Grab start time of the next request as transition time
192+
# (all requests up to and including phase_requests are in warmup)
182193
request_transition_time = (
183194
info.started_at
184195
if info.started_at is not None
185-
and state.processed_requests > phase_requests
196+
and state.processed_requests == phase_requests + 1
186197
else -1.0
187198
)
188199
elif period == "end":
189200
if phase_duration is not None:
201+
# Duration was set and calculating for "cooldown" / end phase
202+
# Phase is active for [end - duration, end]
190203
duration_transition_time = (
191204
state.start_time + state.progress.total_duration - phase_duration
192205
if state.progress.total_duration is not None
193206
else -1.0
194207
)
195208
if phase_requests is not None:
209+
# Requests was set and calculating for "cooldown" / end phase
210+
# Phase is active for requests [total - phase_requests, total]
211+
# Grab completion time of the request right before cooldown starts
212+
# (all requests from that point onward are in cooldown)
196213
request_transition_time = (
197214
info.completed_at
198215
if info.completed_at is not None
199216
and state.progress.remaining_requests is not None
200-
and state.progress.remaining_requests < phase_requests + 1
217+
and state.progress.remaining_requests == phase_requests + 1
201218
else -1.0
202219
)
203220

204221
transition_active: bool = False
205222
transition_time: float | None = None
206223

207224
if request_transition_time == -1.0 or duration_transition_time == -1.0:
208-
# Transition defined but not yet reached, not enough info yet
225+
# Transition defined but not yet reached or passed
209226
transition_active = True
210227
request_transition_time = None
211228
elif (
@@ -221,7 +238,7 @@ def compute_transition_time(
221238
elif (
222239
request_transition_time is not None or duration_transition_time is not None
223240
):
224-
# One limit defined; satisfy t hat one
241+
# One limit defined; satisfy that one
225242
transition_active = True
226243
transition_time = request_transition_time or duration_transition_time
227244

0 commit comments

Comments
 (0)