Skip to content

Commit 26f3593

Browse files
committed
Always parse rate as list[float]
1 parent d9cbc70 commit 26f3593

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/guidellm/benchmark/entrypoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def benchmark_generative_text( # noqa: C901
6767
| Path
6868
),
6969
profile: StrategyType | ProfileType | Profile,
70-
rate: float | list[float] | None = None,
70+
rate: list[float] | None = None,
7171
random_seed: int = 42,
7272
# Backend configuration
7373
backend: BackendType | Backend = "openai_http",

src/guidellm/benchmark/profile.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __pydantic_schema_base_type__(cls) -> type[Profile]:
8686
def create(
8787
cls,
8888
rate_type: str,
89-
rate: float | int | list[float | int] | None,
89+
rate: list[float] | None,
9090
random_seed: int = 42,
9191
**kwargs: Any,
9292
) -> Profile:
@@ -112,7 +112,7 @@ def create(
112112
def resolve_args(
113113
cls,
114114
rate_type: str,
115-
rate: float | int | list[float, int] | None,
115+
rate: list[float] | None,
116116
random_seed: int,
117117
**kwargs: Any,
118118
) -> dict[str, Any]:
@@ -264,7 +264,7 @@ class SynchronousProfile(Profile):
264264
def resolve_args(
265265
cls,
266266
rate_type: str,
267-
rate: float | int | list[float, int] | None,
267+
rate: list[float] | None,
268268
random_seed: int,
269269
**kwargs: Any,
270270
) -> dict[str, Any]:
@@ -313,7 +313,7 @@ class ConcurrentProfile(Profile):
313313
"""Fixed-concurrency strategy execution profile with configurable stream counts."""
314314

315315
type_: Literal["concurrent"] = "concurrent" # type: ignore[assignment]
316-
streams: int | list[int] = Field(
316+
streams: list[int] = Field(
317317
description="Number of concurrent streams for request scheduling",
318318
gt=0,
319319
)
@@ -330,7 +330,7 @@ class ConcurrentProfile(Profile):
330330
def resolve_args(
331331
cls,
332332
rate_type: str,
333-
rate: float | int | list[float, int] | None,
333+
rate: list[float] | None,
334334
random_seed: int,
335335
**kwargs: Any,
336336
) -> dict[str, Any]:
@@ -344,7 +344,7 @@ def resolve_args(
344344
:return: Dictionary of resolved arguments.
345345
:raises ValueError: If rate is None.
346346
"""
347-
kwargs["streams"] = rate
347+
kwargs["streams"] = [int(r) for r in rate] if rate else None
348348
return kwargs
349349

350350
@property
@@ -401,7 +401,7 @@ class ThroughputProfile(Profile):
401401
def resolve_args(
402402
cls,
403403
rate_type: str,
404-
rate: float | int | list[float, int] | None,
404+
rate: list[float] | None,
405405
random_seed: int,
406406
**kwargs: Any,
407407
) -> dict[str, Any]:
@@ -456,7 +456,7 @@ class AsyncProfile(Profile):
456456
strategy_type: Literal["constant", "poisson"] = Field(
457457
description="Type of asynchronous strategy pattern to use",
458458
)
459-
rate: float | list[float] = Field(
459+
rate: list[float] = Field(
460460
description="Request scheduling rate in requests per second",
461461
gt=0,
462462
)
@@ -482,7 +482,7 @@ class AsyncProfile(Profile):
482482
def resolve_args(
483483
cls,
484484
rate_type: str,
485-
rate: float | int | list[float, int] | None,
485+
rate: list[float] | None,
486486
random_seed: int,
487487
**kwargs: Any,
488488
) -> dict[str, Any]:
@@ -516,7 +516,7 @@ def resolve_args(
516516
@property
517517
def strategy_types(self) -> list[StrategyType]:
518518
"""Get async strategy types for each configured rate."""
519-
num_strategies = len(self.rate) if isinstance(self.rate, list) else 1
519+
num_strategies = len(self.rate)
520520
return [self.strategy_type] * num_strategies
521521

522522
def next_strategy(
@@ -533,7 +533,7 @@ def next_strategy(
533533
or None if all rates completed.
534534
:raises ValueError: If strategy_type is neither 'constant' nor 'poisson'.
535535
"""
536-
rate = self.rate if isinstance(self.rate, list) else [self.rate]
536+
rate = self.rate
537537

538538
if len(self.completed_strategies) >= len(rate):
539539
return None
@@ -607,7 +607,7 @@ class SweepProfile(Profile):
607607
def resolve_args(
608608
cls,
609609
rate_type: str,
610-
rate: float | int | list[float, int] | None,
610+
rate: list[float] | None,
611611
random_seed: int,
612612
**kwargs: Any,
613613
) -> dict[str, Any]:
@@ -620,7 +620,8 @@ def resolve_args(
620620
:param kwargs: Additional arguments to pass through.
621621
:return: Dictionary of resolved arguments.
622622
"""
623-
kwargs["sweep_size"] = kwargs.get("sweep_size", rate)
623+
sweep_size_from_rate = rate[0] if rate else None
624+
kwargs["sweep_size"] = kwargs.get("sweep_size", sweep_size_from_rate)
624625
kwargs["random_seed"] = random_seed
625626
if rate_type in ["constant", "poisson"]:
626627
kwargs["strategy_type"] = rate_type

0 commit comments

Comments
 (0)