Skip to content

Commit b0becd5

Browse files
committed
Reenablement of flows and fixes
1 parent ef36af1 commit b0becd5

File tree

13 files changed

+480
-728
lines changed

13 files changed

+480
-728
lines changed

src/guidellm/__main__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def benchmark():
286286
)
287287
@click.option(
288288
"--data-num-workers",
289-
default=1,
289+
default=None,
290290
type=int,
291291
help="The number of worker processes to use for data loading.",
292292
)
@@ -505,11 +505,9 @@ def run(
505505
output_formats=output_formats,
506506
# Updates configuration
507507
progress=(
508-
[
509-
GenerativeConsoleBenchmarkerProgress(
510-
display_scheduler_stats=display_scheduler_stats
511-
)
512-
]
508+
GenerativeConsoleBenchmarkerProgress(
509+
display_scheduler_stats=display_scheduler_stats
510+
)
513511
if not disable_progress
514512
else None
515513
),

src/guidellm/benchmark/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
SynchronousProfile,
1616
ThroughputProfile,
1717
)
18-
from .progress import (
19-
BenchmarkerProgress,
20-
BenchmarkerProgressGroup,
21-
GenerativeConsoleBenchmarkerProgress,
22-
)
18+
from .progress import BenchmarkerProgress, GenerativeConsoleBenchmarkerProgress
2319
from .schemas import (
2420
Benchmark,
2521
BenchmarkArgs,
@@ -44,7 +40,6 @@
4440
"Benchmarker",
4541
"BenchmarkerDict",
4642
"BenchmarkerProgress",
47-
"BenchmarkerProgressGroup",
4843
"ConcurrentProfile",
4944
"EstimatedBenchmarkState",
5045
"GenerativeAudioMetricsSummary",

src/guidellm/benchmark/benchmarker.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,19 @@
2323
from typing import Generic
2424

2525
from guidellm.benchmark.profile import Profile
26+
from guidellm.benchmark.progress import BenchmarkerProgress
2627
from guidellm.benchmark.schemas import (
2728
BenchmarkArgs,
2829
BenchmarkT,
2930
EstimatedBenchmarkState,
3031
)
32+
from guidellm.logger import logger
3133
from guidellm.scheduler import (
3234
BackendInterface,
3335
Environment,
34-
NonDistributedEnvironment,
3536
RequestT,
3637
ResponseT,
3738
Scheduler,
38-
SchedulerState,
39-
SchedulingStrategy,
4039
)
4140
from guidellm.utils import ThreadSafeSingletonMixin
4241

@@ -65,19 +64,13 @@ async def run(
6564
requests: Iterable[RequestT | Iterable[RequestT | tuple[RequestT, float]]],
6665
backend: BackendInterface[RequestT, ResponseT],
6766
profile: Profile,
68-
environment: Environment | None = None,
67+
environment: Environment,
68+
progress: BenchmarkerProgress[BenchmarkT] | None = None,
6969
sample_requests: int | None = 20,
7070
warmup: float | None = None,
7171
cooldown: float | None = None,
7272
prefer_response_metrics: bool = True,
73-
) -> AsyncIterator[
74-
tuple[
75-
EstimatedBenchmarkState | None,
76-
BenchmarkT | None,
77-
SchedulingStrategy,
78-
SchedulerState | None,
79-
]
80-
]:
73+
) -> AsyncIterator[BenchmarkT]:
8174
"""
8275
Execute benchmark runs across multiple scheduling strategies.
8376
@@ -95,15 +88,17 @@ async def run(
9588
:raises Exception: If benchmark execution or compilation fails.
9689
"""
9790
with self.thread_lock:
98-
if environment is None:
99-
environment = NonDistributedEnvironment()
91+
if progress:
92+
await progress.on_initialize(profile)
10093

10194
run_id = str(uuid.uuid4())
10295
strategies_generator = profile.strategies_generator()
10396
strategy, constraints = next(strategies_generator)
10497

10598
while strategy is not None:
106-
yield None, None, strategy, None
99+
if progress:
100+
await progress.on_benchmark_start(strategy)
101+
107102
args = BenchmarkArgs(
108103
run_id=run_id,
109104
run_index=len(profile.completed_strategies),
@@ -127,18 +122,23 @@ async def run(
127122
env=environment,
128123
**constraints or {},
129124
):
130-
benchmark_class.update_estimate(
131-
args,
132-
estimated_state,
133-
response,
134-
request,
135-
request_info,
136-
scheduler_state,
137-
)
138-
yield estimated_state, None, strategy, scheduler_state
139-
140-
if scheduler_state is None:
141-
raise RuntimeError("Scheduler state is None after execution.")
125+
try:
126+
benchmark_class.update_estimate(
127+
args,
128+
estimated_state,
129+
response,
130+
request,
131+
request_info,
132+
scheduler_state,
133+
)
134+
if progress:
135+
await progress.on_benchmark_update(
136+
estimated_state, scheduler_state
137+
)
138+
except Exception as err:
139+
logger.error(
140+
f"Error updating benchmark estimate/progress: {err}"
141+
)
142142

143143
benchmark = benchmark_class.compile(
144144
args=args,
@@ -151,10 +151,16 @@ async def run(
151151
strategy=strategy,
152152
constraints=constraints,
153153
)
154-
yield None, benchmark, strategy, None
154+
if progress:
155+
await progress.on_benchmark_complete(benchmark)
156+
157+
yield benchmark
155158

156159
try:
157160
strategy, constraints = strategies_generator.send(benchmark)
158161
except StopIteration:
159162
strategy = None
160163
constraints = None
164+
165+
if progress:
166+
await progress.on_finalize()

src/guidellm/benchmark/entrypoints.py

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from guidellm.benchmark.benchmarker import Benchmarker
1111
from guidellm.benchmark.output import GenerativeBenchmarkerOutput
1212
from guidellm.benchmark.profile import Profile, ProfileType
13-
from guidellm.benchmark.progress import BenchmarkerProgressGroup
13+
from guidellm.benchmark.progress import BenchmarkerProgress
1414
from guidellm.benchmark.schemas import GenerativeBenchmark, GenerativeBenchmarksReport
15-
from guidellm.benchmark.types import OutputFormatT, ProcessorInputT, ProgressInputT
15+
from guidellm.benchmark.types import OutputFormatT, ProcessorInputT
1616
from guidellm.data import (
1717
DataLoader,
1818
DatasetPreprocessor,
@@ -271,7 +271,6 @@ async def resolve_output_formats(
271271
return resolved
272272

273273

274-
# @validate_call(config={"arbitrary_types_allowed": True})
275274
async def benchmark_generative_text( # noqa: C901, PLR0915, PLR0912
276275
# Required
277276
target: str,
@@ -296,7 +295,7 @@ async def benchmark_generative_text( # noqa: C901, PLR0915, PLR0912
296295
) = "chat_completions",
297296
data_collator: Callable | Literal["generative"] | None = "generative",
298297
data_sampler: Sampler[int] | Literal["shuffle"] | None = None,
299-
data_num_workers: int | None = 1,
298+
data_num_workers: int | None = None,
300299
dataloader_kwargs: dict[str, Any] | None = None,
301300
random_seed: int = 42,
302301
# Output configuration
@@ -308,7 +307,7 @@ async def benchmark_generative_text( # noqa: C901, PLR0915, PLR0912
308307
| None
309308
) = ("console", "json", "html", "csv"),
310309
# Updates configuration
311-
progress: ProgressInputT | None = None,
310+
progress: BenchmarkerProgress | None = None,
312311
print_updates: bool = False,
313312
# Benchmarker configuration
314313
benchmark_cls: type[GenerativeBenchmark] = GenerativeBenchmark,
@@ -366,37 +365,26 @@ async def benchmark_generative_text( # noqa: C901, PLR0915, PLR0912
366365
output_formats=output_formats, output_path=output_path, console=console
367366
)
368367

369-
progress_group = BenchmarkerProgressGroup(
370-
instances=progress or [], enabled=bool(progress)
371-
)
372368
report = GenerativeBenchmarksReport()
373369
console.print_update(
374370
title="Setup complete, starting benchmarks...", status="success"
375371
)
376372
console.print("\n\n")
377373

378-
async for (
379-
_aggregator_update,
380-
benchmark,
381-
_strategy,
382-
_scheduler_state,
383-
) in progress_group(
384-
profile,
385-
Benchmarker[
386-
GenerativeBenchmark,
387-
GenerationRequest,
388-
GenerationResponse,
389-
]().run(
390-
benchmark_class=benchmark_cls,
391-
requests=request_loader,
392-
backend=backend,
393-
profile=profile,
394-
environment=NonDistributedEnvironment(),
395-
sample_requests=sample_requests,
396-
warmup=warmup,
397-
cooldown=cooldown,
398-
prefer_response_metrics=True,
399-
),
374+
benchmarker: Benchmarker[
375+
GenerativeBenchmark, GenerationRequest, GenerationResponse
376+
] = Benchmarker()
377+
async for benchmark in benchmarker.run(
378+
benchmark_class=benchmark_cls,
379+
requests=request_loader,
380+
backend=backend,
381+
profile=profile,
382+
environment=NonDistributedEnvironment(),
383+
progress=progress,
384+
sample_requests=sample_requests,
385+
warmup=warmup,
386+
cooldown=cooldown,
387+
prefer_response_metrics=True,
400388
):
401389
if benchmark:
402390
report.benchmarks.append(benchmark)

0 commit comments

Comments
 (0)