Skip to content

Commit 6cb8c60

Browse files
Refactor to use kwargs
1 parent 49cad6a commit 6cb8c60

File tree

5 files changed

+29
-45
lines changed

5 files changed

+29
-45
lines changed

src/guidellm/__main__.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,18 @@ def benchmark():
162162
help=(
163163
"Benchmark rate(s) to test. Meaning depends on profile: "
164164
"sweep=number of benchmarks, concurrent=concurrent requests, "
165-
"async/constant/poisson=requests per second. "
166-
"Not used for incremental profile."
165+
"async/constant/poisson=requests per second, "
166+
"incremental=start rate in requests per second."
167167
),
168168
)
169169
@click.option(
170-
"--start-rate",
171-
type=float,
172-
default=BenchmarkGenerativeTextArgs.get_default("start_rate"),
173-
help="Initial rate for incremental profile in requests per second.",
174-
)
175-
@click.option(
176-
"--increment-factor",
177-
type=float,
178-
default=BenchmarkGenerativeTextArgs.get_default("increment_factor"),
179-
help="Factor by which to increase rate over time for incremental profile.",
180-
)
181-
@click.option(
182-
"--rate-limit",
183-
type=int,
184-
default=BenchmarkGenerativeTextArgs.get_default("rate_limit"),
185-
help="Maximum rate cap for incremental profile.",
170+
"--profile-kwargs",
171+
callback=cli_tools.parse_json,
172+
default=BenchmarkGenerativeTextArgs.get_default("profile_kwargs"),
173+
help=(
174+
"JSON string of arguments to pass to the profile. "
175+
'For incremental: {"increment_factor": 0.5, "rate_limit": 100}.'
176+
),
186177
)
187178
# Backend configuration
188179
@click.option(

src/guidellm/benchmark/entrypoints.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ async def resolve_profile(
268268
max_error_rate: float | None,
269269
max_global_error_rate: float | None,
270270
console: Console | None = None,
271+
profile_kwargs: dict[str, Any] | None = None,
271272
) -> Profile:
272273
"""
273274
Resolve and configure a benchmark profile with rate and constraint settings.
@@ -306,6 +307,7 @@ async def resolve_profile(
306307
rate=rate,
307308
random_seed=random_seed,
308309
constraints={**constraints},
310+
**(profile_kwargs or {}),
309311
)
310312
elif constraints:
311313
raise ValueError(
@@ -413,6 +415,7 @@ async def benchmark_generative_text(
413415
max_error_rate=args.max_error_rate,
414416
max_global_error_rate=args.max_global_error_rate,
415417
console=console,
418+
profile_kwargs=args.profile_kwargs,
416419
)
417420
output_formats = await resolve_output_formats(
418421
output_formats=args.output_formats,

src/guidellm/benchmark/profile.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ class IncrementalProfile(ThroughputProfile):
729729
increment_factor: PositiveFloat = Field(
730730
description="Factor by which to increase the rate over time",
731731
)
732-
rate_limit: PositiveInt | None = Field(
732+
rate_limit: PositiveFloat | None = Field(
733733
default=None,
734734
description="Maximum rate cap after which load remains constant",
735735
)
@@ -747,48 +747,47 @@ def resolve_args(
747747
rate_type: str,
748748
rate: list[float] | None,
749749
random_seed: int,
750-
start_rate: float | None = None,
751750
increment_factor: float | None = None,
752-
rate_limit: int | None = None,
751+
rate_limit: float | None = None,
753752
**kwargs: Any,
754753
) -> dict[str, Any]:
755754
"""
756755
Resolve arguments for incremental profile construction.
757756
758757
:param rate_type: Profile type identifier
759-
:param rate: Rate parameter (must be None for incremental)
758+
:param rate: Start rate in requests per second
760759
:param random_seed: Random seed (ignored)
761-
:param start_rate: Initial rate in requests per second
762760
:param increment_factor: Rate increase factor over time
763761
:param rate_limit: Optional maximum rate cap
764762
:param kwargs: Additional arguments passed through unchanged
765763
:return: Resolved arguments dictionary
766-
:raises ValueError: If rate is not None or required params missing
764+
:raises ValueError: If required params missing or invalid
767765
"""
768766
_ = random_seed # unused
769767
if rate_type != "incremental":
770768
raise ValueError("Rate type must be 'incremental' for incremental profile")
771769

772-
if rate is not None:
770+
# For incremental profile, rate is used as start_rate
771+
start_rate = rate[0] if isinstance(rate, list) and rate else rate
772+
if start_rate is None:
773773
raise ValueError(
774-
"rate does not apply to incremental profile, it must be set to None "
775-
"or not set at all. Use start_rate and increment_factor instead."
774+
"rate is required for incremental profile (used as start_rate)"
776775
)
777776

778-
if start_rate is None:
779-
raise ValueError("start_rate is required for incremental profile")
780-
781777
if increment_factor is None:
782-
raise ValueError("increment_factor is required for incremental profile")
778+
raise ValueError(
779+
"increment_factor is required for incremental profile. "
780+
"Pass it via --profile-kwargs '{\"increment_factor\": <value>}'"
781+
)
783782

784783
if start_rate <= 0:
785-
raise ValueError("start_rate must be a positive number")
784+
raise ValueError("rate (start_rate) must be a positive number")
786785

787786
if increment_factor <= 0:
788787
raise ValueError("increment_factor must be a positive number")
789788

790789
if rate_limit is not None and rate_limit <= 0:
791-
raise ValueError("rate_limit must be a positive integer")
790+
raise ValueError("rate_limit must be a positive number")
792791

793792
kwargs["start_rate"] = start_rate
794793
kwargs["increment_factor"] = increment_factor

src/guidellm/benchmark/schemas.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,17 +1840,8 @@ def get_default(cls: type[BenchmarkGenerativeTextArgs], field: str) -> Any:
18401840
rate: float | list[float] | None = Field(
18411841
default=None, description="Request rate(s) for rate-based scheduling"
18421842
)
1843-
start_rate: float | None = Field(
1844-
default=None,
1845-
description="Initial rate for incremental profile in requests per second",
1846-
)
1847-
increment_factor: float | None = Field(
1848-
default=None,
1849-
description="Factor by which to increase rate over time for incremental profile",
1850-
)
1851-
rate_limit: int | None = Field(
1852-
default=None,
1853-
description="Maximum rate cap for incremental profile",
1843+
profile_kwargs: dict[str, Any] | None = Field(
1844+
default=None, description="Additional profile-specific configuration arguments"
18541845
)
18551846
# Backend configuration
18561847
backend: BackendType | Backend = Field(

src/guidellm/scheduler/strategies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ class AsyncIncrementalStrategy(ThroughputStrategy):
543543
description="Factor by which to increase the rate over time",
544544
gt=0,
545545
)
546-
rate_limit: int | None = Field(
546+
rate_limit: float | None = Field(
547547
default=None,
548548
description="Maximum rate cap after which load remains constant",
549549
gt=0,

0 commit comments

Comments
 (0)