Skip to content

Commit 3ac7729

Browse files
authored
fix: fix concurrency validation when request_count is not set (#480)
1 parent fe0b0b2 commit 3ac7729

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/aiperf/common/config/user_config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,11 @@ def validate_concurrency_limits(self) -> Self:
386386
f"the number of conversations ({self.input.conversation.num}). "
387387
"Either reduce --concurrency or increase --conversation-num."
388388
)
389-
# For single-turn scenarios, check against request_count
390-
elif self.loadgen.concurrency > self.loadgen.request_count:
389+
# For single-turn scenarios, check against request_count if it is set
390+
elif (
391+
"request_count" in self.loadgen.model_fields_set
392+
and self.loadgen.concurrency > self.loadgen.request_count
393+
):
391394
raise ValueError(
392395
f"Concurrency ({self.loadgen.concurrency}) cannot be greater than "
393396
f"the request count ({self.loadgen.request_count}). "

tests/unit/common/config/test_user_config.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,27 @@ def test_concurrency_validation_with_request_rate():
707707
)
708708

709709

710-
def test_concurrency_validation_applies_against_default_request_count():
711-
"""Test that concurrency validation applies even when request_count uses default value."""
712-
# When concurrency exceeds the default request_count, validation should fail
710+
def test_concurrency_validation_skipped_when_request_count_not_set():
711+
"""Test that concurrency validation is skipped when request_count is not explicitly set."""
712+
config = UserConfig(
713+
endpoint=EndpointConfig(
714+
model_names=["test-model"],
715+
type=EndpointType.CHAT,
716+
custom_endpoint="test",
717+
),
718+
loadgen=LoadGeneratorConfig(
719+
concurrency=100,
720+
request_rate=10.0,
721+
),
722+
)
723+
assert config.loadgen.concurrency == 100
724+
725+
726+
def test_concurrency_validation_applies_when_request_count_set():
727+
"""Test that concurrency validation applies when request_count is explicitly set."""
713728
with pytest.raises(
714729
ValueError,
715-
match="Concurrency \\(100\\) cannot be greater than the request count \\(10\\)",
730+
match="Concurrency \\(100\\) cannot be greater than the request count \\(50\\)",
716731
):
717732
UserConfig(
718733
endpoint=EndpointConfig(
@@ -722,5 +737,23 @@ def test_concurrency_validation_applies_against_default_request_count():
722737
),
723738
loadgen=LoadGeneratorConfig(
724739
concurrency=100,
740+
request_count=50,
725741
),
726742
)
743+
744+
745+
def test_concurrency_validation_with_duration_benchmarking():
746+
"""Test that concurrency validation is skipped with duration-based benchmarking."""
747+
config = UserConfig(
748+
endpoint=EndpointConfig(
749+
model_names=["test-model"],
750+
type=EndpointType.CHAT,
751+
custom_endpoint="test",
752+
),
753+
loadgen=LoadGeneratorConfig(
754+
concurrency=100,
755+
benchmark_duration=60,
756+
),
757+
)
758+
assert config.loadgen.concurrency == 100
759+
assert config.loadgen.benchmark_duration == 60

0 commit comments

Comments
 (0)