Skip to content

Commit fa04fa1

Browse files
Refactor to use kwargs
1 parent 69c86bf commit fa04fa1

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-34
lines changed

src/guidellm/__main__.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,27 +149,18 @@ def benchmark():
149149
help=(
150150
"Benchmark rate(s) to test. Meaning depends on profile: "
151151
"sweep=number of benchmarks, concurrent=concurrent requests, "
152-
"async/constant/poisson=requests per second. "
153-
"Not used for incremental profile."
152+
"async/constant/poisson=requests per second, "
153+
"incremental=start rate in requests per second."
154154
),
155155
)
156156
@click.option(
157-
"--start-rate",
158-
type=float,
159-
default=BenchmarkGenerativeTextArgs.get_default("start_rate"),
160-
help="Initial rate for incremental profile in requests per second.",
161-
)
162-
@click.option(
163-
"--increment-factor",
164-
type=float,
165-
default=BenchmarkGenerativeTextArgs.get_default("increment_factor"),
166-
help="Factor by which to increase rate over time for incremental profile.",
167-
)
168-
@click.option(
169-
"--rate-limit",
170-
type=int,
171-
default=BenchmarkGenerativeTextArgs.get_default("rate_limit"),
172-
help="Maximum rate cap for incremental profile.",
157+
"--profile-kwargs",
158+
callback=cli_tools.parse_json,
159+
default=BenchmarkGenerativeTextArgs.get_default("profile_kwargs"),
160+
help=(
161+
"JSON string of arguments to pass to the profile. "
162+
'For incremental: {"increment_factor": 0.5, "rate_limit": 100}.'
163+
),
173164
)
174165
# Backend configuration
175166
@click.option(

src/guidellm/benchmark/entrypoints.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ async def resolve_profile(
324324
max_error_rate: float | None,
325325
max_global_error_rate: float | None,
326326
console: Console | None = None,
327+
profile_kwargs: dict[str, Any] | None = None,
327328
) -> Profile:
328329
"""
329330
Resolve and configure a benchmark profile with rate and constraint settings.
@@ -370,6 +371,7 @@ async def resolve_profile(
370371
random_seed=random_seed,
371372
rampup_duration=rampup,
372373
constraints={**constraints},
374+
**(profile_kwargs or {}),
373375
)
374376
elif constraints:
375377
raise ValueError(
@@ -501,6 +503,7 @@ async def benchmark_generative_text(
501503
max_error_rate=args.max_error_rate,
502504
max_global_error_rate=args.max_global_error_rate,
503505
console=console,
506+
profile_kwargs=args.profile_kwargs,
504507
)
505508
output_formats = await resolve_output_formats(
506509
outputs=args.outputs, output_dir=args.output_dir, console=console

src/guidellm/benchmark/profiles.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ class IncrementalProfile(ThroughputProfile):
732732
increment_factor: PositiveFloat = Field(
733733
description="Factor by which to increase the rate over time",
734734
)
735-
rate_limit: PositiveInt | None = Field(
735+
rate_limit: PositiveFloat | None = Field(
736736
default=None,
737737
description="Maximum rate cap after which load remains constant",
738738
)
@@ -750,48 +750,47 @@ def resolve_args(
750750
rate_type: str,
751751
rate: list[float] | None,
752752
random_seed: int,
753-
start_rate: float | None = None,
754753
increment_factor: float | None = None,
755-
rate_limit: int | None = None,
754+
rate_limit: float | None = None,
756755
**kwargs: Any,
757756
) -> dict[str, Any]:
758757
"""
759758
Resolve arguments for incremental profile construction.
760759
761760
:param rate_type: Profile type identifier
762-
:param rate: Rate parameter (must be None for incremental)
761+
:param rate: Start rate in requests per second
763762
:param random_seed: Random seed (ignored)
764-
:param start_rate: Initial rate in requests per second
765763
:param increment_factor: Rate increase factor over time
766764
:param rate_limit: Optional maximum rate cap
767765
:param kwargs: Additional arguments passed through unchanged
768766
:return: Resolved arguments dictionary
769-
:raises ValueError: If rate is not None or required params missing
767+
:raises ValueError: If required params missing or invalid
770768
"""
771769
_ = random_seed # unused
772770
if rate_type != "incremental":
773771
raise ValueError("Rate type must be 'incremental' for incremental profile")
774772

775-
if rate is not None:
773+
# For incremental profile, rate is used as start_rate
774+
start_rate = rate[0] if isinstance(rate, list) and rate else rate
775+
if start_rate is None:
776776
raise ValueError(
777-
"rate does not apply to incremental profile, it must be set to None "
778-
"or not set at all. Use start_rate and increment_factor instead."
777+
"rate is required for incremental profile (used as start_rate)"
779778
)
780779

781-
if start_rate is None:
782-
raise ValueError("start_rate is required for incremental profile")
783-
784780
if increment_factor is None:
785-
raise ValueError("increment_factor is required for incremental profile")
781+
raise ValueError(
782+
"increment_factor is required for incremental profile. "
783+
"Pass it via --profile-kwargs '{\"increment_factor\": <value>}'"
784+
)
786785

787786
if start_rate <= 0:
788-
raise ValueError("start_rate must be a positive number")
787+
raise ValueError("rate (start_rate) must be a positive number")
789788

790789
if increment_factor <= 0:
791790
raise ValueError("increment_factor must be a positive number")
792791

793792
if rate_limit is not None and rate_limit <= 0:
794-
raise ValueError("rate_limit must be a positive integer")
793+
raise ValueError("rate_limit must be a positive number")
795794

796795
kwargs["start_rate"] = start_rate
797796
kwargs["increment_factor"] = increment_factor

src/guidellm/scheduler/strategies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ class AsyncIncrementalStrategy(ThroughputStrategy):
653653
description="Factor by which to increase the rate over time",
654654
gt=0,
655655
)
656-
rate_limit: int | None = Field(
656+
rate_limit: float | None = Field(
657657
default=None,
658658
description="Maximum rate cap after which load remains constant",
659659
gt=0,

0 commit comments

Comments
 (0)